--- loncom/interface/lonquickgrades.pm 2008/12/12 18:44:32 1.43.2.1
+++ loncom/interface/lonquickgrades.pm 2011/01/21 16:28:32 1.64
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Quick Student Grades Display
#
-# $Id: lonquickgrades.pm,v 1.43.2.1 2008/12/12 18:44:32 raeburn Exp $
+# $Id: lonquickgrades.pm,v 1.64 2011/01/21 16:28:32 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,7 +25,6 @@
#
# http://www.lon-capa.org/
#
-# Created Nov. 14, 2002 by Jeremy Bowers
package Apache::lonquickgrades;
@@ -62,42 +61,117 @@ sub real_handler {
&Apache::loncommon::no_cache($r);
$r->send_http_header;
- my $showPoints =
+ my $showPoints =
$env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard';
- my $notshowSPRSlink =
- $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external';
+ my $notshowSPRSlink =
+ (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external')
+ || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'));
+ my $notshowTotals=
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals';
+ my $showCategories=
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories';
+
+
+ my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display";
+ my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}];
+ $r->print(&Apache::loncommon::start_page($title,undef,
+ {'bread_crumbs' => $brcrum})
+ );
- # Create the nav map
- my $navmap = Apache::lonnavmaps::navmap->new();
+ &startGradeScreen($r,'quick');
+
+ $r->rflush();
+
+# my $uname='korte';
+# my $udom='gerd';
- if (!defined($navmap)) {
- my $requrl = $r->uri;
- $env{'user.error.msg'} = "$requrl:bre:0:0:Navamp initialization failed.";
- return HTTP_NOT_ACCEPTABLE;
+ my $uname;
+ my $udom;
+
+ my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=
+ &getData($showPoints,$uname,$udom);
+
+ if ($showCategories) {
+ &outputCategories($r,$showPoints,$notshowTotals,
+ $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
+ } else {
+ &outputTable($r,$showPoints,$notshowTotals,
+ $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
}
+ &endGradeScreen($r);
+ return OK;
- # Keep this hash in sync with %statusIconMap in lonnavmaps; they
- # should match color/icon
- my $res = $navmap->firstResource(); # temp resource to access constants
-
- # Header
- my $title = $showPoints ? "Points Display" : "Completed Problems Display";
- $r->print(&Apache::loncommon::start_page($title));
-
- if (!$showPoints && !$notshowSPRSlink ) {
- $r->print('
'
- .&mt('This screen shows how many problems (or problem parts) you have completed'
- .', and how many you have not yet done.'
- .' You can also look at [_1]a detailed score sheet[_2].'
- ,'','')
- .'
');
+}
+
+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(''.&mt('This may take a few moments to display.').'
');
- $r->rflush();
+ $r->print("\n".'');
+ $r->print("\n".'- '.
+ ($showPoints?&mt('Individual Points Overview'):($showCategories?&mt('Grades Overview'):&mt('Completion Overview'))).
+ '
');
+
+ if (!($showPoints || $notshowSPRSlink) || ($allowed_to_view)) {
+ $r->print("\n".'- '.
+ &mt('Spreadsheet (Detailed)').'
');
+ }
+ if ($allowed_to_view) {
+ $r->print("\n".'- '.
+ &mt('Statistics and Reports').'
');
- # End navmap using boilerplate
+ $r->print("\n".'- '.
+ &mt('Assessment Overview Chart').'
');
+
+ }
+ if ($allowed_to_edit) {
+ $r->print("\n".'- '.
+ &mt('Problem Grading').'
');
+ }
+ $r->print("\n".'
'."\n");
+ $r->print('');
+}
+
+sub endGradeScreen {
+ my ($r)=@_;
+ $r->print('
');
+}
+
+
+sub getData {
+
+ my ($showPoints,$uname,$udom)=@_;
+
+ &Apache::lonnet::logthis("About to call with $uname $udom");
+
+ # Create the nav map
+ my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom);
+
+ my $res = $navmap->firstResource(); # temp resource to access constants
my $iterator = $navmap->getIterator(undef, undef, undef, 1);
my $depth = 1;
@@ -212,11 +286,17 @@ sub real_handler {
}
$curRes = $iterator->next();
}
+ return ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
+}
- $iterator = $navmap->getIterator(undef, undef, undef, 1);
- $depth = 1;
- $iterator->next(); # ignore first BEGIN_MAP
- $curRes = $iterator->next();
+#
+# Outputting everything.
+#
+
+sub outputTable {
+
+ my ($r,$showPoints,$notshowTotals,
+ $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_;
my @start = (255, 255, 192);
my @end = (0, 192, 0);
@@ -227,12 +307,21 @@ sub real_handler {
$r->print(&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
.''.&mt('Folder').' | ');
- $title = &mt($showPoints ? "Points Scored" : "Done");
+ my $title = &mt($showPoints ? "Points Scored" : "Done");
if ($totalAttempted) {
- $title .= " / " . &mt("Attempted");
+ $title .= " / " . &mt("Attempted");
}
- $r->print("$title / ".&mt('Total').''
+ $r->print(" | $title".($notshowTotals?'':" / ".&mt('Total')).' | '
.&Apache::loncommon::end_data_table_header_row());
+#
+# Output of folder scores
+#
+
+ my $iterator = $navmap->getIterator(undef, undef, undef, 1);
+ my $depth = 1;
+ $iterator->next(); # ignore first BEGIN_MAP
+ my $curRes = $iterator->next();
+
while ($depth > 0) {
if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
if ($curRes == $iterator->END_MAP()) { $depth--; }
@@ -247,7 +336,7 @@ sub real_handler {
if ($total > 0) {
my $ratio;
$ratio = $correct / $total;
- my $color = mixColors(\@start, \@end, $ratio);
+ my $color = &mixColors(\@start, \@end, $ratio);
$r->print(&Apache::loncommon::start_data_table_row()
.'');
@@ -255,22 +344,22 @@ sub real_handler {
for (my $i = 1; $i < $depth; $i++) { $thisIndent .= $indentString; }
$r->print("$thisIndent$title | ");
- if ($totalAttempted) {
- $r->print(''
+ if ($totalAttempted) {
+ $r->print(' | '
.$thisIndent
.''
- .$correct.' / '.$attempted.' / '.$total
+ .$correct.' / '.$attempted.($notshowTotals?'':' / '.$total)
.' | '
.&Apache::loncommon::end_data_table_row()
);
- } else {
- $r->print(''
+ } else {
+ $r->print(' | '
.$thisIndent
.''
- .$correct.' / '.$total
+ .$correct.($notshowTotals?'':' / '.$total)
.' | '
.&Apache::loncommon::end_data_table_row());
- }
+ }
}
}
@@ -288,28 +377,68 @@ sub real_handler {
.&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");
+ 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.' | '
+ $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());
}
$r->print(&Apache::loncommon::end_data_table()
.&Apache::loncommon::end_page());
- return OK;
+}
+
+#
+# Outputting category-based grades.
+#
+
+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=();
+# Storing
+ if (($cangrade) && ($env{'form.storechanges'})) {
+
+# Actually store
+ &Apache::lonnet::put('grading_categories',\%categories,$cdom,$cnum);
+ } else {
+# Loading
+ %categories=&Apache::lonnet::dump('grading_categories',$cdom,$cnum);
+ }
+# categories loaded now
+# Form only generated if user can change the grading categories
+ if ($cangrade) {
+ $r->print('');
+ }
}
# Pass this two refs to arrays for the start and end color, and a number
# from 0 to 1 for how much of the latter you want to mix in. It will
# return a string ready to show ("#FFC309");
+
sub mixColors {
my $start = shift;
my $end = shift;