--- loncom/homework/grades.pm 2003/07/15 20:59:53 1.116
+++ loncom/homework/grades.pm 2003/07/29 14:24:24 1.127
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.116 2003/07/15 20:59:53 ng Exp $
+# $Id: grades.pm,v 1.127 2003/07/29 14:24:24 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@
# June-August H.K. Ng
# Year 2003
# February, March H.K. Ng
+# July, H. K. Ng
#
package Apache::grades;
@@ -98,7 +99,8 @@ sub get_fullname {
#--- Get the partlist and the response type for a given problem. ---
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
- my ($url) = shift;
+ my ($url,$symb) = shift;
+ $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
my $allkeys = &Apache::lonnet::metadata($url,'keys');
my %seen = ();
my (@partlist,%handgrade);
@@ -106,7 +108,9 @@ sub response_type {
if (/^\w+response_\w+.*/) {
my ($responsetype,$part) = split(/_/,$_,2);
my ($partid,$respid) = split(/_/,$part);
- $handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no');
+ $responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!!
+ my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb);
+ $handgrade{$part} = $responsetype.':'.($value eq 'yes' ? 'yes' : 'no');
next if ($seen{$partid} > 0);
$seen{$partid}++;
push @partlist,$partid;
@@ -115,10 +119,105 @@ sub response_type {
return \@partlist,\%handgrade;
}
+#--- Show resource title
+#--- and parts and response type
+sub showResourceInfo {
+ my ($url,$probTitle) = @_;
+ my $result ='
'.
+ 'Current Resource: '.$probTitle.' '."\n";
+ my ($partlist,$handgrade) = &response_type($url);
+ my %resptype = ();
+ my $hdgrade='no';
+ for (sort keys(%$handgrade)) {
+ my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
+ my $partID = (split(/_/))[0];
+ $resptype{$partID} = $responsetype;
+ $hdgrade = $handgrade if ($handgrade eq 'yes');
+ $result.='Part '.$partID.' '.
+ 'Type: '.$responsetype.' ';
+# 'Handgrade: '.$handgrade.' ';
+ }
+ $result.='
'."\n";
+ return $result,\%resptype,$hdgrade,$partlist,$handgrade;
+}
+
+#--- Clean response type for display
+#--- Currently filters option response type only.
+sub cleanRecord {
+ my ($answer,$response,$symb) = @_;
+ if ($response eq 'option') {
+ my (@IDs,@ans);
+ foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
+ my ($optionID,$ans) = split(/=/);
+ push @IDs,$optionID.'';
+ push @ans,$ans;
+ }
+ my $grayFont = '';
+ return ''.
+ 'Answer '.
+ (join ' ',@ans).' '.
+ ''.$grayFont.'Option ID '.$grayFont.
+ (join ' '.$grayFont,@IDs).' '.
+ '
';
+ }
+ if ($response eq 'essay') {
+ if (! exists ($ENV{'form.'.$symb})) {
+ my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
+ $ENV{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
+ $ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
+ $ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
+ $ENV{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
+ }
+ return ''.&keywords_highlight($answer).' ';
+ }
+ return $answer;
+}
+
+#-- A couple of common js functions
+sub commonJSfunctions {
+ my $request = shift;
+ $request->print(<
+ function radioSelection(radioButton) {
+ var selection=null;
+ if (radioButton.length > 1) {
+ for (var i=0; i 1) {
+ for (var i=0; i
+COMMONJSFUNCTIONS
+}
+
#--- Dumps the class list with usernames,list of sections,
#--- section, ids and fullnames for each user.
sub getclasslist {
my ($getsec,$filterlist) = @_;
+ $getsec = $getsec eq '' ? 'all' : $getsec;
my $classlist=&Apache::loncoursedata::get_classlist();
# Bail out if we were unable to get the classlist
return if (! defined($classlist));
@@ -225,6 +324,7 @@ sub jscriptNform {
' '."\n".
' '."\n".
' '."\n".
+ ' '."\n".
' '."\n".
' '."\n".
' '."\n".
@@ -297,7 +397,7 @@ sub verifyreceipt {
my $title.='Verifying Submission Receipt '.
$receipt.' '."\n".
- 'Problem: '.$ENV{'form.probTitle'}.' '."\n";
+ 'Resource: '.$ENV{'form.probTitle'}.' '."\n";
my ($string,$contents,$matches) = ('','',0);
my (undef,undef,$fullname) = &getclasslist('all','0');
@@ -345,26 +445,15 @@ sub listStudents {
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};
- my $result;
- my ($partlist,$handgrade) = &response_type($url);
- for (sort keys(%$handgrade)) {
- my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
- $ENV{'form.handgrade'} = 'yes' if ($handgrade eq 'yes');
- $result.='Part '.(split(/_/))[0].' '.
- 'Type: '.$responsetype.' '.
- 'Handgrade: '.$handgrade.' ';
- }
- $result.=''."\n";
-
- my $viewgrade = $ENV{'form.handgrade'} eq 'yes' ? 'View/Grade' : 'View';
+ my $viewgrade = $ENV{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View';
$ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ?
&Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'};
- $result=' '.
- $viewgrade.
- ' Submissions for a Student or a Group of Students '.
- ''.
- 'Problem: '.$ENV{'form.probTitle'}.' '.$result;
+ my $result=' '.$viewgrade.
+ ' Submissions for a Student or a Group of Students ';
+
+ my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ $result.=$table;
$request->print(<
@@ -385,7 +474,7 @@ sub listStudents {
sense = "the student";
}
if (ctr == 0) {
- alert("Please select "+sense+" before clicking on the $viewgrade button.");
+ alert("Please select "+sense+" before clicking on the Next button.");
return false;
}
document.gradesub.submit();
@@ -396,34 +485,21 @@ sub listStudents {
formname.command.value = 'submission';
formname.submit();
}
-
- function pullDownSelection(selectOne) {
- var selection="";
- if (selectOne.length > 1) {
- for (var i=0; i
LISTJAVASCRIPT
+ &commonJSfunctions($request);
$request->print($result);
- my $checkhdgrade = $ENV{'form.handgrade'} eq 'yes' ? 'checked' : '';
- my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
-
+ my $checkhdgrade = ($ENV{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked' : '';
+ my $checklastsub = $checkhdgrade eq '' ? 'checked' : '';
my $gradeTable=''."\n";
+ 'value="Next->" />'."\n";
if ($ctr == 0) {
my $num_students=(scalar(keys(%$fullname)));
if ($num_students eq 0) {
@@ -569,9 +652,9 @@ sub sub_page_js {
$request->print(<
function updateRadio(formname,id,weight) {
- var gradeBox = eval("formname.GD_BOX"+id);
- var radioButton = eval("formname.RADVAL"+id);
- var oldpts = eval("formname.oldpts"+id+".value");
+ var gradeBox = formname["GD_BOX"+id];
+ var radioButton = formname["RADVAL"+id];
+ var oldpts = formname["oldpts"+id].value;
var pts = checkSolved(formname,id) == 'update' ? gradeBox.value : oldpts;
gradeBox.value = pts;
var resetbox = false;
@@ -593,7 +676,7 @@ sub sub_page_js {
var resp = confirm("You entered a value ("+pts+
") greater than the weight for the part. Accept?");
if (resp == false) {
- gradeBox.value = "";
+ gradeBox.value = oldpts;
return;
}
}
@@ -605,18 +688,17 @@ sub sub_page_js {
}
}
updateSelect(formname,id);
- var stores = eval("formname.stores"+id);
- stores.value = "0";
+ formname["stores"+id].value = "0";
}
function writeBox(formname,id,pts) {
- var gradeBox = eval("formname.GD_BOX"+id);
+ var gradeBox = formname["GD_BOX"+id];
if (checkSolved(formname,id) == 'update') {
gradeBox.value = pts;
} else {
- var oldpts = eval("formname.oldpts"+id+".value");
+ var oldpts = formname["oldpts"+id].value;
gradeBox.value = oldpts;
- var radioButton = eval("formname.RADVAL"+id);
+ var radioButton = formname["RADVAL"+id];
for (var i=0; idir_config('lonIconsURL');
+ &commonJSfunctions($request);
$request->print(<
//===================== Show list of keywords ====================
- function keywords(keyform) {
- var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value);
+ function keywords(formname) {
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value);
if (nret==null) return;
- keyform.value = nret;
+ formname.keywords.value = nret;
- document.SCORE.refresh.value = "on";
- if (document.SCORE.keywords.value != "") {
- document.SCORE.submit();
+ formname.refresh.value = "on";
+ if (formname.keywords.value != "") {
+ formname.submit();
}
return;
}
@@ -775,10 +862,9 @@ sub sub_page_kw_js {
}
var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt);
if (nret==null) return;
- var curlist = document.SCORE.keywords.value;
- document.SCORE.keywords.value = curlist+" "+nret;
- document.SCORE.refresh.value = "on";
+ document.SCORE.keywords.value = document.SCORE.keywords.value+" "+nret;
if (document.SCORE.keywords.value != "") {
+ document.SCORE.refresh.value = "on";
document.SCORE.submit();
}
return;
@@ -795,21 +881,23 @@ sub sub_page_kw_js {
var Nmsg = msgform.savemsgN.value;
savedMsgHeader(Nmsg,usrctr,fullname);
var subject = msgform.msgsub.value;
- var rtrchk = eval("document.SCORE.includemsg"+usrctr);
- var msgchk = rtrchk.value;
+ var msgchk = document.SCORE["includemsg"+usrctr].value;
re = /msgsub/;
var shwsel = "";
if (re.test(msgchk)) { shwsel = "checked" }
- displaySubject(subject,shwsel);
+ subject = (document.SCORE.shownSub.value == 0 ? checkEntities(subject) : subject);
+ displaySubject(checkEntities(subject),shwsel);
for (var i=1; i<=Nmsg; i++) {
- var testpt = "savemsg"+i+",";
- re = /testpt/;
+ var testmsg = "savemsg"+i+",";
+ re = new RegExp(testmsg,"g");
shwsel = "";
if (re.test(msgchk)) { shwsel = "checked" }
- var message = eval("document.SCORE.savemsg"+i+".value");
- displaySavedMsg(i,message,shwsel);
+ var message = document.SCORE["savemsg"+i].value;
+ message = (document.SCORE["shownOnce"+i].value == 0 ? checkEntities(message) : message);
+ displaySavedMsg(i,message,shwsel); //I do not get it. w/o checkEntities on saved messages,
+ //any < is already converted to <, etc. However, only once!!
}
- newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
+ newmsg = document.SCORE["newmsg"+usrctr].value;
shwsel = "";
re = /newmsg/;
if (re.test(msgchk)) { shwsel = "checked" }
@@ -818,7 +906,22 @@ sub sub_page_kw_js {
return;
}
-// var pWin = null;
+ function checkEntities(strx) {
+ if (strx.length == 0) return strx;
+ var orgStr = ["&", "<", ">", '"'];
+ var newStr = ["&", "<", ">", """];
+ var counter = 0;
+ while (counter < 4) {
+ strx = strReplace(strx,orgStr[counter],newStr[counter]);
+ counter++;
+ }
+ return strx;
+ }
+
+ function strReplace(strx, orgStr, newStr) {
+ return strx.split(orgStr).join(newStr);
+ }
+
function savedMsgHeader(Nmsg,usrctr,fullname) {
var height = 70*Nmsg+250;
var scrollbar = "no";
@@ -827,7 +930,12 @@ sub sub_page_kw_js {
scrollbar = "yes";
}
// if (window.pWin) {window.pWin.close(); window.pWin=null}
- pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx=70,screeny=75,width=600,height='+height);
+ var xpos = (screen.width-600)/2;
+ xpos = (xpos < 0) ? '0' : xpos;
+ var ypos = (screen.height-height)/2-30;
+ ypos = (ypos < 0) ? '0' : ypos;
+
+ pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height);
pWin.focus();
pDoc = pWin.document;
pDoc.write("");
@@ -835,11 +943,11 @@ sub sub_page_kw_js {
pDoc.write("
ENDPICK
-return '';
+ $request->print(&show_grading_menu_form($symb,$url));
+ return '';
}
@@ -2400,9 +2542,11 @@ sub upcsvScores_form {
CSVFORMJS
$ENV{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
+ my ($table) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ $result.=$table;
$result.=''."\n";
$result.=''."\n";
- $result.=' Specify a file containing the class scores for problem - '.$ENV{'form.probTitle'}.
+ $result.=' Specify a file containing the class scores for current resource'.
'. '."\n";
$result.=''."\n";
my $upfile_select=&Apache::loncommon::upfile_select_html();
@@ -2421,7 +2565,6 @@ ENDUPFORM
$result.='
'."\n";
$result.='
'."\n";
$result.=&show_grading_menu_form($symb,$url);
-
return $result;
}
@@ -2535,7 +2678,7 @@ sub csvuploadassign {
#
#-------------------------------------------------------------------
#
-#-------------- Next few routines handles grading by page/sequence
+#-------------- Next few routines handle grading by page/sequence
#
#--- Select a page/sequence and a student to grade
sub pickStudentPage {
@@ -2549,41 +2692,15 @@ function checkPickOne(formname) {
alert("Please select the student you wish to grade.");
return;
}
- var ptr = pullDownSelection(formname.selectpage);
- formname.page.value = eval("formname.page"+ptr+".value");
- formname.title.value = eval("formname.title"+ptr+".value");
+ ptr = pullDownSelection(formname.selectpage);
+ formname.page.value = formname["page"+ptr].value;
+ formname.title.value = formname["title"+ptr].value;
formname.submit();
}
-function radioSelection(radioButton) {
- var selection=null;
- if (radioButton.length > 1) {
- for (var i=0; i 1) {
- for (var i=0; i
LISTJAVASCRIPT
-
+ &commonJSfunctions($request);
my ($symb,$url) = &get_symb_and_url($request);
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"};
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"};
@@ -2620,45 +2737,44 @@ LISTJAVASCRIPT
$result.=' Submission Details: '.
' none'."\n".
- ' dates and submissions'."\n".
+ ' by dates and submissions'."\n".
' all details'."\n";
$result.=' '."\n".
- ' '."\n".
+ ' '."\n".
' '."\n".
' '."\n".
' '."\n".
' '." \n";
$result.=' '."\n";
+ 'onClick="javascript:checkPickOne(this.form);"value="Next->" /> '."\n";
$request->print($result);
- my $studentTable.=' Select a student you wish to grade '.
+ my $studentTable.=' Select a student you wish to grade and then click on the Next button. '.
''."\n";
- $studentTable.=' '."\n";
+ $studentTable.=' " />'."\n";
$studentTable.=&show_grading_menu_form($symb,$url);
$request->print($studentTable);
@@ -2669,51 +2785,22 @@ LISTJAVASCRIPT
sub getSymbMap {
my ($request) = @_;
my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db',
- $ENV{'request.course.fn'}.'_parms.db',1, 1);
+ $ENV{'request.course.fn'}.'_parms.db');
$navmap->init();
- # End navmap using boilerplate
-
- my $iterator = Apache::lonnavmaps::iterator->new($navmap, undef, undef, undef, undef, 1, undef, 1);
- my $depth = 1;
- my $curRes = $iterator->next();
-
my %symbx = ();
my @titles = ();
- my $minder=0;
- my $seenBeginMap = 0;
- while ($depth > 0 || !$seenBeginMap) {
- if ($curRes == $iterator->BEGIN_MAP()) {$depth++; $seenBeginMap = 1; }
- if ($curRes == $iterator->END_MAP()) { $depth--; }
-
- if (ref($curRes) && $curRes->is_map()) {
- my ($mapUrl, $id, $resUrl) = split(/___/, $curRes->symb()); # check map contains at least one problem
- my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
-
- my $mapiterator = $navmap->getIterator($map->map_start(),
- $map->map_finish());
-
- my $mapdepth = 1;
- my $countProblems = 0;
- $mapiterator->next(); # skip the first BEGIN_MAP
- my $mapcurRes = $mapiterator->next(); # for "current resource"
- while ($mapdepth > 0) {
- if($mapcurRes == $mapiterator->BEGIN_MAP) { $mapdepth++; }
- if($mapcurRes == $mapiterator->END_MAP) { $mapdepth--; }
-
- if (ref($mapcurRes) && $mapcurRes->is_problem() && !$mapcurRes->randomout) {
- $countProblems++;
- }
- $mapcurRes = $mapiterator->next();
- }
- if ($countProblems > 0) {
- my $title = $curRes->compTitle();
- push @titles,$minder.'.'.$title; # minder, just in case two titles are identical
- $symbx{$minder.'.'.$title} = $curRes->symb();
- $minder++;
- }
- }
- $curRes = $iterator->next();
+ my $minder = 0;
+
+ # Gather every sequence that has problems.
+ my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, 1);
+ for my $sequence ($navmap->getById('0.0'), @sequences) {
+ if ($navmap->hasResource($sequence, sub { shift->is_problem(); }, 0) ) {
+ my $title = $minder.'.'.$sequence->compTitle();
+ push @titles, $title; # minder in case two titles are identical
+ $symbx{$title} = $sequence->symb();
+ $minder++;
+ }
}
$navmap->untieHashes();
@@ -2755,22 +2842,24 @@ sub displayPage {
my $studentTable=''."\n";
$studentTable.=&show_grading_menu_form($symb,$url);
@@ -2874,24 +2933,45 @@ sub displayPage {
return '';
}
-sub cleanRecord {
- my ($answer,$response) = @_;
- if ($response eq 'option') {
- my (@IDs,@ans);
- foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
- my ($optionID,$ans) = split(/=/);
- push @IDs,$optionID.'';
- push @ans,$ans;
- }
- my $grayFont = '';
- return ''.
- 'Answer '.
- (join ' ',@ans).' '.
- ''.$grayFont.'Option ID '.$grayFont.
- (join ' '.$grayFont,@IDs).' '.
- '
';
+sub displaySubByDates {
+ my ($symbx,$record,$parts,$responseType,$checkIcon) = @_;
+ my $studentTable=''.
+ ''.
+ 'Date/Time '.
+ 'Submission '.
+ 'Status ';
+ my ($version);
+ my %mark;
+ $mark{'correct_by_student'} = $checkIcon;
+ return ' Nothing submitted - no attempts '
+ if (!exists($$record{'1:timestamp'}));
+ for ($version=1;$version<=$$record{'version'};$version++) {
+ my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
+ $studentTable.=''.$timestamp.' ';
+ my @versionKeys = split(/\:/,$$record{$version.':keys'});
+ my @displaySub = ();
+ foreach my $partid (@{$parts}) {
+ my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
+# next if ($$record{"$version:resource.$partid.solved"} eq '');
+ $displaySub[0].=(exists $$record{$version.':'.$matchKey[0]}) ?
+ 'Part '.$partid.' '.
+ ($$record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' :
+ 'Trial '.$$record{"$version:resource.$partid.tries"}).' '.
+ &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid},$$symbx).' ' : '';
+ $displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ?
+ 'Part '.$partid.' '.
+ lc($$record{"$version:resource.$partid.award"}).' '.
+ $mark{$$record{"$version:resource.$partid.solved"}}.' ' : '';
+ $displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ?
+ $$record{"$version:resource.$partid.regrader"}.' (Part: '.$partid.')' : '';
+ }
+ $displaySub[2].=(exists $$record{"$version:resource.regrader"}) ?
+ $$record{"$version:resource.regrader"} : ''; # needed because old essay regrader has not parts info
+ $studentTable.=''.$displaySub[0].' '.$displaySub[1].
+ ($displaySub[2] eq '' ? '' : 'Manually graded by '.$displaySub[2]).' ';
}
- return $answer;
+ $studentTable.='
';
+ return $studentTable;
}
sub updateGradeByPage {
@@ -2910,7 +2990,7 @@ sub updateGradeByPage {
return;
}
my $result=' '.$ENV{'form.title'}.' ';
- $result.=' Student: '.$$fullname{$ENV{'form.student'}}.
+ $result.=' Student: '.$ENV{'form.fullname'}.
' ('.$uname.($udom eq $cdom ? '':':'.$udom).') '."\n";
$request->print($result);
@@ -2925,7 +3005,7 @@ sub updateGradeByPage {
my $studentTable=' '.
''.
- ' No '.
+ ' Prob. '.
' Title '.
' Previous Score '.
' New Score ';
@@ -2957,31 +3037,39 @@ sub updateGradeByPage {
my $score;
if ($partial > 0) {
$score = 'correct_by_override';
- } elsif ($partial == 0) {
+ } elsif ($newpts ne '') { #empty is taken as 0
$score = 'incorrect_by_override';
}
- if ($ENV{'form.GD_SEL'.$question.'_'.$partid} eq 'excused') {
+ my $dropMenu = $ENV{'form.GD_SEL'.$question.'_'.$partid};
+ if ($dropMenu eq 'excused') {
$partial = '';
$score = 'excused';
+ } elsif ($dropMenu eq 'reset status'
+ && $ENV{'form.solved'.$question.'_'.$partid} ne '') { #update only if previous record exists
+ $newrecord{'resource.'.$partid.'.tries'} = 0;
+ $newrecord{'resource.'.$partid.'.solved'} = '';
+ $newrecord{'resource.'.$partid.'.award'} = '';
+ $newrecord{'resource.'.$partid.'.awarded'} = 0;
+ $newrecord{'resource.'.$partid.'.regrader'} = "$ENV{'user.name'}:$ENV{'user.domain'}";
+ $changeflag++;
+ $newpts = '';
}
+
my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid};
$displayPts[0].=' Part '.$partid.' = '.
(($oldstatus eq 'excused') ? 'excused' : $oldpts).
' ';
$displayPts[1].=' Part '.$partid.' = '.
- ($oldstatus eq 'correct_by_student' ? $oldpts :
- (($score eq 'excused') ? 'excused' : $newpts)).
+ (($score eq 'excused') ? 'excused' : $newpts).
' ';
$question++;
- if (($oldstatus eq 'correct_by_student') ||
- ($newpts eq $oldpts && $score eq $oldstatus))
- {
- next;
- }
+ next if ($dropMenu eq 'reset status' || ($newpts == $oldpts && $score ne 'excused'));
+
$newrecord{'resource.'.$partid.'.awarded'} = $partial if $partial ne '';
- $newrecord{'resource.'.$partid.'.solved'} = $score;
- $newrecord{'resource.'.$partid.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ $newrecord{'resource.'.$partid.'.solved'} = $score if $score ne '';
+ $newrecord{'resource.'.$partid.'.regrader'} = "$ENV{'user.name'}:$ENV{'user.domain'}"
+ if (scalar(keys(%newrecord)) > 0);
$changeflag++;
}
@@ -2989,6 +3077,7 @@ sub updateGradeByPage {
&Apache::lonnet::cstore(\%newrecord,$symbx,$ENV{'request.course.id'},
$udom,$uname);
}
+
$studentTable.=''.$displayPts[0].' '.
''.$displayPts[1].' '.
'';
@@ -3330,7 +3419,7 @@ SCANTRONFORM
#--- Show a Grading Menu button - Calls the next routine ---
sub show_grading_menu_form {
my ($symb,$url)=@_;
- my $result.='