File:  [LON-CAPA] / loncom / interface / lonquickgrades.pm
Revision 1.49.6.6.2.1: download - view: text, annotated - select for diffs
Tue Sep 8 04:24:18 2020 UTC (3 years, 8 months ago) by raeburn
Branches: version_2_11_3_msu
- For 2.11.3 (modified)
  Include changes in 1.110, 1.117

    1: # The LearningOnline Network with CAPA
    2: # Quick Student Grades Display
    3: #
    4: # $Id: lonquickgrades.pm,v 1.49.6.6.2.1 2020/09/08 04:24:18 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: 
   29: package Apache::lonquickgrades;
   30: 
   31: use strict;
   32: use Apache::Constants qw(:common :http REDIRECT);
   33: use POSIX;
   34: use Apache::loncommon;
   35: use Apache::lonlocal;
   36: use Apache::lonnet;
   37: use Apache::grades;
   38: use Apache::lonuserstate;
   39: 
   40: sub handler {
   41:     my $r = shift;
   42:     return real_handler($r);
   43: }
   44: 
   45: sub real_handler {
   46:     my $r = shift;
   47: 
   48:     &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
   49: 
   50:     # Handle header-only request
   51:     if ($env{'browser.mathml'}) {
   52: 	&Apache::loncommon::content_type($r,'text/xml');
   53:     } else {
   54: 	&Apache::loncommon::content_type($r,'text/html');
   55:     }
   56:     if ($r->header_only) {
   57: 	$r->send_http_header;
   58:         return OK;
   59:     }
   60: 
   61:     my $cangrade=&Apache::lonnet::allowed('mgr');
   62:     my $showPoints =
   63:         $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard';
   64: 
   65:     my $reinitresult;
   66: 
   67:     if ($env{'request.course.id'}) {
   68:         my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
   69:         my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
   70:         my ($blocked,$blocktext) =
   71:             &Apache::loncommon::blocking_status('grades',$cnum,$cdom);
   72:         if ($blocked) {
   73:             my $checkrole = "cm./$cdom/$cnum";
   74:             if ($env{'request.course.sec'} ne '') {
   75:                 $checkrole .= "/$env{'request.course.sec'}";
   76:             }
   77:             unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) &&
   78:                     ($env{'request.role'} !~ m{^st\./$cdom/$cnum})) {
   79:                 &grades_blocked($r,$blocktext,$showPoints);
   80:                 return OK;
   81:             }
   82:         }
   83:     }
   84: 
   85:     unless ($cangrade) {
   86:         # Check for critical messages and redirect if present.
   87:         my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'grades');
   88:         if ($redirect) {
   89:             &Apache::loncommon::content_type($r,'text/html');
   90:             $r->header_out(Location => $url);
   91:             return REDIRECT;
   92:         }
   93: 
   94:         # Check if course needs to be re-initialized
   95:         my $loncaparev = $r->dir_config('lonVersion');
   96:         ($reinitresult,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
   97: 
   98:         if ($reinitresult eq 'switch') {
   99:             &Apache::loncommon::content_type($r,'text/html');
  100:             $r->send_http_header;
  101:             $r->print(&Apache::loncommon::check_release_result(@reinit));
  102:             return OK;
  103:         } elsif ($reinitresult eq 'update') {
  104:             my $cid = $env{'request.course.id'};
  105:             my $cnum = $env{'course.'.$cid.'.num'};
  106:             my $cdom = $env{'course.'.$cid.'.domain'};
  107:             &Apache::loncommon::content_type($r,'text/html');
  108:             $r->send_http_header;
  109:             &startpage($r,$showPoints);
  110:             my $preamble = '<div id="LC_update_'.$cid.'" class="LC_info">'.
  111:                            '<br />'.
  112:                            &mt('Your course session is being updated because of recent changes by course personnel.').
  113:                            ' '.&mt('Please be patient.').'<br /></div>'.
  114:                            '<div style="padding:0;clear:both;margin:0;border:0"></div>';
  115:             my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble);
  116:             &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Updating course'));
  117:             $r->rflush();
  118:             my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
  119:             &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Finished'));
  120:             &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
  121:             my $closure = <<ENDCLOSE;
  122: <script type="text/javascript">
  123: // <![CDATA[
  124: \$("#LC_update_$cid").hide('slow');
  125: // ]]>
  126: </script>
  127: ENDCLOSE
  128:             if ($ferr) {
  129:                 $r->print($closure.&Apache::loncommon::end_page());
  130:                 my $requrl = $r->uri;
  131:                 $env{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
  132:                 $env{'user.reinit'} = 1;
  133:                 return HTTP_NOT_ACCEPTABLE;
  134:             } else {
  135:                $r->print($closure);
  136:             }
  137:         }
  138:     }
  139: 
  140:     unless ($reinitresult eq 'update') {
  141:         # Send header, don't cache this page
  142:         &Apache::loncommon::no_cache($r);
  143:         $r->send_http_header;
  144:         &startpage($r,$showPoints);
  145:     }
  146:     $r->rflush();
  147: 
  148:     &startGradeScreen($r);
  149: 
  150: #
  151: # Pick student
  152: #
  153:     my $uname;
  154:     my $udom;
  155:     my $stdid;
  156:     if ($cangrade) {
  157:         if ($env{'form.uname'}) { $uname=$env{'form.uname'}; }
  158:         if ($env{'form.udom'}) { $udom=$env{'form.udom'}; }
  159:         if ($env{'form.id'}) { $stdid=$env{'form.id'}; }
  160:         if (($stdid) && ($udom)) {
  161:             $uname=(&Apache::lonnet::idget($udom,[$stdid],'ids'))[1];
  162:         }
  163:         if (($stdid) && (!$uname)) {
  164:             $r->print('<p><span class="LC_warning">'.&mt("Unknown Student/Employee ID: [_1]",$stdid).'</span></p>');
  165:             $stdid='';
  166:         }
  167:         if (($uname eq '') && ($udom eq '')) {
  168:             $uname = $env{'user.name'};
  169:             $udom = $env{'user.domain'};
  170:         }
  171:         $r->print('<form method="post" name="quickform" action="/adm/quickgrades">');
  172:         my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
  173:            &Apache::loncommon::selectstudent_link('quickform','uname','udom');
  174:         $r->print("<p>\n".&Apache::loncommon::studentbrowser_javascript()."\n");
  175:         $r->print(&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]'
  176:                  ,'<input type="text" value="'.$uname.'" size="12" name="uname" />'
  177:                  ,'<input type="text" value="'.$stdid.'" size="12" name="id" /> '
  178:                  ,$chooseopt).
  179:                  '&nbsp;&nbsp;<input type="submit" name="display" value="'.&mt('Display Individual Student').'" /></p>');
  180:         if (($uname) && ($udom)) {
  181:             $r->print('<p>'.&mt('Full Name: [_1]',&Apache::loncommon::plainname($uname,$udom)).'</p>');
  182:         }
  183:     } else {
  184:         $r->print('<p class="LC_info">'.&mt('This may take a few moments to display.').'</p>');
  185:     }
  186:     $r->rflush();
  187: 
  188:     my $notshowTotals=
  189:         $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals';
  190: 
  191:     my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,
  192:         $topLevelRight,$topLevelAttempted) = &getData($showPoints,$uname,$udom);
  193: 
  194:     if (ref($navmap)) {
  195:         &outputTable($r,$showPoints,$notshowTotals,$navmap,$totalParts,$totalPossible,
  196:                      $totalRight,$totalAttempted,$topLevelParts,$topLevelRight,
  197:                      $topLevelAttempted);
  198:     } else {
  199:         if ($cangrade) { $r->print("\n</form>\n"); }
  200:         my $requrl = $r->uri;
  201:         $env{'user.error.msg'} = "$requrl:bre:0:0:Navmap initialization failed.";
  202:         return HTTP_NOT_ACCEPTABLE;
  203:     }
  204:     if ($cangrade) { $r->print("\n</form>\n"); }
  205:     &endGradeScreen($r);
  206:     return OK;
  207: }
  208: 
  209: sub grades_blocked {
  210:     my ($r,$blocktext,$caller) = @_;
  211:     my $title = 'Points Display';
  212:     if ($caller eq 'spreadsheet') {
  213:         $title = 'Spreadsheet';
  214:     } elsif ($env{'course.'.$env{'request.course.id'}.'.grading'} ne 'standard') {
  215:         $title = 'Completed Problems Display';
  216:     }
  217:     my $brcrum = [{href=>"/adm/quickgrades",text => $title}];
  218:     &Apache::lonhtmlcommon::clear_breadcrumbs();
  219:     &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/quickgrades',
  220:                                             text=> $title});
  221:     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs($title);
  222:     &Apache::loncommon::content_type($r,'text/html');
  223:     &Apache::loncommon::no_cache($r);
  224:     $r->send_http_header;
  225:     $r->print(&Apache::loncommon::start_page($title).
  226:               $breadcrumbs.
  227:               $blocktext.
  228:               &Apache::loncommon::end_page());
  229:     return;
  230: }
  231: 
  232: #
  233: # Go through the complete course and collect data
  234: #
  235: 
  236: sub getData {
  237: 
  238:     my ($showPoints,$uname,$udom)=@_;
  239: 
  240:     # Create the nav map
  241:     my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom);
  242: 
  243:     if (!defined($navmap)) {
  244:         return ();
  245:     }
  246: 
  247:     my $res = $navmap->firstResource(); # temp resource to access constants
  248: 
  249:     my $iterator = $navmap->getIterator(undef, undef, undef, 1);
  250:     my $depth = 1;
  251:     $iterator->next(); # ignore first BEGIN_MAP
  252:     my $curRes = $iterator->next();
  253: 
  254:     # General overview of the following: Walk along the course resources.
  255:     # For every problem in the resource, tell its parent maps how many
  256:     # parts and how many parts correct it has. After that, each map will
  257:     # have a count of the total parts underneath it, correct and otherwise.
  258:     # After that, we will walk through the course again and read off
  259:     # maps in order, with their data. 
  260:     # (If in the future people decide not to be cumulative, only add
  261:     #  the counts to the parent map.)
  262:     # For convenience, "totalParts" is also "totalPoints" when we're looking
  263:     #  at points; I can't come up with a variable name that makes sense
  264:     #  equally for both cases.
  265: 
  266:     my $totalParts = 0; my $totalPossible = 0; my $totalRight = 0;
  267:     my $totalAttempted = 0;
  268:     my $now = time();
  269:     my $topLevelParts = 0; my $topLevelRight = 0; my $topLevelAttempted = 0;
  270: 
  271:     # Pre-run: Count parts correct
  272:     while ( $depth > 0 ) {
  273:         if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
  274:         if ($curRes == $iterator->END_MAP()) { $depth--; }
  275: 
  276:         if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout)
  277:         {
  278:             # Get number of correct, incorrect parts
  279:             my $parts = $curRes->parts();
  280:             my $partsRight = 0;
  281: 	    my $partsCount = 0;
  282: 	    my $partsAttempted = 0;
  283:             my $stack = $iterator->getStack();
  284:             
  285:             for my $part (@{$parts}) {
  286: 		my $dateStatus = $curRes->getDateStatus($part);
  287:                 my $weight = $curRes->weight($part);
  288:                 my $problemstatus = $curRes->problemstatus($part);
  289: 
  290:                 if ($curRes->solved($part) eq 'excused') {
  291:                     next;
  292:                 }
  293: 		if ($showPoints) {
  294: 		    my $score = 0;
  295: 		    # If we're not telling status and the answer date isn't passed yet, 
  296: 		    # it's an "attempted" point
  297: 		    if ((($problemstatus eq 'no') ||
  298:                          ($problemstatus eq 'no_feedback_ever')) &&
  299: 			($dateStatus != $curRes->ANSWER_OPEN)) {
  300: 			my $status = $curRes->simpleStatus($part);
  301: 			if ($status == $curRes->ATTEMPTED) {
  302: 			    $partsAttempted += $weight;
  303: 			    $totalAttempted += $partsAttempted;
  304: 			}
  305: 		    } else {
  306: 			$score = &Apache::grades::compute_points($weight, $curRes->awarded($part));
  307: 		    }
  308: 		    $partsRight += $score;
  309: 		    $totalRight += $score;
  310: 		    $partsCount += $weight;
  311: 
  312: 		    if ($curRes->opendate($part) < $now) {
  313: 			$totalPossible += $weight;
  314: 		    }
  315: 		    $totalParts += $weight;
  316: 		} else {
  317: 		    my $status = $curRes->simpleStatus($part);
  318: 		    my $thisright = 0;
  319: 		    $partsCount++;
  320: 		    if ($status == $curRes->CORRECT ||
  321: 			$status == $curRes->PARTIALLY_CORRECT ) {
  322: 			$partsRight++;
  323: 			$totalRight++;
  324: 			$thisright = 1;
  325: 		    }
  326: 
  327: 		    if ($status == $curRes->ATTEMPTED) {
  328: 			$partsAttempted++;
  329: 			$totalAttempted++;
  330: 		    }
  331: 		    
  332: 		    $totalParts++;
  333: 		    if ($curRes->opendate($part) < $now) {
  334: 			$totalPossible++;
  335: 		    }
  336: 		}
  337:             }
  338: 
  339:             if ($depth == 1) { # in top-level only
  340: 		$topLevelParts += $partsCount;
  341: 		$topLevelRight += $partsRight;
  342: 		$topLevelAttempted += $partsAttempted;
  343: 	    }
  344: 
  345:             # Crawl down stack and record parts correct and total
  346:             for my $res (@{$stack}) {
  347:                 if (ref($res) && $res->is_map()) {
  348:                     if (!defined($res->{DATA}->{CHILD_PARTS})) {
  349:                         $res->{DATA}->{CHILD_PARTS} = 0;
  350:                         $res->{DATA}->{CHILD_CORRECT} = 0;
  351: 			$res->{DATA}->{CHILD_ATTEMPTED} = 0;
  352:                     }
  353:                     
  354:                     $res->{DATA}->{CHILD_PARTS} += $partsCount;
  355:                     $res->{DATA}->{CHILD_CORRECT} += $partsRight;
  356: 		    $res->{DATA}->{CHILD_ATTEMPTED} += $partsAttempted;
  357:                 }
  358:             }
  359:         }
  360:         $curRes = $iterator->next();
  361:     }
  362:     return ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,
  363:             $topLevelParts,$topLevelRight,$topLevelAttempted);
  364: }
  365: 
  366: #
  367: # Outputting everything.
  368: #
  369: 
  370: sub outputTable {
  371: 
  372:     my ($r,$showPoints,$notshowTotals,$navmap,$totalParts,$totalPossible,$totalRight,
  373:         $totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_;
  374: 
  375:     my @start = (255, 255, 192);
  376:     my @end   = (0, 192, 0);
  377: 
  378:     my $indentString = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  379: 
  380:     # Second pass: Print the maps.
  381:     $r->print(&Apache::loncommon::start_data_table()
  382:              .&Apache::loncommon::start_data_table_header_row()
  383:              .'<th>'.&mt('Folder').'</th>');
  384:     my $title = &mt($showPoints ? "Points Scored" : "Done");
  385:     if ($totalAttempted) {
  386:         $title .= " / " . &mt("Attempted");
  387:     }
  388:     $r->print("<th>$title".($notshowTotals?'':" / ".&mt('Total')).'</th>'
  389:              .&Apache::loncommon::end_data_table_header_row());
  390: #
  391: # Output of folder scores
  392: #
  393: 
  394:     my $iterator = $navmap->getIterator(undef, undef, undef, 1);
  395:     my $depth = 1;
  396:     $iterator->next(); # ignore first BEGIN_MAP
  397:     my $curRes = $iterator->next();
  398: 
  399:     while ($depth > 0) {
  400:         if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
  401:         if ($curRes == $iterator->END_MAP()) { $depth--; }
  402: 
  403:         if (ref($curRes) && $curRes->is_map()) {
  404:             my $title = $curRes->compTitle();
  405:             
  406:             my $correct = $curRes->{DATA}->{CHILD_CORRECT};
  407:             my $total = $curRes->{DATA}->{CHILD_PARTS};
  408: 	    my $attempted = $curRes->{DATA}->{CHILD_ATTEMPTED};
  409: 
  410:             if ($total > 0) {
  411:                 my $ratio;
  412:                 $ratio = $correct / $total;
  413:                 my $color = &mixColors(\@start, \@end, $ratio);
  414:                 $r->print(&Apache::loncommon::start_data_table_row()
  415:                          .'<td style="background-color:'.$color.';">');
  416:                 
  417: 		my $thisIndent = '';
  418:                 for (my $i = 1; $i < $depth; $i++) { $thisIndent .= $indentString; }
  419:                 
  420:                 $r->print("$thisIndent$title</td>");
  421: 		if ($totalAttempted) {
  422: 		    $r->print('<td valign="top">'
  423:                              .$thisIndent
  424:                              .'<span class="LC_nobreak">'
  425:                              .$correct.' / '.$attempted.($notshowTotals?'':' / '.$total)
  426:                              .'</span></td>'
  427:                              .&Apache::loncommon::end_data_table_row()
  428:                     );
  429: 		} else {
  430: 		    $r->print('<td valign="top">'
  431:                              .$thisIndent
  432:                              .'<span class="LC_nobreak">'
  433:                              .$correct.($notshowTotals?'':' / '.$total)
  434:                              .'</span></td>'
  435:                              .&Apache::loncommon::end_data_table_row());
  436: 		}
  437:             }
  438:         }
  439: 
  440:         $curRes = $iterator->next();
  441:     }
  442: 
  443:     # If there were any problems at the top level, print an extra "catchall"
  444:     if ($topLevelParts > 0) {
  445:         my $ratio = $topLevelRight / $topLevelParts;
  446:         my $color = &mixColors(\@start, \@end, $ratio);
  447:         $r->print(&Apache::loncommon::start_data_table_row()
  448:                  .'<td style="background-color:'.$color.';">');
  449:         $r->print(&mt("Problems Not Contained In A Folder")."</td><td>");
  450:         $r->print("$topLevelRight / $topLevelParts</td>"
  451:                  .&Apache::loncommon::end_data_table_row());
  452:     }
  453: 
  454: #
  455: # show totals (if applicable), close table
  456: #
  457:     if ($showPoints) {
  458: 	my $maxHelpLink = &Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct");
  459: 
  460: 	$title = $showPoints ? "Points" : "Parts Done";
  461: 	my $totaltitle = $showPoints ? &mt("Awarded Total Points") : &mt("Total Parts Done");
  462: 	$r->print(&Apache::loncommon::start_data_table_row()
  463:                  .'<td colspan="2" align="right">'.$totaltitle.': <b>'.$totalRight.'</b><br />');
  464: 	$r->print(&mt('Max Possible To Date')." $maxHelpLink: <b>$totalPossible</b><br />");
  465: 	$title = $showPoints ? "Points" : "Parts";
  466: 	$r->print(&mt("Total $title In Course").': <b>'.$totalParts.'</b></td>'
  467:                  .&Apache::loncommon::end_data_table_row());
  468:     }
  469: 
  470:     $r->print(&Apache::loncommon::end_data_table());
  471:     return;
  472: }
  473: 
  474: sub startpage {
  475:     my ($r,$showPoints) = @_;
  476:     my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display";
  477:     my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}];
  478:     $r->print(&Apache::loncommon::start_page($title,undef,
  479:                                             {'bread_crumbs' => $brcrum})
  480:              );
  481: }
  482: 
  483: sub startGradeScreen {
  484:     my ($r)=@_;
  485: 
  486:     my $showPoints =
  487:         $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard';
  488:     my $notshowSPRSlink =
  489:         (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external')
  490:       || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'));
  491:     my $notshowTotals =
  492:         $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals';
  493:     my $showSPRSlink =
  494:         $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet';
  495: 
  496:     my $allowed_to_view = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
  497:     if ((!$allowed_to_view) && ($env{'request.course.sec'} ne '')) {
  498:         $allowed_to_view = &Apache::lonnet::allowed('vgr',
  499:                                "$env{'request.course.id'}/$env{'request.course.sec'}");
  500:     }
  501: 
  502:     my $allowed_to_edit = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
  503:     if ((!$allowed_to_edit) && ($env{'request.course.sec'} ne '')) {
  504:         $allowed_to_edit = &Apache::lonnet::allowed('mgr',
  505:                                "$env{'request.course.id'}/$env{'request.course.sec'}");
  506:     }
  507: 
  508:     if ($allowed_to_view) {
  509:         my @notes;
  510:         push(@notes,&mt('Students do not see total points.')) if ($notshowTotals);
  511:         push(@notes,&mt('Students do not see link to spreadsheet.')) if ($notshowSPRSlink);
  512:         push(@notes,&mt('Students will see points based on problem weights.')) if ($showPoints);
  513:         push(@notes,&mt('Students will see link to spreadsheet.')) if ($showSPRSlink);
  514:         push(@notes,&Apache::lonhtmlcommon::coursepreflink(&mt('Grade display settings'),'grading'));
  515:         $r->print(&Apache::loncommon::head_subbox(join('&nbsp;&nbsp;',@notes)));
  516:     } elsif (!$allowed_to_edit) {
  517:         if (!$showPoints && !$notshowSPRSlink ) {
  518:             $r->print(&Apache::loncommon::head_subbox(
  519:                       &mt('This screen shows how many problems (or problem parts) you have completed'
  520:                      .', and how many you have not yet done.'
  521:                      .' You can also look at [_1]a detailed score sheet[_2].'
  522:                      ,'<a href="/adm/studentcalc">','</a>')));
  523:         }
  524:     }
  525:     return;
  526: }
  527: 
  528: sub endGradeScreen {
  529:     my ($r)=@_;
  530:     $r->print(&Apache::loncommon::end_page());
  531:     return;
  532: }
  533: 
  534: # Pass this two refs to arrays for the start and end color, and a number
  535: # from 0 to 1 for how much of the latter you want to mix in. It will
  536: # return a string ready to show ("#FFC309");
  537: sub mixColors {
  538:     my $start = shift;
  539:     my $end = shift;
  540:     my $ratio = shift;
  541:     
  542:     my ($a,$b);
  543:     my $final = "";
  544:     $a = $start->[0]; $b = $end->[0];
  545:     my $mix1 = POSIX::floor((1-$ratio)*$a + $ratio*$b);
  546:     $a = $start->[1]; $b = $end->[1];
  547:     my $mix2 = POSIX::floor((1-$ratio)*$a + $ratio*$b);
  548:     $a = $start->[2]; $b = $end->[2];
  549:     my $mix3 = POSIX::floor((1-$ratio)*$a + $ratio*$b);
  550: 
  551:     $final = sprintf "%02x%02x%02x", $mix1, $mix2, $mix3;
  552:     return "#" . $final;
  553: }
  554: 
  555: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>