');
+ $stdid='';
+ }
+ $r->print('\n"); }
+ &endGradeScreen($r);
+ return OK;
+
+}
+
+sub startGradeScreen {
+ my ($r,$mode)=@_;
+
+ my $showPoints =
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard';
+ my $notshowSPRSlink =
+ (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external')
+ || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals')
+ || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'));
+ my $notshowTotals=
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals';
+ my $showCategories=
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories';
+
+ my $allowed_to_view = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
+ my $allowed_to_edit = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
+
+ if ($allowed_to_view) {
+ my @notes;
+ push(@notes,&mt('Students do not see total points.')) if ($notshowTotals);
+ push(@notes,&mt('Students do not see link to spreadsheet.')) if ($notshowSPRSlink);
+ push(@notes,&mt('Students will see points based on problem weights.')) if ($showPoints);
+ push(@notes,&mt('Students will see points based on categories.')) if ($showCategories);
+ push(@notes, &Apache::lonhtmlcommon::coursepreflink(&mt('Grade display settings'),'grading'));
+ $r->print(&Apache::loncommon::head_subbox(join(' ',@notes)));
+ }
+
+
+ $r->print("\n".'
'
+ .&Apache::loncommon::end_data_table_row());
+ }
}
}
@@ -211,45 +403,749 @@ HEADER
}
# If there were any problems at the top level, print an extra "catchall"
- if ($unaccountedTotal > 0) {
- my $ratio = $unaccountedCorrect / $unaccountedTotal;
- my $color = mixColors(\@start, \@end, $ratio);
- $r->print("
");
- $r->print("Problems Not Contained In Sequences
");
+ if ($topLevelParts > 0) {
+ my $ratio = $topLevelRight / $topLevelParts;
+ my $color = &mixColors(\@start, \@end, $ratio);
+ $r->print(&Apache::loncommon::start_data_table_row()
+ .'
');
+ $r->print(&mt("Problems Not Contained In A Folder")."
");
+ $r->print("$topLevelRight / $topLevelParts
"
+ .&Apache::loncommon::end_data_table_row());
+ }
+
+#
+# show totals (if applicable), close table
+#
+ if ($showPoints) {
+ my $maxHelpLink = &Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct");
+
+ $title = $showPoints ? "Points" : "Parts Done";
+ my $totaltitle = $showPoints ? &mt("Awarded Total Points") : &mt("Total Parts Done");
+ $r->print(&Apache::loncommon::start_data_table_row()
+ .'
'.$totaltitle.': '.$totalRight.' ');
+ $r->print(&mt('Max Possible To Date')." $maxHelpLink: $totalPossible ");
+ $title = $showPoints ? "Points" : "Parts";
+ $r->print(&mt("Total $title In Course").': '.$totalParts.'
'
+ .&Apache::loncommon::end_data_table_row());
}
- my $maxHelpLink = Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct");
+ $r->print(&Apache::loncommon::end_data_table());
+}
+
+#
+# === Outputting category-based grades.
+#
+# $category{'order'}: output order of categories by id
+# $category{'all'}: complete list of all categories
+# $category{$id.'_name'}: display-name of category
+#
- $r->print("
Total Parts Correct: $totalRight ");
- $r->print("Max Possible To Date $maxHelpLink: $totalPossible ");
- $r->print("Total Parts In Course: $totalParts
\n\n");
+sub outputCategories {
+ my ($r,$showPoints,$notshowTotals,
+ $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_;
+# Take care of storing and retrieving categories
+
+ my $cangrade=&Apache::lonnet::allowed('mgr');
+
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my %categories=();
+# Loading old categories
+ %categories=&Apache::lonnet::dump('grading_categories',$cdom,$cnum);
+# Storing
+ if (($cangrade) && (($env{'form.storechanges'}) || ($env{'form.storemove'} ne '') || ($env{'form.cmd'} ne ''))) {
+# Process the changes
+ %categories=&process_category_edits($r,$cangrade,%categories);
+# Actually store
+ &Apache::lonnet::put('grading_categories',\%categories,$cdom,$cnum);
+ }
+# new categories loaded now
+ &output_category_table($r,$cangrade,$navmap,%categories);
+#
+ if ($cangrade) {
+ $r->print(&Apache::loncommon::resourcebrowser_javascript().
+ ''.
+ ''.
+ ''.
+ ''.
+ '');
+ }
+#
+# Debug
+#
+# my %data=&dumpdata($navmap);
+# foreach (keys(%data)) {
+# $r->print("\n ".$_.'='.$data{$_});
+# }
+# my @debugarray=('5:1','4:3','1:1','5:5','6:7');
+# $r->print("Array: ".join(',',@debugarray).' ');
+# $r->print("0,0,0: ".join(',',&drop(0,0,0,@debugarray)).' ');
+# $r->print("1,0,0: ".join(',',&drop(1,0,0,@debugarray)).' ');
+# $r->print("0,1,0: ".join(',',&drop(0,1,0,@debugarray)).' ');
+# $r->print("1,1,0: ".join(',',&drop(1,1,0,@debugarray)).' ');
+#
+# $r->print("0,0,2: ".join(',',&drop(0,0,2,@debugarray)).' ');
+# $r->print("1,0,2: ".join(',',&drop(1,0,2,@debugarray)).' ');
+# $r->print("0,1,2: ".join(',',&drop(0,1,2,@debugarray)).' ');
+# $r->print("1,1,2: ".join(',',&drop(1,1,2,@debugarray)).' ');
+#
+# $r->print("0,0,4: ".join(',',&drop(0,0,4,@debugarray)).' ');
+# $r->print("1,0,4: ".join(',',&drop(1,0,4,@debugarray)).' ');
+# $r->print("0,1,4: ".join(',',&drop(0,1,4,@debugarray)).' ');
+# $r->print("1,1,4: ".join(',',&drop(1,1,4,@debugarray)).' ');
+#
+# $r->print("0,0,5: ".join(',',&drop(0,0,5,@debugarray)).' ');
+# $r->print("1,0,5: ".join(',',&drop(1,0,5,@debugarray)).' ');
+# $r->print("0,1,5: ".join(',',&drop(0,1,5,@debugarray)).' ');
+# $r->print("1,1,5: ".join(',',&drop(1,1,5,@debugarray)).' ');
+#
+# $r->print("0,0,7: ".join(',',&drop(0,0,7,@debugarray)).' ');
+# $r->print("1,0,7: ".join(',',&drop(1,0,7,@debugarray)).' ');
+# $r->print("0,1,7: ".join(',',&drop(0,1,7,@debugarray)).' ');
+# $r->print("1,1,7: ".join(',',&drop(1,1,7,@debugarray)).' ');
- $r->print("