'.
- ''.
- ' Select Fullname '.
- ' Username Domain ';
- foreach (sort(@$partlist)) {
- $gradeTable.=' Part '.(split(/_/))[0].' Status ';
+ '';
+ my $loop = 0;
+ while ($loop < 2) {
+ $gradeTable.=' No. Select '.
+ ''.&nameUserString('header').' ';
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (sort(@$partlist)) {
+ $gradeTable.=' Part '.(split(/_/))[0].' Status ';
+ }
+ }
+ $loop++;
+# $gradeTable.=' ' if ($loop%2 ==1);
}
$gradeTable.=' '."\n";
my $ctr = 0;
foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
my ($uname,$udom) = split(/:/,$student);
- my (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
- my $statusflg = '';
- foreach (keys(%status)) {
- $statusflg = 1 if ($status{$_} ne 'nothing');
- my ($foo,$partid,$foo1) = split(/\./,$_);
- if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
- $statusflg = '';
- $gradeTable.=' ';
+ my %status = ();
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
+ my $submitted = 0;
+ my $graded = 1;
+ foreach (keys(%status)) {
+ $submitted = 1 if ($status{$_} ne 'nothing');
+ $graded = 0 if ($status{$_} =~ /^correct/);
+ my ($foo,$partid,$foo1) = split(/\./,$_);
+ if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
+ $submitted = 0;
+ $gradeTable.=' ';
+ }
}
+ next if (!$submitted && ($submitonly eq 'yes' || $submitonly eq 'graded'));
+ next if (!$graded && $submitonly eq 'graded');
}
- next if ($statusflg eq '' && $submitonly eq 'yes');
$ctr++;
- if ( $Apache::grades::viewgrades eq 'F' ) {
- $gradeTable.=''.
+ if ( $perm{'vgr'} eq 'F' ) {
+ $gradeTable.=' ' if ($ctr%2 ==1);
+ $gradeTable.=''.$ctr.' '.
' '."\n".
- ' '.$$fullname{$student}.' '."\n".
- ' '.$uname.' '."\n".
- ' '.$udom.' '."\n";
-
- foreach (sort keys(%status)) {
- next if (/^resource.*?submitted_by$/);
- $gradeTable.=' '.$status{$_}.' '."\n";
+ $student.':'.$$fullname{$student}.' ">'."\n".
+ ''.&nameUserString(undef,$$fullname{$student},$uname,$udom).' '."\n";
+
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (sort keys(%status)) {
+ next if (/^resource.*?submitted_by$/);
+ $gradeTable.=' '.$status{$_}.' '."\n";
+ }
}
- $gradeTable.=' '."\n";
+# $gradeTable.=' ' if ($ctr%2 ==1);
+ $gradeTable.=''."\n" if ($ctr%2 ==0);
}
}
+ if ($ctr%2 ==1) {
+ $gradeTable.=' ';
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (@$partlist) {
+ $gradeTable.=' ';
+ }
+ }
+ $gradeTable.='';
+ }
+
$gradeTable.='
'.
' '."\n";
+ 'value="Next->" />'."\n";
if ($ctr == 0) {
- $gradeTable=' '.
- 'No submission found for this resource. ';
+ my $num_students=(scalar(keys(%$fullname)));
+ if ($num_students eq 0) {
+ $gradeTable=' There are no students currently enrolled. ';
+ } else {
+ $gradeTable=' '.
+ 'No submissions found for this resource for any students. ('.$num_students.
+ ' checked for submissions) ';
+ }
} elsif ($ctr == 1) {
$gradeTable =~ s/type=checkbox/type=checkbox checked/;
}
@@ -453,102 +689,194 @@ sub sub_page_js {
my $request = shift;
$request->print(<
- function updateRadio(radioButton,formtextbox,formsel,scores,weight) {
- var pts = formtextbox.value;
- var resetbox =false;
- if (isNaN(pts) || pts < 0) {
- alert("A number equal or greater than 0 is expected. Entered value = "+pts);
- for (var i=0; i weight) {
+ var resp = confirm("You entered a value ("+pts+
+ ") greater than the weight for the part. Accept?");
+ if (resp == false) {
+ gradeBox.value = oldpts;
+ return;
+ }
}
- return;
- }
- if (pts > weight) {
- var resp = confirm("You entered a value ("+pts+
- ") greater than the weight for the part. Accept?");
- if (resp == false) {
- formtextbox.value = "";
- return;
- }
+ for (var i=0; i
+SUBJAVASCRIPT
+}
-//=================== Check that a point is assigned for all the parts ==============
- function checksubmit(val,total,parttot) {
- document.SCORE.gradeOpt.value = val;
- if (val == "Save & Next") {
- for (i=0;i<=total;i++) {
- for (j=0;jdir_config('lonIconsURL');
+ &commonJSfunctions($request);
+ $request->print(<
//===================== Show list of keywords ====================
- function keywords(keyform) {
- var keywds = keyform.value;
- var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds);
+ 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();
+ if (formname.keywords.value != "") {
+ formname.refresh.value = "on";
+ formname.submit();
}
return;
}
@@ -574,35 +902,42 @@ sub sub_page_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;
}
//====================== Script for composing message ==============
+ // preload images
+ img1 = new Image();
+ img1.src = "$iconpath/mailbkgrd.gif";
+ img2 = new Image();
+ img2.src = "$iconpath/mailto.gif";
+
function msgCenter(msgform,usrctr,fullname) {
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" }
@@ -611,91 +946,125 @@ sub sub_page_js {
return;
}
+ 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 = 30*Nmsg+250;
+ var height = 70*Nmsg+250;
var scrollbar = "no";
if (height > 600) {
height = 600;
scrollbar = "yes";
}
-/* if (window.pWin)
- window.pWin.close(); */
- pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx=70,screeny=75,width=600,height='+height);
- pWin.document.write("");
- pWin.document.write("Message Central ");
-
- pWin.document.write("
SUBJAVASCRIPT
}
+#--- displays the grading box, used in essay type problem and grading by page/sequence
+sub gradeBox {
+ my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
+
+ my $checkIcon = ' ';
+
+ my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
+ my $wgtmsg = ($wgt > 0 ? '(problem weight)' :
+ 'problem weight assigned by computer ');
+ $wgt = ($wgt > 0 ? $wgt : '1');
+ my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
+ '' : $$record{'resource.'.$partid.'.awarded'}*$wgt);
+ my $result=' '."\n";
+
+ $result.=''."\n";
+ return $result;
+}
sub show_problem {
- my ($request,$symb,$uname,$udom,$removeform) = @_;
- my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
- $ENV{'request.course.id'});
+ my ($request,$symb,$uname,$udom,$removeform,$viewon,$mode) = @_;
+ my $rendered;
+ if ($mode eq 'both' or $mode eq 'text') {
+ $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ }
if ($removeform) {
$rendered=~s|||g;
$rendered=~s|name="submit"|name="would_have_been_submit"|g;
}
- my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
- $ENV{'request.course.id'});
+ my $companswer;
+ if ($mode eq 'both' or $mode eq 'answer') {
+ $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ }
if ($removeform) {
$companswer=~s|||g;
- $rendered=~s|name="submit"|name="would_have_been_submit"|g;
+ $companswer=~s|name="submit"|name="would_have_been_submit"|g;
}
my $result.='';
- $result.='';
- $result.=' View of the problem - '.$ENV{'form.fullname'}.
- ' '.$rendered.' ';
- $result.='Correct answer: '.$companswer;
+ $result.='';
+ if ($viewon) {
+ $result.=' ';
+ if ($mode eq 'both' or $mode eq 'text') {
+ $result.='View of the problem - ';
+ } else {
+ $result.='Correct answer: ';
+ }
+ $result.=$ENV{'form.fullname'}.' ';
+ }
+ if ($mode eq 'both') {
+ $result.=''.$rendered.' ';
+ $result.='Correct answer: '.$companswer;
+ } elsif ($mode eq 'text') {
+ $result.=' '.$rendered;
+ } elsif ($mode eq 'answer') {
+ $result.=' '.$companswer;
+ }
$result.='
';
$result.='
';
- $request->print($result);
+ return $result;
}
# --------------------------- show submissions of a student, option to grade
@@ -827,33 +1273,60 @@ sub submission {
my ($request,$counter,$total) = @_;
(my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
-# if ($ENV{'form.student'} eq '') { &moreinfo($request,'Need student login id'); return ''; }
my ($uname,$udom) = ($ENV{'form.student'},$ENV{'form.userdom'});
- ($uname,$udom) = &finduser($uname) if $udom eq '';
+ $udom = ($udom eq '' ? $ENV{'user.domain'} : $udom); #has form.userdom changed for a student?
+ my $usec = &Apache::lonnet::getsection($udom,$uname,$ENV{'request.course.id'});
$ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq '';
-# if ($uname eq '') { &moreinfo($request,'Unable to find student'); return ''; }
my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
+
+ if (!&canview($usec)) {
+ $request->print('Unable to view requested student.('.
+ $uname.$udom.$usec.$ENV{'request.course.id'}.') ');
+ $request->print(&show_grading_menu_form($symb,$url));
+ return;
+ }
+
+ $ENV{'form.lastSub'} = ($ENV{'form.lastSub'} eq '' ? 'datesub' : $ENV{'form.lastSub'});
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
-# $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';
+ my $checkIcon = ' ';
# header info
if ($counter == 0) {
&sub_page_js($request);
+ &sub_page_kw_js($request) if ($ENV{'form.handgrade'} eq 'yes');
+ $ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ?
+ &Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'};
+
$request->print(' Submission Record '."\n".
- ' Resource: '.$url.' '."\n");
+ ' Resource: '.$ENV{'form.probTitle'}.' '."\n");
+
+ if ($ENV{'form.handgrade'} eq 'no') {
+ my $checkMark=' Note: Part(s) graded correct by the computer is marked with a '.
+ $checkIcon.' symbol.'."\n";
+ $request->print($checkMark);
+ }
# option to display problem, only once else it cause problems
# with the form later since the problem has a form.
- if ($ENV{'form.vProb'} eq 'yes') {
- &show_problem($request,$symb,$uname,$udom,0);
+ if ($ENV{'form.vProb'} eq 'yes' or $ENV{'form.vAns'} eq 'yes') {
+ my $mode;
+ if ($ENV{'form.vProb'} eq 'yes' && $ENV{'form.vAns'} eq 'yes') {
+ $mode='both';
+ } elsif ($ENV{'form.vProb'} eq 'yes') {
+ $mode='text';
+ } elsif ($ENV{'form.vAns'} eq 'yes') {
+ $mode='answer';
+ }
+ $request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode));
}
# kwclr is the only variable that is guaranteed to be non blank
# if this subroutine has been called once.
my %keyhash = ();
- if ($ENV{'form.kwclr'} eq '') {
+ if ($ENV{'form.kwclr'} eq '' && $ENV{'form.handgrade'} eq 'yes') {
%keyhash = &Apache::lonnet::dump('nohist_handgrade',
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
@@ -864,76 +1337,105 @@ sub submission {
$ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
$ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
$ENV{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
- $keyhash{$symb.'_subject'} : &Apache::lonnet::metadata($url,'title');
+ $keyhash{$symb.'_subject'} : $ENV{'form.probTitle'};
$ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
-
}
+ my $overRideScore = $ENV{'form.overRideScore'} eq '' ? 'no' : $ENV{'form.overRideScore'};
$request->print('
'."\n";
+ $toGrade.=&show_grading_menu_form($symb,$url)
+ if (($ENV{'form.command'} eq 'submission') ||
+ ($ENV{'form.command'} eq 'processGroup' && $counter == $total));
+ $request = print($toGrade);
return;
}
- # Grading options
- $result=' '."\n".
- ' '."\n".
- ' '."\n";
- my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
- my $msgfor = $givenn.' '.$lastname;
- if (scalar(@col_fullnames) > 0) {
- my $lastone = pop @col_fullnames;
- $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
- }
- $result.=''."\n".
- ' '.
- 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').' '.
- ' (Message will be sent when you click on Save & Next below.)'."\n"
- if ($ENV{'form.handgrade'} eq 'yes');
- $request->print($result);
+ # essay grading message center
+ if ($ENV{'form.handgrade'} eq 'yes') {
+ my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
+ my $msgfor = $givenn.' '.$lastname;
+ if (scalar(@col_fullnames) > 0) {
+ my $lastone = pop @col_fullnames;
+ $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
+ }
+ $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
+ $result=' '."\n".
+ ' '."\n";
+ $result.=' '.
+ 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').' '.
+ ' '."\n".
+ ' (Message will be sent when you click on Save & Next below.)'."\n"
+ if ($ENV{'form.handgrade'} eq 'yes');
+ $request->print($result);
+ }
my %seen = ();
my @partlist;
+ my @gradePartRespid;
for (sort keys(%$handgrade)) {
my ($partid,$respid) = split(/_/);
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$_} =~ /:no$/);
+ next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/);
push @partlist,$partid;
- my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
- my $wgtmsg = ($wgt > 0 ? '(problem weight)' :
- 'problem weight assigned by computer ');
- $wgt = ($wgt > 0 ? $wgt : '1');
- my $score = ($record{'resource.'.$partid.'.awarded'} eq '' ?
- '' : $record{'resource.'.$partid.'.awarded'}*$wgt);
- $result=' ';
- $result.=''."\n";
- $request->print($result);
+ $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
}
$result=' '."\n";
+ $result.=' '."\n" if ($counter == 0);
my $ctr = 0;
while ($ctr < scalar(@partlist)) {
$result.=' '.
- ' '."\n";
- if ($ENV{'form.handgrade'} eq 'yes') {
- $endform.=' '."\n";
- my $ntstu =''.
- '1 2 '.
- '3 5 '.
- '7 10 '."\n";
- my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
- $ntstu =~ s/$nsel $nsel;
- $endform.=$ntstu.'student(s) ';
- } else {
- $endform.=' '."\n";
- }
- $endform.=' '."\n".
- ' ';
- $endform.='(Next and Previous do not save the scores.)'."\n"
- if ($ENV{'form.handgrade'} eq 'yes');
+ my $endform='';
$endform.=&show_grading_menu_form($symb,$url);
$request->print($endform);
@@ -1165,17 +1663,15 @@ KEYWORDS
#--- Retrieve the last submission for all the parts
sub get_last_submission {
- my (%returnhash)=@_;
+ my ($returnhash)=@_;
my (@string,$timestamp);
- if ($returnhash{'version'}) {
+ if ($$returnhash{'version'}) {
my %lasthash=();
my ($version);
- for ($version=1;$version<=$returnhash{'version'};$version++) {
- foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
- $lasthash{$_}=$returnhash{$version.':'.$_};
-# if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
- $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
-# }
+ for ($version=1;$version<=$$returnhash{'version'};$version++) {
+ foreach (sort(split(/\:/,$$returnhash{$version.':keys'}))) {
+ $lasthash{$_}=$$returnhash{$version.':'.$_};
+ $timestamp = scalar(localtime($$returnhash{$version.':timestamp'}));
}
}
foreach ((keys %lasthash)) {
@@ -1187,7 +1683,7 @@ sub get_last_submission {
}
}
}
- @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
+ @string = $string[0] eq '' ? 'Nothing submitted - no attempts. ' : @string;
return \@string,\$timestamp;
}
@@ -1199,13 +1695,8 @@ sub keywords_highlight {
(my $styleoff = $styleon) =~ s/\\<\//;
my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
foreach (@keylist) {
- $string =~ s/\b\Q$_\E(\b|\.)/\$styleon$_$styleoff\<\/font\>/gi;
+ $string =~ s/\b\Q$_\E(\b|\.)/$styleon$_$styleoff<\/font>/gi;
}
- # This is not really the right place to do this, but I cannot find a
- # better one at this time. So here we go - the m in the s:::mg causes
- # ^ to match the beginning of a new line. So we replace(???) the beginning
- # of the line with to make things formatted a little better.
- $string =~ s:^: :mg;
return $string;
}
@@ -1217,13 +1708,20 @@ sub processHandGrade {
my $button = $ENV{'form.gradeOpt'};
my $ngrade = $ENV{'form.NCT'};
my $ntstu = $ENV{'form.NTSTU'};
-
if ($button eq 'Save & Next') {
my $ctr = 0;
while ($ctr < $ngrade) {
my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
- my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
-
+ my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
+ if ($errorflag eq 'no_score') {
+ $ctr++;
+ next;
+ }
+ if ($errorflag eq 'not_allowed') {
+ $request->print("Not allowed to modify grades for $uname:$udom ");
+ $ctr++;
+ next;
+ }
my $includemsg = $ENV{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
@@ -1232,19 +1730,28 @@ sub processHandGrade {
foreach (@msgnum) {
$message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
}
- $message =~ s/\s+/ /g;
+ $message =&Apache::lonfeedback::clear_out_html($message);
+ $message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt;
+ $message.=" for $ENV{'form.probTitle'} ";
$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,
$ENV{'form.msgsub'},$message);
}
if ($ENV{'form.collaborator'.$ctr}) {
my (@collaborators) = split(/:/,$ENV{'form.collaborator'.$ctr});
foreach (@collaborators) {
- &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
- $ENV{'form.unamedom'.$ctr});
- if ($message ne '') {
- $msgstatus = &Apache::lonmsg::user_normal_msg ($_,$udom,
- $ENV{'form.msgsub'},
- $message);
+ my ($errorflag,$pts,$wgt) =
+ &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,$ENV{'form.unamedom'.$ctr});
+ if ($errorflag eq 'not_allowed') {
+ $request->print("Not allowed to modify grades for $_:$udom ");
+ next;
+ } else {
+ if ($message ne '') {
+ $msgstatus = &Apache::lonmsg::user_normal_msg ($_,$udom,
+ $ENV{'form.msgsub'},
+ $message);
+ }
}
}
}
@@ -1252,69 +1759,87 @@ sub processHandGrade {
}
}
- # Keywords sorted in alphabatical order
- my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
- my %keyhash = ();
- $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
- $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
- my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
- $ENV{'form.keywords'} = join(' ',@keywords);
- $keyhash{$symb.'_keywords'} = $ENV{'form.keywords'};
- $keyhash{$symb.'_subject'} = $ENV{'form.msgsub'};
- $keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'};
- $keyhash{$loginuser.'_kwsize'} = $ENV{'form.kwsize'};
- $keyhash{$loginuser.'_kwstyle'} = $ENV{'form.kwstyle'};
-
- # message center - Order of message gets changed. Blank line is eliminated.
- # New messages are saved in ENV for the next student.
- # All messages are saved in nohist_handgrade.db
- my ($ctr,$idx) = (1,1);
- while ($ctr <= $ENV{'form.savemsgN'}) {
- if ($ENV{'form.savemsg'.$ctr} ne '') {
- $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
- $idx++;
+ if ($ENV{'form.handgrade'} eq 'yes') {
+ # Keywords sorted in alphabatical order
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ my %keyhash = ();
+ $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
+ $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
+ my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
+ $ENV{'form.keywords'} = join(' ',@keywords);
+ $keyhash{$symb.'_keywords'} = $ENV{'form.keywords'};
+ $keyhash{$symb.'_subject'} = $ENV{'form.msgsub'};
+ $keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'};
+ $keyhash{$loginuser.'_kwsize'} = $ENV{'form.kwsize'};
+ $keyhash{$loginuser.'_kwstyle'} = $ENV{'form.kwstyle'};
+
+ # message center - Order of message gets changed. Blank line is eliminated.
+ # New messages are saved in ENV for the next student.
+ # All messages are saved in nohist_handgrade.db
+ my ($ctr,$idx) = (1,1);
+ while ($ctr <= $ENV{'form.savemsgN'}) {
+ if ($ENV{'form.savemsg'.$ctr} ne '') {
+ $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
+ $idx++;
+ }
+ $ctr++;
}
- $ctr++;
- }
- $ctr = 0;
- while ($ctr < $ngrade) {
- if ($ENV{'form.newmsg'.$ctr} ne '') {
- $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
- $ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
- $idx++;
+ $ctr = 0;
+ while ($ctr < $ngrade) {
+ if ($ENV{'form.newmsg'.$ctr} ne '') {
+ $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
+ $ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
+ $idx++;
+ }
+ $ctr++;
}
- $ctr++;
+ $ENV{'form.savemsgN'} = --$idx;
+ $keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
+ my $putresult = &Apache::lonnet::put
+ ('nohist_handgrade',\%keyhash,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
}
- $ENV{'form.savemsgN'} = --$idx;
- $keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
- my $putresult = &Apache::lonnet::put
- ('nohist_handgrade',\%keyhash,
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
-
# Called by Save & Refresh from Highlight Attribute Window
+ my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
if ($ENV{'form.refresh'} eq 'on') {
- my $ctr = 0;
- $ENV{'form.NTSTU'}=$ngrade;
+ my ($ctr,$total) = (0,0);
while ($ctr < $ngrade) {
- ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$ENV{'form.unamedom'.$ctr});
- &submission($request,$ctr,$ngrade-1);
+ $total++ if $ENV{'form.unamedom'.$ctr} ne '';
+ $ctr++;
+ }
+ $ENV{'form.NTSTU'}=$ngrade;
+ $ctr = 0;
+ while ($ctr < $total) {
+ my $processUser = $ENV{'form.unamedom'.$ctr};
+ ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser);
+ $ENV{'form.fullname'} = $$fullname{$processUser};
+ &submission($request,$ctr,$total-1);
$ctr++;
}
return '';
}
+# Go directly to grade student - from submission or link from chart page
+ if ($button eq 'Grade Student') {
+ (undef,undef,$ENV{'form.handgrade'},undef,undef) = &showResourceInfo($url);
+ my $processUser = $ENV{'form.unamedom'.$ENV{'form.studentNo'}};
+ ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser);
+ $ENV{'form.fullname'} = $$fullname{$processUser};
+ &submission($request,0,0);
+ return '';
+ }
+
# Get the next/previous one or group of students
my $firststu = $ENV{'form.unamedom0'};
my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
- $ctr = 2;
+ my $ctr = 2;
while ($laststu eq '') {
$laststu = $ENV{'form.unamedom'.($ngrade-$ctr)};
$ctr++;
$laststu = $firststu if ($ctr > $ngrade);
}
- my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
my (@parsedlist,@nextlist);
my ($nextflg) = 0;
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
@@ -1328,21 +1853,29 @@ sub processHandGrade {
}
}
$ctr = 0;
- my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
@parsedlist = reverse @parsedlist if ($button eq 'Previous');
+ my ($partlist) = &response_type($url);
foreach my $student (@parsedlist) {
+ my $submitonly=$ENV{'form.submitonly'};
my ($uname,$udom) = split(/:/,$student);
- if ($ENV{'form.submitonly'} eq 'yes') {
- my (%status) = &student_gradeStatus($ENV{'form.url'},$symb,$udom,$uname,$partlist) ;
- my $statusflg = '';
+ if ($submitonly =~ /^(yes|graded)$/) {
+# my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+ my %status=&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
+ my $submitted = 0;
+ my $graded = 1;
foreach (keys(%status)) {
- $statusflg = 1 if ($status{$_} ne 'nothing');
- my ($foo,$partid,$foo1) = split(/\./);
- $statusflg = '' if ($status{'resource.'.$partid.'.submitted_by'} ne '');
+ $submitted = 1 if ($status{$_} ne 'nothing');
+ $graded = 0 if ($status{$_} =~ /^correct/);
+ my ($foo,$partid,$foo1) = split(/\./,$_);
+ if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
+ $submitted = 0;
+ }
}
- next if ($statusflg eq '');
+ next if (!$submitted && ($submitonly eq 'yes' || $submitonly eq 'graded'));
+ next if (!$graded && $submitonly eq 'graded');
}
push @nextlist,$student if ($ctr < $ntstu);
+ last if ($ctr == $ntstu);
$ctr++;
}
@@ -1354,8 +1887,6 @@ sub processHandGrade {
$ENV{'form.student'} = $uname;
$ENV{'form.userdom'} = $udom;
$ENV{'form.fullname'} = $$fullname{$_};
-# $ENV{'form.'.$_.':submitted_by'} = $submitter;
-# print "submitter=$ENV{'form.'.$_.':submitted_by'}= $submitter: ";
&submission($request,$ctr,$total);
$ctr++;
}
@@ -1372,23 +1903,38 @@ sub processHandGrade {
#---- Save the score and award for each student, if changed
sub saveHandGrade {
my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter) = @_;
- my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
- my %newrecord;
+ my $usec = &Apache::lonnet::getsection($domain,$stuname,
+ $ENV{'request.course.id'});
+ if (!&canmodify($usec)) { return('not_allowed'); }
+ my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
+ my %newrecord = ();
+ my ($pts,$wgt) = ('','');
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
- if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
+ my $dropMenu = $ENV{'form.GD_SEL'.$newflg.'_'.$_};
+ if ($dropMenu eq 'excused') {
if ($record{'resource.'.$_.'.solved'} ne 'excused') {
$newrecord{'resource.'.$_.'.solved'} = 'excused';
if (exists($record{'resource.'.$_.'.awarded'})) {
$newrecord{'resource.'.$_.'.awarded'} = '';
}
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
}
- } else {
- my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
- $ENV{'form.GD_BOX'.$newflg.'_'.$_} :
- $ENV{'form.RADVAL'.$newflg.'_'.$_});
- my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
+ } elsif ($dropMenu eq 'reset status'
+ && exists($record{'resource.'.$_.'.solved'})) { #don't bother if no old records -> no attempts
+ $newrecord{'resource.'.$_.'.tries'} = 0;
+ $newrecord{'resource.'.$_.'.solved'} = '';
+ $newrecord{'resource.'.$_.'.award'} = '';
+ $newrecord{'resource.'.$_.'.awarded'} = 0;
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ } elsif ($dropMenu eq '') {
+ $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
+ $ENV{'form.GD_BOX'.$newflg.'_'.$_} :
+ $ENV{'form.RADVAL'.$newflg.'_'.$_});
+ return 'no_score' if ($pts eq '' && $ENV{'form.GD_SEL'.$newflg.'_'.$_} eq '');
+ $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
$ENV{'form.WGT'.$newflg.'_'.$_};
my $partial= $pts/$wgt;
+ next if ($partial eq $record{'resource.'.$_.'.awarded'}); #do not update score for part if not changed.
$newrecord{'resource.'.$_.'.awarded'} = $partial
if ($record{'resource.'.$_.'.awarded'} ne $partial);
my $reckey = 'resource.'.$_.'.solved';
@@ -1401,15 +1947,15 @@ sub saveHandGrade {
}
$newrecord{'resource.'.$_.'.submitted_by'} = $submitter
if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
}
}
if (scalar(keys(%newrecord)) > 0) {
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
&Apache::lonnet::cstore(\%newrecord,$symb,
$ENV{'request.course.id'},$domain,$stuname);
}
- return '';
+ return '',$pts,$wgt;
}
#--------------------------------------------------------------------------------------
@@ -1423,12 +1969,12 @@ sub viewgrades_js {
$request->print(<
function writePoint(partid,weight,point) {
- var radioButton = eval("document.classgrade.RADVAL_"+partid);
- var textbox = eval("document.classgrade.TEXTVAL_"+partid);
+ var radioButton = document.classgrade["RADVAL_"+partid];
+ var textbox = document.classgrade["TEXTVAL_"+partid];
if (point == "textval") {
- var point = eval("document.classgrade.TEXTVAL_"+partid+".value");
- if (isNaN(point) || point < 0) {
- alert("A number equal or greater than 0 is expected. Entered value = "+point);
+ point = document.classgrade["TEXTVAL_"+partid].value;
+ if (isNaN(point) || parseFloat(point) < 0) {
+ alert("A number equal or greater than 0 is expected. Entered value = "+parseFloat(point));
var resetbox = false;
for (var i=0; i weight) {
- var resp = confirm("You entered a value ("+point+
+ if (parseFloat(point) > parseFloat(weight)) {
+ var resp = confirm("You entered a value ("+parseFloat(point)+
") greater than the weight for the part. Accept?");
if (resp == false) {
textbox.value = "";
@@ -1451,21 +1997,19 @@ sub viewgrades_js {
}
for (var i=0; i weight) {
- var resp = confirm("You entered a value ("+point+
+ if (parseFloat(point) > parseFloat(weight)) {
+ var resp = confirm("You entered a value ("+parseFloat(point)+
") greater than the weight of the part. Accept?");
if (resp == false) {
textbox.value = "";
@@ -1542,19 +2084,21 @@ sub viewgrades_js {
}
function changeOneScore(partid,user) {
- var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_solved");
- if (selval[1].selected) {
- var boxval = eval("document.classgrade.GD_"+user+'_'+partid+"_awarded");
- boxval.value = "";
+ var selval = document.classgrade["GD_"+user+'_'+partid+"_solved"];
+ if (selval[1].selected || selval[2].selected) {
+ document.classgrade["GD_"+user+'_'+partid+"_awarded"].value = "";
+ if (selval[2].selected) {
+ document.classgrade["GD_"+user+'_'+partid+"_tries"].value = "0";
+ }
}
}
function resetEntry(numpart) {
for (ctpart=0;ctpartManual Grading ';
- $result.='Resource: '.$ENV{'form.url'}.' '."\n";
+ $result.='Current Resource: '.$ENV{'form.probTitle'}.' '."\n";
#view individual student submission form - called using Javascript viewOneStudent
$result.=&jscriptNform($url,$symb);
@@ -1604,26 +2145,25 @@ sub viewgrades {
' '."\n".
' '."\n".
' '."\n".
- ' '."\n";
- $result.='Assign Common Grade To ';
+ ' '."\n".
+ ' '."\n".
+ ' '."\n".
+ ' '."\n";
+
+ my $sectionClass;
if ($ENV{'form.section'} eq 'all') {
- $result.='Class ';
+ $sectionClass='Class ';
} elsif ($ENV{'form.section'} eq 'no') {
- $result.='Students in no Section ';
+ $sectionClass='Students in no Section ';
} else {
- $result.='Students in Section '.$ENV{'form.section'}.'';
+ $sectionClass='Students in Section '.$ENV{'form.section'}.'';
}
+ $result.='Assign Common Grade To '.$sectionClass;
$result.= ' '."\n".
'';
-# $result.='To assign the same score for all the students use the radio buttons or '.
-# 'text box below. To assign scores individually fill in the score boxes for '.
-# 'each student in the table below. A part that has already '.
-# 'been graded does not get changed using the radio buttons or text box. '.
-# 'If needed, it has to be changed individually. ';
-# $result.=' ';
#radio buttons/text box for assigning points for a section or class.
#handles different parts of a problem
- my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
+ my ($partlist,$handgrade) = &response_type($url,$symb);
my %weight = ();
my $ctsparts = 0;
$result.='';
@@ -1659,32 +2199,25 @@ sub viewgrades {
'onChange="javascript:writeRadText(\''.$partid.'\','.
$weight{$partid}.')"> '.
' '.
- 'excused '."\n";
+ 'excused '.
+ 'reset status '."\n";
$ctsparts++;
}
$result.='
'.'
'.'
'."\n".
' ';
$result.=' ';
- $result.=' '."\n";
+ 'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self>';
#table listing all the students in a section/class
#header of table
- $result.= 'Assign Grade to Specific Students in ';
- if ($ENV{'form.section'} eq 'all') {
- $result.='the Class ';
- } elsif ($ENV{'form.section'} eq 'no') {
- $result.='no Section ';
- } else {
- $result.='Section '.$ENV{'form.section'}.'';
- }
+ $result.= 'Assign Grade to Specific Students in '.$sectionClass;
$result.= ' '."\n".
- ''.
- 'Fullname Username Domain '."\n";
- my (@parts) = sort(&getpartlist($url));
+ ' No. '.
+ ''.&nameUserString('header')." \n";
+ my (@parts) = sort(&getpartlist($url,$symb));
foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
+ $display =~ s|^Number of Attempts|Tries |; # makes the column narrower
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
if ($display =~ /^Partial Credit Factor/) {
my ($partid) = &split_part_type($part);
@@ -1699,62 +2232,68 @@ sub viewgrades {
#get info for each student
#list all the students - with points and grade status
- my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
+ my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
my $ctr = 0;
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
- my ($uname,$udom) = split(/:/);
+ my $uname = $_;
+ $uname=~s/:/_/;
$result.=' '."\n";
- $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
- $_,$$fullname{$_},\@parts,\%weight);
$ctr++;
+ $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
+ $_,$$fullname{$_},\@parts,\%weight,$ctr);
}
$result.='
';
$result.=' '."\n";
- $result.=' '."\n";
+ if (scalar(%$fullname) eq 0) {
+ my $colspan=3+scalar(@parts);
+ $result='There are no students in section "'.$ENV{'form.section'}.
+ '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade. ';
+ }
$result.=&show_grading_menu_form($symb,$url);
return $result;
}
#--- call by previous routine to display each student
sub viewstudentgrade {
- my ($url,$symb,$courseid,$student,$fullname,$parts,$weight) = @_;
+ my ($url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr) = @_;
my ($uname,$udom) = split(/:/,$student);
+ $student=~s/:/_/;
my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
- my $result=' '.
+ my $result=' '.$ctr.' '.
''.$fullname.' '.
- ' '.$uname.' '.$udom.' '."\n";
- foreach my $part (@$parts) {
- my ($part,$type) = &split_part_type($part);
+ '\')"; TARGET=_self>'.$fullname.' '.
+ '('.$uname.($ENV{'user.domain'} eq $udom ? '' : ':'.$udom).') '."\n";
+ foreach my $apart (@$parts) {
+ my ($part,$type) = &split_part_type($apart);
my $score=$record{"resource.$part.$type"};
if ($type eq 'awarded') {
my $pts = $score eq '' ? '' : $score*$$weight{$part};
$result.=' '."\n";
+ 'GD_'.$student.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n";
$result.=' '."\n";
} elsif ($type eq 'solved') {
my ($status,$foo)=split(/_/,$score,2);
$status = 'nothing' if ($status eq '');
- $result.=' '."\n";
- $result.=''."\n";
- my $optsel = ' excused '."\n";
- $optsel = ' excused '."\n"
- if ($status eq 'excused');
- $result.=$optsel;
- $result.=" \n";
+ $result.=' '."\n";
+ $result.= (($status eq 'excused') ? ' excused '
+ : ' excused ')."\n";
+ $result.='reset status ';
+ $result.=" \n";
} else {
$result.=' '.
+ 'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
"\n";
$result.=' '."\n";
}
}
@@ -1770,12 +2309,13 @@ sub editgrades {
my $symb=$ENV{'form.symb'};
my $url =$ENV{'form.url'};
my $title='Current Grade Status ';
- $title.='Resource: '.$ENV{'form.url'}.' '."\n";
+ $title.='Current Resource: '.$ENV{'form.probTitle'}.' '."\n";
$title.='Section: '.$ENV{'form.section'}.' '."\n";
- $title.= &show_grading_menu_form ($symb,$url);
+
my $result= ''."\n";
$result.= ''.
- 'Username Fullname '."\n";
+ ' No. '.
+ ''.&nameUserString('header')." \n";
my %scoreptr = (
'correct' =>'correct_by_override',
@@ -1791,7 +2331,7 @@ sub editgrades {
my %columns = ();
my ($i,$ctr,$count,$rec_update) = (0,0,0,0);
- my (@parts) = sort(&getpartlist($url));
+ my (@parts) = sort(&getpartlist($url,$symb));
my $header;
while ($ctr < $ENV{'form.totalparts'}) {
my $partid = $ENV{'form.partid_'.$ctr};
@@ -1809,8 +2349,9 @@ sub editgrades {
if ($type eq 'awarded' || $type eq 'solved') { next; }
my $display=&Apache::lonnet::metadata($url,$stores.'.display');
$display =~ s/\[Part: (\w)+\]//;
- $header .= ' Old '.$display.' '.
- ' New '.$display.' ';
+ $display =~ s/Number of Attempts/Tries/;
+ $header .= ' Old '.$display.' '.
+ ' New '.$display.' ';
$columns{$partid}+=2;
}
}
@@ -1823,16 +2364,23 @@ sub editgrades {
$result .= ' ';
$result .= $header;
$result .= ' '."\n";
-
+ my $noupdate;
+ my ($updateCtr,$noupdateCtr) = (1,1);
for ($i=0; $i<$ENV{'form.total'}; $i++) {
+ my $line;
my $user = $ENV{'form.ctr'.$i};
+ my $usercolon = $user;
+ $usercolon =~s/_/:/;
+ my ($uname,$udom)=split(/_/,$user);
my %newrecord;
my $updateflag = 0;
- my @userdom = grep /^$user:/,keys %$classlist;
- my (undef,$udom) = split(/:/,$userdom[0]);
-
- $result .= ''.$user.' '.
- $$fullname{$userdom[0]}.' ';
+ $line .= ''.&nameUserString(undef,$$fullname{$usercolon},$uname,$udom).' ';
+ my $usec=$classlist->{"$uname:$udom"}[5];
+ if (!&canmodify($usec)) {
+ my $numcols=scalar(@partid)*4+2;
+ $noupdate.=$line."Not allowed to modify student ";
+ next;
+ }
foreach (@partid) {
my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_awarded_s'};
my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
@@ -1850,19 +2398,29 @@ sub editgrades {
} elsif ($partial == 0) {
$score = 'incorrect_by_override';
}
- $score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_solved'} eq 'excused') &&
- ($score ne 'excused'));
- $result .= ''.$old_aw.' '.
- ''.$awarded.
- ($score eq 'excused' ? $score : '').' ';
+ my $dropMenu = $ENV{'form.GD_'.$user.'_'.$_.'_solved'};
+ $score = 'excused' if (($dropMenu eq 'excused') && ($score ne 'excused'));
- if (!($old_part eq $partial && $old_score eq $score)) {
+ if ($dropMenu eq 'reset status' &&
+ $old_score ne '') { # ignore if no previous attempts => nothing to reset
+ $newrecord{'resource.'.$_.'.tries'} = 0;
+ $newrecord{'resource.'.$_.'.solved'} = '';
+ $newrecord{'resource.'.$_.'.award'} = '';
+ $newrecord{'resource.'.$_.'.awarded'} = 0;
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ $updateflag = 1;
+ } elsif (!($old_part eq $partial && $old_score eq $score)) {
$updateflag = 1;
$newrecord{'resource.'.$_.'.awarded'} = $partial if $partial ne '';
$newrecord{'resource.'.$_.'.solved'} = $score;
$rec_update++;
}
+ $line .= ''.$old_aw.' '.
+ ''.$awarded.
+ ($score eq 'excused' ? $score : '').' ';
+
+
my $partid=$_;
foreach my $stores (@parts) {
my ($part,$type) = &split_part_type($stores);
@@ -1872,22 +2430,33 @@ sub editgrades {
my $awarded = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type};
if ($awarded ne '' && $awarded ne $old_aw) {
$newrecord{'resource.'.$part.'.'.$type}= $awarded;
+ $newrecord{'resource.'.$part.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
$updateflag=1;
}
- $result .= ''.$old_aw.' '.
+ $line .= ''.$old_aw.' '.
''.$awarded.' ';
}
}
- $result .= ''."\n";
+ $line.=''."\n";
if ($updateflag) {
$count++;
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
- $udom,$user);
+ $udom,$uname);
+ $result.=' '.$updateCtr.' '.$line;
+ $updateCtr++;
+ } else {
+ $noupdate.=' '.$noupdateCtr.' '.$line;
+ $noupdateCtr++;
}
}
- $result .= '
'."\n";
- my $msg = 'Number of records updated = '.$rec_update.
+ if ($noupdate) {
+# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
+ my $numcols=scalar(@partid)*4+2;
+ $result .= 'No Changes Occurred For the Students Below '.$noupdate;
+ }
+ $result .= '