-
-Resource: $ENV{'form.url'}
-Username Name Domain
-View Problem Submissions
-Grade Status Action
+
+ Select Username
+ Fullname Domain
+ Grade Status
ENDTABLEST
- my (%classlist) = &getclasslist($cdom,$cnum,'0');
- foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
+ if ($ENV{'form.url'}) {
+ $request->print(' '."\n");
+ }
+ if ($ENV{'form.symb'}) {
+ $request->print(' '."\n");
+ }
+ $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 %name=&Apache::lonnet::get('environment', ['lastname','generation',
- 'firstname','middlename'],
- $sdom,$sname);
- my $fullname;
- my ($tmp) = keys(%name);
- if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
- $fullname=$name{'lastname'}.$name{'generation'};
- if ($fullname =~ /[^\s]+/) { $fullname.=', '; }
- $fullname.=$name{'firstname'}.' '.$name{'middlename'};
- }
+ my $fullname = &get_fullname($sname,$sdom);
if ( $Apache::grades::viewgrades eq 'F' ) {
- $request->print("\n".''."$sname $fullname $sdom ".
- ' ');
-# $request->print('');
+ $request->print("\n".''.
+ ' '."\n".
+ ' '.$sname.' '."\n".
+ ' '.$fullname.' '."\n".
+ ' '.$sdom.' '."\n");
+ $request->print(' '.$status.' '."\n");
+
+ $request->print(' ');
}
}
$request->print('
');
+ $request->print(' ');
}
+sub processGroup {
+ my ($request) = shift;
+ my $ctr = 0;
+ my @stuchecked = (ref($ENV{'form.stuinfo'}) ? @{$ENV{'form.stuinfo'}}
+ : ($ENV{'form.stuinfo'}));
+ my $total = scalar(@stuchecked)-1;
+ if ($stuchecked[0] eq '') {
+ &userError($request,'No student was selected for viewing/grading.');
+ return;
+ }
+ foreach (@stuchecked) {
+ my ($sname,$sdom,$fullname) = split(/:/);
+ $ENV{'form.student'} = $sname;
+ $ENV{'form.fullname'} = $fullname;
+ &submission($request,$ctr,$total);
+ $ctr++;
+ }
+ return 'The End';
+}
+
+sub userError {
+ my ($request, $reason, $step) = @_;
+ $request->print('LON-CAPA User Error '."\n");
+ $request->print('Reason: '.$reason.' '."\n");
+ $request->print('Step: '.($step ne '' ? $step : 'Use your browser back button to correct')
+ .' '."\n");
+ return '';
+}
#FIXME - needs to handle multiple matches
sub finduser {
my ($name) = @_;
my $domain = '';
-
if ( $Apache::grades::viewgrades eq 'F' ) {
- #get classlist
- my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
- #print "Found $cdom:$cnum ";
- my (%classlist) = &getclasslist($cdom,$cnum,'0');
- foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
- my ($posname,$posdomain) = split(/:/,$student);
+ my ($classlist) = &getclasslist('all','0');
+ foreach ( sort(@{ $$classlist{'all'} }) ) {
+ my ($posname,$posdomain) = split(/:/);
if ($posname =~ $name) { $name=$posname; $domain=$posdomain; last; }
}
return ($name,$domain);
@@ -219,20 +228,28 @@ sub finduser {
}
sub getclasslist {
- my ($coursedomain,$coursenum,$hideexpired) = @_;
+ 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)) {
- #print "Skipping:$name:$end:$now \n";
next;
}
- #print "record=$record ";
- push( @{ $classlist{'allids'} }, $student);
+ 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);
+ return (\%classlist,\@sections);
}
sub getpartlist {
@@ -253,14 +270,9 @@ sub viewstudentgrade {
my $cellclr = '"#ffffdd"';
my ($username,$domain) = split(/:/,$student);
- my (@requests) = ('lastname','firstname','middlename','generation');
- my (%name) = &Apache::lonnet::get('environment',\@requests,$domain,$username);
+ my $fullname = &get_fullname($username,$domain);
my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$username);
- my $fullname=$name{'lastname'}.$name{'generation'};
- if ($fullname =~ /[^\s]+/) { $fullname.=', '; }
- $fullname.=$name{'firstname'}.' '.$name{'middlename'};
-
$result.=" $username $fullname $domain \n";
foreach my $part (@parts) {
my ($temp,$part,$type)=split(/_/,$part);
@@ -272,7 +284,7 @@ sub viewstudentgrade {
my ($status,$foo)=split(/_/,$score,2);
$result.="\n";
my $optsel = 'correct incorrect excused '.
- 'ungraded handgraded nothing '."\n";
+ 'ungraded partial nothing '."\n";
$status = 'nothing' if ($status eq '');
$optsel =~ s/$status/ $status/;
$result.=$optsel;
@@ -287,7 +299,7 @@ sub viewstudentgrade {
#interface based on that, also do that to above function.
sub setstudentgrade {
my ($url,$symb,$courseid,$student,@parts) = @_;
-
+ print "set student grade parts=@parts ";
my $result ='';
my ($stuname,$domain) = split(/:/,$student);
my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
@@ -308,10 +320,11 @@ sub setstudentgrade {
} elsif ($oldscore !~ m/^$newscore/) {
$update=1;
$result.="Updating $stuname to $newscore \n";
- if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }
+ 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 'excused') { $newscore = 'excused'; }
+ if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
+ if ($newscore eq 'partial') { $newscore = 'correct_partially_by_override'; }
} else {
#$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
}
@@ -327,130 +340,671 @@ sub setstudentgrade {
}
if ( scalar(keys(%newrecord)) > 0 ) {
$newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
- print "grader=$newrecord{'resource.regrader'}: records ";
- while (my ($k,$v) = each %newrecord) {
- print "k=$k:v=$v: \n";
- }
- &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
+# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
$result.="Stored away ".scalar(keys(%newrecord))." elements. \n";
}
return $result;
}
-# --------------------------- show submissions of a student, option to grade --------
#
+# --------------------------- show submissions of a student, option to grade --------
sub submission {
- my ($request) = @_;
- $request->print(<print(<
- function updateRadio() {
- var pts = document.SCORE.GRADE_BOX.value;
- var radioButton = document.SCORE.radval;
- var checked =true;
- var unchecked=false;
- 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;
+ var rtrchk = eval("document.SCORE.includemsg"+usrctr);
+ var msgchk = rtrchk.value;
+// alert("checked=>"+msgchk);
+ re = /msgsub/;
+ var shwsel = "";
+ if (re.test(msgchk)) { shwsel = "checked" }
+ displaySubject(subject,shwsel);
+ for (var i=1; i<=Nmsg; i++) {
+ var testpt = "savemsg"+i+",";
+ re = /testpt/;
+ shwsel = "";
+ if (re.test(msgchk)) { shwsel = "checked" }
+ var message = eval("document.SCORE.savemsg"+i+".value");
+ displaySavedMsg(i,message,shwsel);
+ }
+ newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
+ shwsel = "";
+ re = /newmsg/;
+ if (re.test(msgchk)) { shwsel = "checked" }
+ newMsg(newmsg,shwsel);
+ msgTail();
+ return;
+ }
+
+function savedMsgHeader(Nmsg,usrctr,fullname) {
+ var height = 30*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+',width=600,height='+height);
+ pWin.document.write("");
+ pWin.document.write("Message Central ");
+
+ pWin.document.write("
-JAVASCRIPT
- my $url=$ENV{'form.url'};
- $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
- if ($ENV{'form.student'} eq '') { &moreinfo($request,"Need student login id"); return ''; }
+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'});
- if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; }
+ 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 ''; }
-#
-# header info
- my $result='Submission Record ';
- $result.='Username: '.$uname.'Fullname: '.$ENV{'form.fullname'}.'Domain: '.$udom.' ';
- $result.='Resource: '.$url.'
';
-#
-# option to display problem
- if ($ENV{'form.vProb'} eq 'yes') {
+ my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
+
+ # header info
+ if ($counter == 0) {
+ $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'});
- $result.='';
- $result.='';
+ my $result.='';
+ $result.='';
$result.='Student\'s view of the problem '.$rendered.' ';
$result.='Correct answer: '.$companswer;
$result.='
';
$result.='
';
+ $request->print($result);
}
- my $last = '';
- $last = 'last' if ($ENV{'form.submission'} eq 'last');
- my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
- $ENV{'request.course.id'},$last);
- $result.=$answer;
- my $wgt = &Apache::lonnet::EXT('resource.partid.weight',$symb,$udom,$uname);
- my %record= &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
- my $score = $record{'resource.0.awarded'}*$wgt;
+ # beginning of form
+ if ($counter == 0) {
+ 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'};
+ # if the handgrade db has never being initialized then set some default values
+ if ($keyhash{$symb.'_handgrade'} eq '') {
+ $keyhash{$symb.'_keywords'} = '';
+ $keyhash{$symb.'_subject'} = &Apache::lonnet::metadata($url,'title');
+ $keyhash{$loginuser.'_kwclr'} = $keyhash{$loginuser.'_kwclr'} eq '' ? 'red' : $keyhash{$loginuser.'_kwclr'};
+ $keyhash{$loginuser.'_kwsize'} = $keyhash{$loginuser.'_kwsize'} eq '' ? '0' : $keyhash{$loginuser.'_kwsize'};
+ $keyhash{$loginuser.'_kwstyle'} = $keyhash{$loginuser.'_kwstyle'} eq '' ? '' : $keyhash{$loginuser.'_kwstyle'};
+ $keyhash{$symb.'_savemsgN'} = '0';
+ }
+ $request->print('';
- return $result;
+ foreach my $part (&getpartlist($url)) {
+ my ($temp,$part,$type)=split(/_/,$part);
+ if ($type eq 'solved') {
+ my ($status,$foo)=split(/_/,$record{"resource.$part.$type"},2);
+ $status = 'partial' if ($foo =~ /partially/);
+ $status = 'nothing' if ($status eq '');
+ $result.=''."\n";
+ my $optsel = 'correct incorrect '.
+ 'excused ungraded '.
+ 'partial nothing '."\n";
+ $optsel =~ s/$status/ $status/;
+ $result.=$optsel;
+ $result.="   \n";
+ $result.='Compose Message '."\n";
+ }
+ }
+ $result.='
';
+ $request->print($result);
+
+ # print end of form
+ if ($counter == $total) {
+ my $endform.='';
+ $request->print($endform);
+ }
+ return '';
+}
+
+sub get_last_submission {
+ my ($symb,$username,$domain,$course)=@_;
+ if ($symb) {
+ 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$/) {$string = $lasthash{$_}}
+ if ($_ =~ /timestamp/) {$timestamp=scalar(localtime($lasthash{$_}))};
+ }
+ }
+ $string = $string 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 $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+
+ my @kwkeys = ($symb.'_keywords',
+ $loginuser.'_kwclr',
+ $loginuser.'_kwsize',
+ $loginuser.'_kwstyle'
+ );
+
+ my %keyhash = &Apache::lonnet::get
+ ('nohist_handgrade',\@kwkeys,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ my @keylist = split(/[,\s+]/,$keyhash{$symb.'_keywords'});
+ my $size = $keyhash{$kwkeys[2]} eq '0' ? '' : 'size='.$keyhash{$kwkeys[2]};
+ my $styleon = $keyhash{$kwkeys[3]} eq '' ? '' : $keyhash{$kwkeys[3]};
+ (my $styleoff = $styleon) =~ s/\\<\//;
+ foreach my $word (@keylist) {
+ next if ($word eq '');
+ $string =~ s/\b$word(\b|\.)/\$styleon$word$styleoff\<\/font\>/gi;
+ }
+ return $string;
}
sub processHandGrade {
- my ($url,$symb,$courseid,$student,@parts) = @_;
+ my ($request) = shift;
+ my $url = $ENV{'form.url'};
+ my $symb = $ENV{'form.symb'};
+ my $button = $ENV{'form.gradeOpt'};
+ my $ngrade = $ENV{'form.NCT'};
+ my $ntstu = $ENV{'form.NTSTU'};
+
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ my %keyhash = ();
+ $keyhash{$symb.'_handgrade'} = 'activated';
+ $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};
+ $idx++;
+ }
+ $ctr++;
+ }
- my ($stuname,$domain) = split(/:/,$student);
- my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
+ $keyhash{$symb.'_savemsgN'} = --$idx;
+ my $putresult = &Apache::lonnet::put
+ ('nohist_handgrade',\%keyhash,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ my (@parts) = sort(&getpartlist($url));
+
+ if ($button eq 'Save & Next') {
+ my $ctr = 0;
+ while ($ctr < $ngrade) {
+ my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
+ &saveHandGrade($url,$symb,$uname,$udom,$ctr,@parts);
+ if ($ENV{'form.collaborator'.$ctr}) {
+ my (@collaborators) = split(/:/,$ENV{'form.collaborator'.$ctr});
+ foreach (@collaborators) {
+ &saveHandGrade($url,$symb,$_,$udom,$ctr,@parts);
+ }
+ }
+ $ctr++;
+ }
+ }
+ my $firststu = $ENV{'form.unamedom0'};
+ my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
+
+ my ($classlist) = &getclasslist($ENV{'form.section'},'0');
+# print "first=$firststu,last=$laststu ";
+ 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 ($type,$status) = &student_gradeStatus($ENV{'form.url'},$udom,$uname);
+ next if ($status eq 'nothing' && $ENV{'form.submitonly'} eq 'yes');
+
+ if ($nextflg == 1 && $button =~ /Next$/) {
+ push @nextlist,$uname if ($ctr < $ntstu);
+ $ctr++;
+ }
+ $nextflg = 1 if ($student eq $laststu);
+ $prevflg = 1 if ($student eq $firststu);
+ if ($prevflg == 0 && $button eq 'Previous') {
+ push @prevlist,$uname;
+ $ctprev++;
+ }
+ }
+# print "next student=@nextlist ";
+ 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 $total = scalar(@nextlist)-1;
+ foreach my $student (@nextlist) {
+ $ENV{'form.student'} = $student;
+ &submission($request,$ctr,$total);
+ $ctr++;
+ }
+
+ return 'The End';
+}
+
+sub saveHandGrade {
+ my ($url,$symb,$stuname,$domain,$newflg,@parts) = @_;
+ 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=($ENV{'form.GRADE_BOX'} ne '' ? $ENV{"form.GRADE_BOX"} : $ENV{'form.radval'});
+ 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 '') {
@@ -463,45 +1017,32 @@ sub processHandGrade {
if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
if ($newscore eq 'excused') { $newscore = 'excused'; }
if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
- if ($newscore eq 'handgraded') { $newscore = 'handgraded_by_grader'; }
+ 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;
+ }
}
}
if ( scalar(keys(%newrecord)) > 0 ) {
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
- print "grader=$newrecord{'resource.regrader'}: records ";
- while (my ($k,$v) = each %newrecord) {
- print "k=$k:v=$v: \n";
- }
- &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
+ $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);
}
return '';
}
sub get_symb_and_url {
- my ($request) = @_;
- my $url=$ENV{'form.url'};
- $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
-# my $symb=$ENV{'form.symb'};
-# if (!$symb) { $symb=&Apache::lonnet::symbread($url); }
+ my ($request) = @_;
+ (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)));
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
- return ($symb,$url);
-}
-
-sub view_edit_entire_class_form {
- my ($symb,$url)=@_;
- my $result.=''."\n";
- return $result;
+ return ($symb,$url);
}
sub show_grading_menu_form {
@@ -519,31 +1060,119 @@ 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.='
';
+
+ $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);
+ return $result;
+}
- my $result=' Select a Grading Method ';
- $result.=''."\n";
- $result.=''."\n";
- $result.=' Resource : '.$url.' '."\n";
+sub view_edit_entire_class_form {
+ my ($symb,$url)=@_;
+ my $result.=''."\n";
+ $result.=''."\n";
+ $result.='
'."\n";
+ return $result;
+}
+
+sub upcsvScores_form {
+ my ($symb,$url) = @_;
+ if (!$symb) {return '';}
+ my $result.=''."\n";
+ $result.=''."\n";
+ $result.='
'."\n";
+ return $result;
+}
+
+sub viewGradeaStu_form {
+ my ($symb,$url,$response,$handgrade) = @_;
+ my ($classlist,$sections) = &getclasslist('all','0');
+ my $result.=''."\n";
+ $result.=''."\n";
+ $result.='
'."\n";
+ return $result;
+}
+
+sub verifyReceipt_form {
+ my ($symb,$url) = @_;
+ my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
+ my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
+ my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
+
+ my $result.=''."\n";
+ $result.=''."\n";
+ $result.=' Verify a Submission Receipt Issued by this Server '."\n";
+ $result.=''."\n";
+ $result.='';
$result.='
'."\n";
$result.='
'."\n";
return $result;
@@ -559,7 +1188,7 @@ sub viewgrades {
#get classlist
my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
#print "Found $cdom:$cnum ";
- my (%classlist) = &getclasslist($cdom,$cnum,'0');
+ my ($classlist) = &getclasslist('all','0');
my $headerclr = '"#ccffff"';
my $cellclr = '"#ffffcc"';
@@ -580,12 +1209,11 @@ sub viewgrades {
foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
- print "Manual grading:$url:$part:$display: ";
$result.=''.$display.' '."\n";
}
$result.='';
#get info for each student
- foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
+ foreach my $student ( sort(@{ $$classlist{'all'} }) ) {
my $display=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
# print "ID=$ENV{'request.course.id'}:STU=$student:DIS=$display: \n";
$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
@@ -604,9 +1232,9 @@ sub editgrades {
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$symb:$ENV{'form.url'}"); return ''; }
my $url=$ENV{'form.url'};
#get classlist
- my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
+# my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
#print "Found $cdom:$cnum ";
- my (%classlist) = &getclasslist($cdom,$cnum,'0');
+ my ($classlist) = &getclasslist('all','0');
#get list of parts for this problem
my (@parts) = &getpartlist($url);
@@ -617,7 +1245,7 @@ sub editgrades {
' '."\n".
' '."\n";
- foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
+ foreach my $student ( sort(@{ $$classlist{'all'} }) ) {
$result.=&setstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
}
@@ -625,25 +1253,6 @@ sub editgrades {
return $result;
}
-sub csvupload {
- my ($request)= @_;
- my $result;
- my ($symb,$url)=&get_symb_and_url($request);
- if (!$symb) {return '';}
- my $upfile_select=&Apache::loncommon::upfile_select_html();
- $result.=<
-
-
-
-
-Specify a file containing the class grades for resource $url
-$upfile_select
-
-ENDUPFORM
- return $result;
-}
-
sub csvupload_javascript_reverse_associate {
return(<print('Assigning Grades ');
my $courseid=$ENV{'request.course.id'};
- my $cdom=$ENV{"course.$courseid.domain"};
- my $cnum=$ENV{"course.$courseid.num"};
- my (%classlist) = &getclasslist($cdom,$cnum,'1');
+# my $cdom=$ENV{"course.$courseid.domain"};
+# my $cnum=$ENV{"course.$courseid.num"};
+ my ($classlist) = &getclasslist('all','1');
my @skipped;
my $countdone=0;
foreach my $grade (@gradedata) {
my %entries=&Apache::loncommon::record_sep($grade);
my $username=$entries{$fields{'username'}};
my $domain=$entries{$fields{'domain'}};
- if (!exists($classlist{"$username:$domain"})) {
+ if (!exists($$classlist{"$username:$domain"})) {
push(@skipped,"$username:$domain");
next;
}
@@ -944,11 +1553,15 @@ sub handler {
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
if ($command eq 'submission') {
&listStudents($request) if ($ENV{'form.student'} eq '');
- $request->print(&submission($request)) if ($ENV{'form.student'} ne '');
+ &submission($request,0,0) if ($ENV{'form.student'} ne '');
+ } elsif ($command eq 'processGroup') {
+ &processGroup($request);
} elsif ($command eq 'gradingmenu') {
$request->print(&gradingmenu($request));
} elsif ($command eq 'viewgrades') {
$request->print(&viewgrades($request));
+ } elsif ($command eq 'handgrade') {
+ $request->print(&processHandGrade($request));
} elsif ($command eq 'editgrades') {
$request->print(&editgrades($request));
} elsif ($command eq 'verify') {
@@ -957,8 +1570,8 @@ sub handler {
$request->print(&csvupload($request));
} elsif ($command eq 'csvuploadmap') {
$request->print(&csvuploadmap($request));
- } elsif ($command eq 'receiptInput') {
- &receiptInput($request);
+# } elsif ($command eq 'receiptInput') {
+# &receiptInput($request);
} elsif ($command eq 'csvuploadassign') {
if ($ENV{'form.associate'} ne 'Reverse Association') {
$request->print(&csvuploadassign($request));