--- loncom/interface/lonquickgrades.pm 2011/03/26 16:09:33 1.80 +++ loncom/interface/lonquickgrades.pm 2011/05/04 01:49:08 1.85 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.80 2011/03/26 16:09:33 www Exp $ +# $Id: lonquickgrades.pm,v 1.85 2011/05/04 01:49:08 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,7 +62,8 @@ sub real_handler { $r->send_http_header; my $showPoints = - $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard'; + (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard') + || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories')); my $notshowSPRSlink = (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external') || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals')); @@ -266,8 +267,12 @@ sub getData { $totalRight += $score; $partsCount += $curRes->weight($part); + $curRes->{DATA}->{PROB_SCORE} += $score; + $curRes->{DATA}->{PROB_WEIGHT} += $curRes->weight($part); + if ($curRes->opendate($part) < $now) { $totalPossible += $curRes->weight($part); + $curRes->{DATA}->{PROB_POSSIBLE} += $curRes->weight($part); } $totalParts += $curRes->weight($part); } else { @@ -459,11 +464,49 @@ sub outputCategories { &output_category_table($r,$cangrade,$navmap,%categories); # if ($cangrade) { - $r->print('<input type="hidden" name="storemove" value="" />'. + $r->print(&Apache::loncommon::resourcebrowser_javascript(). + '<input type="hidden" name="storemove" value="" />'. '<input type="hidden" name="cmd" value="" />'. '<input type="submit" name="storechanges" value="'.&mt("Save changes to grading categories").'" />'. '<script>function storecmd (cmd) { document.quickform.cmd.value=cmd; document.quickform.submit(); }</script>'); } +# +# Debug +# +# my %data=&dumpdata($navmap); +# foreach (keys(%data)) { +# $r->print("\n<br />".$_.'='.$data{$_}); +# } +} + +# +# Get data for all symbs +# + +sub dumpdata { + my ($navmap)=@_; + my %returndata=(); + +# Run through the map and get all data + + 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--; } + if (ref($curRes)) { + if ($curRes->is_map()) { + $returndata{$curRes->symb()}='folder:'.$curRes->{DATA}->{CHILD_PARTS}.':'.$curRes->{DATA}->{CHILD_ATTEMPTED}.':'.$curRes->{DATA}->{CHILD_CORRECT}; + } else { + $returndata{$curRes->symb()}='res:'.$curRes->{DATA}->{PROB_WEIGHT}.':'.$curRes->{DATA}->{PROB_POSSIBLE}.':'.$curRes->{DATA}->{PROB_SCORE}; + } + } + $curRes = $iterator->next(); + } + return %returndata; } # @@ -479,6 +522,7 @@ sub process_category_edits { %categories=&set_category_name($cangrade,$id,$env{'form.name_'.$id},%categories); %categories=&set_category_total($cangrade,$id,$env{'form.totaltype_'.$id},$env{'form.total_'.$id},%categories); %categories=&set_category_weight($cangrade,$id,$env{'form.weight_'.$id},%categories); + %categories=&set_category_displayachieved($cangrade,$id,$env{'form.displayachieved_'.$id},%categories); # Set values for category rules (before names may change) %categories=&set_category_rules($cangrade,$id,%categories); } @@ -545,9 +589,10 @@ sub output_category_table_header { } $r->print('<th>'.&mt('Category').'</th>'. '<th>'.&mt('Contents').'</th>'. - '<th>'.&mt('Calculation').'</th>'. '<th>'.&mt('Total Points').'</th>'. - '<th>'.&mt('Relative Weight').'</th>'); + '<th>'.&mt('Calculation').'</th>'. + '<th>'.&mt('Relative Weight').'</th>'. + '<th>'.&mt('Achieved').'</th>'); $r->print(&Apache::loncommon::end_data_table_header_row()); } @@ -608,10 +653,25 @@ ENDMOVE } $r->print('</ul>'); if ($cangrade) { - $r->print('<br />'.&mt('Add Problem or Sequence').'<br />'. - &Apache::lonstathelpers::problem_selector('.',undef,1,1,'addcont_'.$id.'_',1,'this.form.cmd.value="addcont_'.$id.'";this.form.submit();')); + $r->print('<br />'.&Apache::loncommon::selectresource_link('quickform','addcont_'.$id,&mt('Add Problem or Folder')).'<br />'. + '<input type="hidden" name="addcont_'.$id.'_res" onChange='."'".'this.form.cmd.value="addcont_'.$id.'";this.form.submit();'."' />"); } $r->print('</td>'); + +# Total + if ($cangrade) { + $r->print('<td>'. + '<select name="totaltype_'.$id.'">'. + '<option value="default"'.($categories{$id.'_totaltype'} eq 'default'?' selected="selected"':'').'>'.&mt('default').'</option>'. + '<option value="typein"'.($categories{$id.'_totaltype'} eq 'typein'?' selected="selected"':'').'>'.&mt('Type-in value').'</option>'. + '</select>'. + '<input type="text" size="4" name="total_'.$id. + '" value="'.&Apache::lonhtmlcommon::entity_encode($categories{$id.'_total'}).'" /></td>'); + } else { + $r->print('<td>'.($categories{$id.'_totaltype'} eq 'default'?&mt('default'):$categories{$id.'_total'}).'</td>'); + } + + # Calculation $r->print('<td><ul>'); foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) { @@ -629,19 +689,6 @@ ENDMOVE } $r->print('</td>'); - -# Total - if ($cangrade) { - $r->print('<td>'. - '<select name="totaltype_'.$id.'">'. - '<option value="default"'.($categories{$id.'_totaltype'} eq 'default'?' selected="selected"':'').'>'.&mt('default').'</option>'. - '<option value="typein"'.($categories{$id.'_totaltype'} eq 'typein'?' selected="selected"':'').'>'.&mt('Type-in value').'</option>'. - '</select>'. - '<input type="text" size="4" name="total_'.$id. - '" value="'.&Apache::lonhtmlcommon::entity_encode($categories{$id.'_total'}).'" /></td>'); - } else { - $r->print('<td>'.($categories{$id.'_totaltype'} eq 'default'?&mt('default'):$categories{$id.'_total'}).'</td>'); - } # Weight if ($cangrade) { $r->print('<td>'. @@ -650,6 +697,21 @@ ENDMOVE } else { $r->print('<td>'.$categories{$id.'_weight'}.'</td>'); } +# Achieved + $r->print('<td>'); + if ($cangrade) { + $r->print('<select name="displayachieved_'.$id.'">'. + '<option value="percent"'.($categories{$id.'_displayachieved'} eq 'percent'?' selected="selected"':'').'>'.&mt('percent').'</option>'. + '<option value="points"'.($categories{$id.'_displayachieved'} eq 'points'?' selected="selected"':'').'>'.&mt('points').'</option>'. + '</select>'); + } else { + if ($categories{$id.'_displayachieved'} eq 'percent') { + $r->print(&mt('percent')); + } else { + $r->print(&mt('points')); + } + } + $r->print('</td>'); return ($value,$weight); } @@ -664,7 +726,7 @@ sub bottom_line_category { if ($cangrade) { $r->print('<td colspan="3"><a href="javascript:storecmd(\'createnewcat\');">'.&mt('Create New Category').'</a></td>'); } - $r->print('<td colspan="5">'.&mt('Current:').$sum.'<br />'.&mt('Total:').$total.'<br /></td>'); + $r->print('<td colspan="6">'.&mt('Current:').$sum.'<br />'.&mt('Total:').$total.'<br /></td>'); } # @@ -688,6 +750,7 @@ sub make_new_category { } $categories{$id.'_weight'}=0; $categories{$id.'_totaltype'}='default'; + $categories{$id.'_displayachieved'}='percent'; return %categories; } @@ -933,6 +996,15 @@ sub set_category_weight { return %categories; } +sub set_category_displayachieved { + my ($cangrade,$id,$value,%categories)=@_; + unless ($cangrade) { return %categories; } + unless (($value eq 'percent') || ($value eq 'points')) { $value='percent'; } + $categories{$id.'_displayachieved'}=$value; + return %categories; +} + + # # === end category-related #