-
- Select | Username |
- Fullname | Domain |
- Grade Status |
+ yes
+ Submissions:
+ handgrade only
+ last sub only
+ last sub & parts info
+ all details
+
+
+
+
+
ENDTABLEST
if ($ENV{'form.url'}) {
$request->print(''."\n");
@@ -157,23 +185,38 @@ ENDTABLEST
}
$request->print(''."\n");
- my ($classlist) = &getclasslist($getsec,'0');
- foreach my $student ( sort(@{ $$classlist{$getsec} }) ) {
- my ($sname,$sdom) = split(/:/,$student);
- my ($type,$status) = &student_gradeStatus($ENV{'form.url'},$cdom,$sname);
- next if ($status eq 'nothing' && $submitonly eq 'yes');
+ my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');
+
+ $result='');
@@ -191,13 +234,13 @@ sub processGroup {
return;
}
foreach (@stuchecked) {
- my ($sname,$sdom,$fullname) = split(/:/);
- $ENV{'form.student'} = $sname;
+ my ($uname,$udom,$fullname) = split(/:/);
+ $ENV{'form.student'} = $uname;
$ENV{'form.fullname'} = $fullname;
&submission($request,$ctr,$total);
$ctr++;
}
- return 'The End';
+ return '';
}
sub userError {
@@ -226,28 +269,32 @@ sub finduser {
}
sub getclasslist {
- my ($getsec,$hideexpired) = @_;
- my ($coursedomain,$coursenum) = split(/_/,$ENV{'request.course.id'});
- my %classlist=&Apache::lonnet::dump('classlist',$coursedomain,$coursenum);
- my $now = time;
- my (@holdsec,@sections);
- foreach my $student (keys(%classlist)) {
- my ($end,$start)=split(/:/,$classlist{$student});
- # still a student?
- if (($hideexpired) && ($end) && ($end < $now)) {
- next;
- }
- my ($unam,$udom) = split(/:/,$student,2);
- my $section = &Apache::lonnet::usection($udom,$unam,$ENV{'request.course.id'});
- $section = ($section ne '-1' ? $section : 'no');
- push @holdsec,$section;
- push (@{ $classlist{$getsec} }, $student) if ($getsec eq 'all' || $getsec eq $section);
- }
- my %seen = ();
- foreach my $item (@holdsec) {
- push (@sections, $item) unless $seen{$item}++;
- }
- return (\%classlist,\@sections);
+ my ($getsec,$hideexpired) = @_;
+ my %classlist=&Apache::lonnet::dump('classlist',
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ my $now = time;
+ my (@holdsec,@sections,%allids,%stusec,%fullname);
+ foreach (keys(%classlist)) {
+ my ($end,$start,$id,$section,$fullname)=split(/:/,$classlist{$_});
+ # still a student?
+ if (($hideexpired) && ($end) && ($end < $now)) {
+ next;
+ }
+ $section = ($section ne '' ? $section : 'no');
+ push @holdsec,$section;
+ if ($getsec eq 'all' || $getsec eq $section) {
+ push (@{ $classlist{$getsec} }, $_);
+ $allids{$_}=$id;
+ $stusec{$_}=$section;
+ $fullname{$_}=$fullname;
+ }
+ }
+ my %seen = ();
+ foreach my $item (@holdsec) {
+ push (@sections, $item) unless $seen{$item}++;
+ }
+ return (\%classlist,\@sections,\%allids,\%stusec,\%fullname);
}
sub getpartlist {
@@ -264,14 +311,13 @@ sub getpartlist {
sub viewstudentgrade {
my ($url,$symb,$courseid,$student,@parts) = @_;
- my $result ='';
my $cellclr = '"#ffffdd"';
my ($username,$domain) = split(/:/,$student);
my $fullname = &get_fullname($username,$domain);
my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$username);
- $result.="$username | $fullname | $domain | \n";
+ my $result=" $username | $fullname | $domain | \n";
foreach my $part (@parts) {
my ($temp,$part,$type)=split(/_/,$part);
my $score=$record{"resource.$part.$type"};
@@ -282,14 +328,14 @@ sub viewstudentgrade {
my ($status,$foo)=split(/_/,$score,2);
$result.=" | \n";
}
}
- $result.=' | ';
+ $result.='';
return $result;
}
@@ -322,7 +368,7 @@ sub setstudentgrade {
if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
if ($newscore eq 'excused') { $newscore = 'excused'; }
if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
- if ($newscore eq 'partial') { $newscore = 'correct_partially_by_override'; }
+# if ($newscore eq 'partial') { $newscore = 'correct_partially_by_override'; }
} else {
#$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
}
@@ -350,271 +396,6 @@ sub setstudentgrade {
sub submission {
my ($request,$counter,$total) = @_;
- if ($counter == 0) {
- $request->print(<
- function updateRadio(radioButton,formtextbox,formsel,wgt) {
- 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 0 && pts < wgt) {
- formsel[4].selected = true;
- }
- if (pts == wgt) {
- formsel[0].selected = true;
- }
- return;
- }
-
- function keywords(keyform) {
- var keywds = keyform.value;
- var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds);
- if (nret==null) return;
- keyform.value = nret;
- return;
- }
-
-//===================== Script to add keyword(s) ==================
- function getSel() {
- if (document.getSelection) txt = document.getSelection();
- else if (document.selection) txt = document.selection.createRange().text;
- else return;
- var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
- if (cleantxt=="") {
- alert("Select a word or group of words from document and then click this link.");
- return;
- }
- var nret = prompt("Add selection to keyword list?",cleantxt);
- if (nret==null) return;
- var curlist = document.SCORE.keywords.value;
- document.SCORE.keywords.value = curlist+" "+nret;
- return;
- }
-
-//====================== Script for composing message ==============
- function msgCenter(msgform,usrctr,fullname) {
- var Nmsg = msgform.savemsgN.value;
- savedMsgHeader(Nmsg,usrctr,fullname);
- var subject = msgform.msgsub.value;
- displaySubject(subject);
- for (var i=1; i<=Nmsg; i++) {
- var message = eval("document.SCORE.savemsg"+i+".value");
- displaySavedMsg(i,message);
- }
- newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
- newMsg(newmsg);
- msgTail();
- return;
- }
-
-function savedMsgHeader(Nmsg,usrctr,fullname) {
- var height = 30*Nmsg+250;
- var scrollbar = "no";
- if (height > 600) {
- height = 600;
- scrollbar = "yes";
- }
- pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',width=600,height='+height);
- pWin.document.write("");
- pWin.document.write("Message Central");
-
- pWin.document.write("
-SUBJAVASCRIPT
-}
(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) = &finduser($ENV{'form.student'});
@@ -623,174 +404,228 @@ SUBJAVASCRIPT
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 ''; }
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
-#
-# header info
+
+ # header info
if ($counter == 0) {
+ &sub_page_js($request);
$request->print(' Submission Record'.
' Resource: '.$url.'');
- }
-#
-# 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' && $counter == 0) {
- my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
- $ENV{'request.course.id'});
- my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
- $ENV{'request.course.id'});
- my $result.='';
- $result.='';
- $result.='Student\'s view of the problem | '.$rendered.' ';
- $result.='Correct answer: '.$companswer;
- $result.=' | ';
- $result.=' |
';
- $request->print($result);
- }
-#
-# beginning of form
- if ($counter == 0) {
- my %keyhash = &Apache::lonnet::get
- ('nohist_handgrade',[$symb.'_keywords'],
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ # 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') {
+ my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ my $result.='';
+ $result.='';
+ $result.='Student\'s view of the problem | '.$rendered.' ';
+ $result.='Correct answer: '.$companswer;
+ $result.=' | ';
+ $result.=' |
';
+ $request->print($result);
+ }
+
+ # 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 '') {
+ %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.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
+ $keyhash{$symb.'_subject'} : &Apache::lonnet::metadata($url,'title');
+ $ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
+ }
$request->print('';
+ $ntstu =~ s/ ';
$request->print($endform);
}
return '';
@@ -799,35 +634,34 @@ KEYWORDS
sub get_last_submission {
my ($symb,$username,$domain,$course)=@_;
if ($symb) {
- my (%returnhash)=&Apache::lonnet::restore($symb,$course,$domain,$username);
- if ($returnhash{'version'}) {
- my %lasthash=();
- my $version;
- for ($version=1;$version<=$returnhash{'version'};$version++) {
- foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
- $lasthash{$_}=$returnhash{$version.':'.$_};
+ my (@string,$timestamp);
+ my (%returnhash)=&Apache::lonnet::restore($symb,$course,$domain,$username);
+ if ($returnhash{'version'}) {
+ my %lasthash=();
+ my ($version);
+ for ($version=1;$version<=$returnhash{'version'};$version++) {
+ foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
+ $lasthash{$_}=$returnhash{$version.':'.$_};
+ }
}
- }
- foreach ((keys %lasthash)) {
- if ($_ =~ /\.submission$/) {return $lasthash{$_}}
- }
- return '';
- }
+ foreach ((keys %lasthash)) {
+ if ($_ =~ /\.submission$/) {push @string, (join(':',$_,$lasthash{$_}))}
+ if ($_ =~ /timestamp/) {$timestamp = scalar(localtime($lasthash{$_}))};
+ }
+ }
+ @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
+ return \@string,\$timestamp;
}
}
sub keywords_highlight {
my $string = shift;
- (my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
- my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
- my %keyhash = &Apache::lonnet::get
- ('nohist_handgrade',[$symb.'_keywords'],
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
- my @keylist = split(/[,\s+]/,$keyhash{$symb.'_keywords'});
- foreach my $word (@keylist) {
- next if ($word eq '');
- $string =~ s/\b$word(\b|\.)/\$word\<\/font\>/gi;
+ my $size = $ENV{'form.kwsize'} eq '0' ? '' : 'size='.$ENV{'form.kwsize'};
+ my $styleon = $ENV{'form.kwstyle'} eq '' ? '' : $ENV{'form.kwstyle'};
+ (my $styleoff = $styleon) =~ s/\\<\//;
+ my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
+ foreach (@keylist) {
+ $string =~ s/\b$_(\b|\.)/\$styleon$_$styleoff\<\/font\>/gi;
}
return $string;
}
@@ -839,133 +673,171 @@ sub processHandGrade {
my $button = $ENV{'form.gradeOpt'};
my $ngrade = $ENV{'form.NCT'};
my $ntstu = $ENV{'form.NTSTU'};
- my $keywords= $ENV{'form.keywords'};
- my $newmsg0 = $ENV{'form.newmsg0'};
- print "newmsg0=$newmsg0 ";
- my $newmsg1 = $ENV{'form.newmsg1'};
- print "newmsg1=$newmsg1 ";
- my $oldmsg1 = $ENV{'form.savemsg1'};
- print "oldmsg1=$oldmsg1 ";
- my $oldmsg2 = $ENV{'form.savemsg2'};
- print "oldmsg1=$oldmsg2 ";
- my $oldmsg3 = $ENV{'form.savemsg3'};
- print "oldmsg1=$oldmsg3 ";
- my $oldmsg4 = $ENV{'form.savemsg4'};
- print "oldmsg1=$oldmsg4 ";
- my $messages = $ENV{'form.includemsg0'};
- print "messages=$messages ";
- if ($keywords ne '') {
- my $crsname = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
- my $crsdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
-# my $putresult = &Apache::lonnet::put
-# ('nohist_handgrade',{$symb.'_keywords' => $keywords},
-# $crsdom,$crsname);
+
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ my %keyhash = ();
+ $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
+ $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
+ $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'};
+
+ 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 = 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++;
+ }
+ $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'});
+
+ if ($ENV{'form.refresh'} eq 'on') {
+ my $ctr = 0;
+ $ENV{'form.NTSTU'}=$ngrade;
+ while ($ctr < $ngrade) {
+ ($ENV{'form.student'},my $udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
+ &submission($request,$ctr,$ngrade-1);
+ $ctr++;
+ }
+ return '';
}
- my (@parts) = sort(&getpartlist($url));
if ($button eq 'Save & Next') {
my $ctr = 0;
- while ($ctr < $ENV{'form.NCT'}) {
+ while ($ctr < $ngrade) {
my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
- &saveHandGrade($url,$symb,$uname,$udom,$ctr,@parts);
+ my ($errorflg) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
+ return '' if ($errorflg eq 'error');
+
+ my $includemsg = $ENV{'form.includemsg'.$ctr};
+ my ($subject,$message,$msgstatus) = ('','','');
+ if ($includemsg =~ /savemsg|new$ctr/) {
+ $subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);
+ my (@msgnum) = split(/,/,$includemsg);
+ foreach (@msgnum) {
+ $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
+ }
+ $message =~ s/\s+/ /g;
+ $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($url,$symb,$_,$udom,$ctr,@parts);
+ &saveHandGrade($request,$url,$symb,$_,$udom,$ctr);
+ if ($message ne '') {
+ $msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,$ENV{'form.msgsub'},$message);
+ }
}
}
$ctr++;
}
}
my $firststu = $ENV{'form.unamedom0'};
- my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
-
- my ($classlist) = &getclasslist($ENV{'form.section'},'0');
+ my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
+ $ctr = 2;
+ while ($laststu eq '') {
+ $laststu = $ENV{'form.unamedom'.($ngrade-$ctr)};
+ $ctr++;
+ $laststu = $firststu if ($ctr > $ngrade);
+ }
+ my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
- my (@nextlist,@prevlist);
- my ($nextflg,$prevflg,$ctr,$ctprev) = (0,0,0,0);
- foreach my $student ( sort(@{ $$classlist{$ENV{'form.section'}} }) ) {
- my ($uname,$udom) = split(/:/,$student);
+ my (@parsedlist,@nextlist);
+ my ($nextflg) = 0;
+ foreach ( sort(@{ $$classlist{$ENV{'form.section'}} }) ) {
if ($nextflg == 1 && $button =~ /Next$/) {
- push @nextlist,$uname if ($ctr < $ntstu);
- $ctr++;
+ push @parsedlist,$_;
}
- $nextflg = 1 if ($student eq $laststu);
- $prevflg = 1 if ($student eq $firststu);
- if ($prevflg == 0 && $button eq 'Previous') {
- push @prevlist,$uname;
- $ctprev++;
+ $nextflg = 1 if ($_ eq $laststu);
+ if ($button eq 'Previous') {
+ last if ($_ eq $firststu);
+ push @parsedlist,$_;
}
}
- if ($button eq 'Previous') {
- if ($ctprev <= $ntstu) {
- @nextlist = @prevlist;
- } else {
- my $idx = 0;
- my $start = $ctprev - $ntstu;
- while ($idx < $ntstu) {
- $nextlist[$idx] = $prevlist[$start+$idx];
- $idx++;
+ $ctr = 0;
+ my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
+ @parsedlist = reverse @parsedlist if ($button eq 'Previous');
+ foreach my $student (@parsedlist) {
+ my ($uname,$udom) = split(/:/,$student);
+ if ($ENV{'form.submitonly'} eq 'yes') {
+ my (%status) = &student_gradeStatus($ENV{'form.url'},$udom,$uname,$partlist) ;
+ my $statusflg = '';
+ foreach (keys(%status)) {
+ $statusflg = 1 if ($status{$_} ne 'nothing');
}
+ next if ($statusflg eq '');
}
+ push @nextlist,$student if ($ctr < $ntstu);
+ $ctr++;
}
+
$ctr = 0;
my $total = scalar(@nextlist)-1;
- foreach my $student (@nextlist) {
- $ENV{'form.student'} = $student;
+ foreach (sort @nextlist) {
+ my ($uname,$udom) = split(/:/);
+ $ENV{'form.student'} = $uname;
+ $ENV{'form.fullname'} = $$fullname{$_};
&submission($request,$ctr,$total);
$ctr++;
}
-
- return 'The End';
+ if ($total < 0) {
+ my $the_end = 'LON-CAPA User Message '."\n";
+ $the_end.='Message: No more students for this section or class.
'."\n";
+ $the_end.='Click on the button below to return to the grading menu.
'."\n";
+ $the_end.=&show_grading_menu_form ($symb,$url);
+ $request->print($the_end);
+ }
+ return '';
}
sub saveHandGrade {
- my ($url,$symb,$stuname,$domain,$newflg,@parts) = @_;
- my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
+ my ($request,$url,$symb,$stuname,$domain,$newflg) = @_;
+# my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
my %newrecord;
-
- foreach my $part (@parts) {
- my ($temp,$part,$type)=split(/_/,$part);
- my $oldscore=$record{"resource.$part.$type"};
- my $newscore;
- if ($type eq 'awarded' && $newflg >= 0) {
- my $pts = ($ENV{'form.GRADE_BOX'.$newflg} ne '' ?
- $ENV{'form.GRADE_BOX'.$newflg} : $ENV{'form.RADVAL'.$newflg});
- my $wgt = $ENV{'form.WGT'.$newflg};
-# my $sel = $ENV{'form.GRADE_SEL'.$newflg};
- $newscore = $pts/$wgt if ($wgt != 0);
- }
- if ($type eq 'solved') {
- $newscore = $ENV{'form.GRADE_SEL'.$newflg} if ($newflg >= 0);
- my $update=0;
- if ($newscore eq 'nothing' ) {
- if ($oldscore ne '') {
- $update=1;
- $newscore = '';
- }
- } elsif ($oldscore !~ m/^$newscore/) {
- $update=1;
- if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }
- if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
- if ($newscore eq 'excused') { $newscore = 'excused'; }
- if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
- if ($newscore eq 'partial') { $newscore = 'correct_partially_by_override'; }
- }
- if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
- } else {
- if ($oldscore ne $newscore) {
- $newrecord{"resource.$part.$type"}=$newscore;
+ foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
+ if ($ENV{'form.GRADE_SEL'.$newflg.'_'.$_} eq 'excused') {
+ $newrecord{'resource.'.$_.'.solved'} = 'excused';
+ } else {
+ my $pts = ($ENV{'form.GRADE_BOX'.$newflg.'_'.$_} ne '' ?
+ $ENV{'form.GRADE_BOX'.$newflg.'_'.$_} : $ENV{'form.RADVAL'.$newflg.'_'.$_});
+ if ($pts eq '') {
+ &userError($request,'No point was assigned for part id '.$_.' and for username '.$stuname.'.');
+ return 'error';
+ }
+ my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : $ENV{'form.WGT'.$newflg.'_'.$_};
+ my $partial= $pts/$wgt;
+ $newrecord{'resource.'.$_.'.awarded'} = $partial;
+ if ($partial == 0) {
+ $newrecord{'resource.'.$_.'.solved'} = 'incorrect_by_override';
+ } else {
+ $newrecord{'resource.'.$_.'.solved'} = 'correct_by_override';
+ }
}
- }
}
+
if ( scalar(keys(%newrecord)) > 0 ) {
$newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
# while (my ($k,$v) = each %newrecord) {
# print "k=$k:v=$v: \n";
# }
-# print "symb=$symb,courseid=$ENV{'request.course.id'},dom=$domain,name=$stuname ";
-# &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},$domain,$stuname);
+ &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},$domain,$stuname);
}
return '';
}
@@ -993,25 +865,70 @@ sub gradingmenu {
my ($request) = @_;
my ($symb,$url)=&get_symb_and_url($request);
if (!$symb) {return '';}
- my $allkeys = &Apache::lonnet::metadata($url,'keys');
- my $handgrade = ($allkeys =~ /parameter_.*?_handgrade/ ? 'yes' : 'no');
- my ($responsetype,$foo) = split(/_/,&Apache::lonnet::metadata($url,'packages'));
-
my $result=' Select a Grading Method';
$result.='';
- $result.='Resource: | '.
- ''.$url.' | ';
- $result.='Type: | '.
- ''.$responsetype.' Handgrade: '.$handgrade.' | ';
+ $result.='Resource: '.$url.' | ';
+ my ($partlist,$handgrade) = &response_type($url);
+ my ($resptype,$hdgrade)=('','no');
+ for (sort keys(%$handgrade)) {
+ my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
+ $resptype = $responsetype;
+ $hdgrade = $handgrade if ($handgrade eq 'yes');
+ $result.='Part id: '.$_.' | '.
+ 'Type: '.$responsetype.' | '.
+ 'Handgrade: '.$handgrade.' | ';
+ }
$result.=' ';
-
$result.=&view_edit_entire_class_form($symb,$url).' ';
$result.=&upcsvScores_form($symb,$url).' ';
- $result.=&viewGradeaStu_form($symb,$url,$responsetype,$handgrade).' ';
- $result.=&verifyReceipt_form($symb,$url);
+ $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).' ';
+ $result.=&verifyReceipt_form($symb,$url).' ';
+ $result.=&view_classlist_form($symb,$url);
+
+ return $result;
+}
+
+sub view_classlist_form {
+ my ($symb,$url)=@_;
+ my $result.=''."\n";
+ $result.=''."\n";
+ $result.=' View Class List | '."\n";
+ $result.=''."\n";
+ $result.=''."\n";
+ $result.=' | '."\n";
+ $result.=' | '."\n";
return $result;
}
+sub viewclasslist {
+ my ($request) = shift;
+ my ($coursedomain,$coursenum) = split(/_/,$ENV{'request.course.id'});
+ my %classlist=&Apache::lonnet::dump('classlist',$coursedomain,$coursenum);
+ $request->print('');
+ foreach (sort keys(%classlist)) {
+# my ($unam,$udom) = split(/:/,$_,2);
+# my $section = &Apache::lonnet::usection($udom,$unam,$ENV{'request.course.id'});
+# my $fullname = &get_fullname ($unam,$udom);
+# my @uname;
+# $uname[0]=$unam;
+# my %userid=&Apache::lonnet::idrget($udom,@uname);
+# my $value=$classlist{$_}.':'.$userid{$unam}.':'.$section.':'.$fullname;
+# $classlist{$_}=$value;
+ $request->print(''.$_.' | '.$classlist{$_}.' | ');
+ }
+ $request->print(' ');
+# my $putresult = &Apache::lonnet::put
+# ('classlist',\%classlist,
+# $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+# $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ return '';
+}
+
sub view_edit_entire_class_form {
my ($symb,$url)=@_;
my $result.=''."\n";
@@ -1061,20 +978,20 @@ sub viewGradeaStu_form {
$result.=' View/Grade an Individual Student\'s Submission | '."\n";
$result.=''."\n";
$result.=' |
|