.*?(.*?) | (.*?)<\/td>/;
+ print "Submitted=$1: $2;";
+#
+ 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 %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+ my $score = ($record{'resource.0.awarded'} eq '' ? '' : $record{'resource.0.awarded'}*$wgt);
- $answer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
- $ENV{'request.course.id'});
- $result.=$answer;
- return $result;
+#
+# display grading options
+ $result=''.
+ ''."\n";
+ $result.='';
+ $request->print($result);
+#
+# print end of form
+ if ($counter == $total) {
+ my $endform.='';
+ $request->print($endform);
+ }
+ return '';
+}
+
+sub processHandGrade {
+ 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 $vProb = $ENV{'form.vProb'};
+# my $lastSub= $ENV{'form.lastSub'};
+
+ my (@parts) = sort(&getpartlist($url));
+
+ if ($button eq 'Save & Next') {
+ my $ctr = 0;
+ while ($ctr < $ENV{'form.NCT'}) {
+# my $pts = ($ENV{'form.GRADE_BOX'.$ctr} ne '' ? $ENV{'form.GRADE_BOX'.$ctr} : $ENV{'form.RADVAL'.$ctr});
+# my $wgt = $ENV{'form.WGT'.$ctr};
+# my $sel = $ENV{'form.GRADE_SEL'.$ctr};
+# my $score = $pts/$wgt if ($wgt != 0);
+ my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
+ &saveHandGrade($url,$symb,$uname,$udom,$ctr,@parts);
+# &saveHandGrade($url,$symb,$uname,$udom,$score,@parts);
+ $ctr++;
+ }
+ }
+ my $firststu = $ENV{'form.unamedom0'};
+ my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
+
+ #get classlist
+# my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
+ my ($classlist) = &getclasslist('all','0');
+
+ my (@nextlist,@prevlist);
+ my ($nextflg,$prevflg,$ctr,$ctprev) = (0,0,0,0);
+ foreach my $student ( sort(@{ $$classlist{'all'} }) ) {
+ my ($uname,$udom) = split(/:/,$student);
+ 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++;
+ }
+ }
+ 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 ($stuname,$domain) = split(/:/,$student);
+ 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;
+ }
+ }
+ }
+ 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);
+ }
+ 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);
+ return ($symb,$url);
+}
+
+sub show_grading_menu_form {
+ my ($symb,$url)=@_;
+ my $result.=''."\n";
+ return $result;
}
sub gradingmenu {
my ($request) = @_;
my ($symb,$url)=&get_symb_and_url($request);
if (!$symb) {return '';}
- my $result='Select a grading method ';
- $result.='';
+
+ my $result=' Select a Grading Method';
+ $result.=' Resource: '.$url.'
';
+
+ $result.=&view_edit_entire_class_form($symb,$url).' ';
+ $result.=&upcsvScores_form($symb,$url).' ';
+ $result.=&viewGradeaStu_form($symb,$url).' ';
+ $result.=&verifyReceipt_form($symb,$url);
+ return $result;
+}
+
+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) = @_;
+ 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;
}
@@ -368,14 +782,14 @@ 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"';
#get list of parts for this problem
- my (@parts) = &getpartlist($url);
+ my (@parts) = sort(&getpartlist($url));
- $request->print ("Manual Grading");
+ $request->print ("Manual Grading");
#start the form
$result = ' | ';
+ $result.='