File:  [LON-CAPA] / loncom / interface / lonquickgrades.pm
Revision 1.49.6.8: download - view: text, annotated - select for diffs
Tue Dec 14 02:44:05 2021 UTC (2 years, 5 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4
Diff to branchpoint 1.49: preferred, unified
- For 2.11
  Backport 1.117, 1.122

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

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