File:  [LON-CAPA] / loncom / interface / lonquickgrades.pm
Revision 1.49.6.8.2.3: download - view: text, annotated - select for diffs
Thu Sep 7 23:53:42 2023 UTC (8 months, 1 week ago) by raeburn
Branches: version_2_11_4_msu
Diff to branchpoint 1.49.6.8: preferred, unified
- For 2.11.4 (modified)
  Include changes in 1.112

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

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