--- loncom/homework/grades.pm 2003/07/18 20:14:35 1.119
+++ loncom/homework/grades.pm 2003/07/22 18:59:57 1.122
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.119 2003/07/18 20:14:35 ng Exp $
+# $Id: grades.pm,v 1.122 2003/07/22 18:59:57 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -123,23 +123,25 @@ sub showResourceInfo {
my $result ='
'.
'
Current Resource: '.$probTitle.'
'."\n";
my ($partlist,$handgrade) = &response_type($url);
- my ($resptype,$hdgrade)=('','no');
+ my %resptype = (); #,$hdgrade)=('','no');
+ my $hdgrade='no';
for (sort keys(%$handgrade)) {
my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
- $resptype = $responsetype;
+ my $partID = (split(/_/))[0];
+ $resptype{$partID} = $responsetype;
$hdgrade = $handgrade if ($handgrade eq 'yes');
- $result.='
Part '.(split(/_/))[0].'
'.
+ $result.='
Part '.$partID.'
'.
'
Type: '.$responsetype.'
';
# '
Handgrade: '.$handgrade.'
';
}
$result.='
'."\n";
- return $result,$resptype,$hdgrade,$partlist,$handgrade;
+ return $result,\%resptype,$hdgrade,$partlist,$handgrade;
}
#--- Clean response type for display
#--- Currently filters option response type only.
sub cleanRecord {
- my ($answer,$response) = @_;
+ my ($answer,$response,$symb) = @_;
if ($response eq 'option') {
my (@IDs,@ans);
foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
@@ -155,6 +157,21 @@ sub cleanRecord {
(join '
'.$grayFont,@IDs).'
'.
'';
}
+ if ($response eq 'essay') {
+ if (! exists ($ENV{'form.'.$symb})) {
+ my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
+ $ENV{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
+ $ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
+ $ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
+ $ENV{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
+ }
+ return &keywords_highlight($answer);
+ }
return $answer;
}
@@ -197,6 +214,7 @@ COMMONJSFUNCTIONS
#--- section, ids and fullnames for each user.
sub getclasslist {
my ($getsec,$filterlist) = @_;
+ $getsec = $getsec eq '' ? 'all' : $getsec;
my $classlist=&Apache::loncoursedata::get_classlist();
# Bail out if we were unable to get the classlist
return if (! defined($classlist));
@@ -430,7 +448,7 @@ sub listStudents {
my $result='
'.$viewgrade.
' Submissions for a Student or a Group of Students
';
- my ($table,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
$result.=$table;
$request->print(< last sub only'."\n".
' last sub & parts info'."\n".
+ ' by dates and submissions'."\n".
' all details'."\n".
''."\n".
''."\n".
- ''."\n".
' '."\n".
' '."\n".
''."\n".
@@ -707,9 +725,10 @@ sub sub_page_js {
}
function checkSolved(formname,id) {
- if (eval("formname.solved"+id+".value") == "correct_by_student") {
+ if (eval("formname.solved"+id+".value") == "correct_by_student" && formname.overRideScore.value == 'no') {
var reply = confirm("This problem has been graded correct by the computer. Do you want to change the score?");
if (!reply) {return "noupdate";}
+ formname.overRideScore.value = 'yes';
}
return "update";
}
@@ -720,9 +739,9 @@ sub sub_page_js {
return;
}
-//=========== Check that a point is assigned for all the parts (essay grading only) ============
+//=========== Check that a point is assigned for all the parts ============
function checksubmit(formname,val,total,parttot) {
- document.SCORE.gradeOpt.value = val;
+ formname.gradeOpt.value = val;
if (val == "Save & Next") {
for (i=0;i<=total;i++) {
for (j=0;j
//===================== Show list of keywords ====================
- function keywords(keyform) {
- var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value);
+ function keywords(formname) {
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value);
if (nret==null) return;
- keyform.value = nret;
+ formname.keywords.value = nret;
- document.SCORE.refresh.value = "on";
- if (document.SCORE.keywords.value != "") {
- document.SCORE.submit();
+ formname.refresh.value = "on";
+ if (formname.keywords.value != "") {
+ formname.submit();
}
return;
}
@@ -1160,6 +1186,7 @@ sub submission {
(my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
my ($uname,$udom) = ($ENV{'form.student'},$ENV{'form.userdom'});
+ $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 '';
@@ -1173,7 +1200,10 @@ sub submission {
return;
}
+ $ENV{'form.lastSub'} = ($ENV{'form.lastSub'} eq '' ? 'datesub' : $ENV{'form.lastSub'});
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
+ my $checkIcon = '';
# header info
if ($counter == 0) {
@@ -1186,8 +1216,6 @@ sub submission {
' Resource: '.$ENV{'form.probTitle'}.''."\n");
if ($ENV{'form.handgrade'} eq 'no') {
- my $checkIcon = '';
my $checkMark='
Note: Part(s) graded correct by the computer is marked with a '.
$checkIcon.' symbol.'."\n";
$request->print($checkMark);
@@ -1217,13 +1245,17 @@ sub submission {
$ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
}
+ my $overRideScore = $ENV{'form.overRideScore'} eq '' ? 'no' : $ENV{'form.overRideScore'};
$request->print(''."\n");
- $request->print(&show_grading_menu_form($symb,$url))
+ my $toGrade.=' '."\n" if (&canmodify($usec));
+ $toGrade.=''."\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;
}
- $result=''."\n".
- ''."\n".
- ''."\n";
- # essay grading options
+ # essay grading message center
if ($ENV{'form.handgrade'} eq 'yes') {
my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
my $msgfor = $givenn.' '.$lastname;
@@ -1450,6 +1487,8 @@ KEYWORDS
}
$msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
# $result.='
'."\n".
+ $result=''."\n".
+ ''."\n";
$result.=' '.
'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').' '.
@@ -1457,8 +1496,8 @@ KEYWORDS
'/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".
' (Message will be sent when you click on Save & Next below.)'."\n"
if ($ENV{'form.handgrade'} eq 'yes');
+ $request->print($result);
}
- $request->print($result);
my %seen = ();
my @partlist;
@@ -1483,8 +1522,7 @@ KEYWORDS
# print end of form
if ($counter == $total) {
- my $endform='
'.
- ''."\n";
+ my $endform='
'."\n";
$endform.=' '."\n";
@@ -1554,7 +1592,6 @@ 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) {
@@ -1648,7 +1685,6 @@ sub processHandGrade {
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
}
# Called by Save & Refresh from Highlight Attribute Window
-# my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
if ($ENV{'form.refresh'} eq 'on') {
my ($ctr,$total) = (0,0);
@@ -1668,6 +1704,16 @@ sub processHandGrade {
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)};
@@ -1768,7 +1814,7 @@ sub saveHandGrade {
}
$newrecord{'resource.'.$_.'.submitted_by'} = $submitter
if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
- $newrecord{'resource.'.$_.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
}
}
@@ -2047,7 +2093,7 @@ sub viewgrades {
my (@parts) = sort(&getpartlist($url));
foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
- next if ($display =~ /Number of Attempts/);
+ $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);
@@ -2119,13 +2165,13 @@ sub viewstudentgrade {
if ($status eq 'excused');
$result.=$optsel;
$result.="
';
@@ -2249,7 +2295,7 @@ 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'}";
+ $newrecord{'resource.'.$part.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
$updateflag=1;
}
$line .= '
'.$old_aw.'
'.
@@ -2378,7 +2424,7 @@ sub csvuploadmap_header {
$javascript=&csvupload_javascript_forward_associate();
}
- my ($result,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ my ($result) = &showResourceInfo($url,$ENV{'form.probTitle'});
$request->print(<
@@ -2590,7 +2636,7 @@ sub csvuploadassign {
#
#-------------------------------------------------------------------
#
-#-------------- Next few routines handles grading by page/sequence
+#-------------- Next few routines handle grading by page/sequence
#
#--- Select a page/sequence and a student to grade
sub pickStudentPage {
@@ -2649,7 +2695,7 @@ LISTJAVASCRIPT
$result.=' Submission Details: '.
' none'."\n".
- ' dates and submissions'."\n".
+ ' by dates and submissions'."\n".
' all details'."\n";
$result.=''."\n".
@@ -2779,7 +2825,8 @@ sub displayPage {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
if($curRes == $iterator->END_MAP) { $depth--; }
- if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
+# if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
+ if (ref($curRes) && $curRes->is_problem()) {
my $parts = $curRes->parts();
my $title = $curRes->compTitle();
my $symbx = $curRes->symb();
@@ -2809,7 +2856,7 @@ sub displayPage {
foreach my $partid (@{$parts}) {
$responseType{$partid} = $curRes->responseType($partid);
}
- $studentTable.= &displaySubByDates(\%record,$parts,\%responseType,$checkIcon);
+ $studentTable.= &displaySubByDates(\$symbx,\%record,$parts,\%responseType,$checkIcon);
}
} elsif ($ENV{'form.lastSub'} eq 'all') {
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
@@ -2844,7 +2891,7 @@ sub displayPage {
}
sub displaySubByDates {
- my ($record,$parts,$responseType,$checkIcon) = @_;
+ my ($symbx,$record,$parts,$responseType,$checkIcon) = @_;
my $studentTable='
'.
'
'.
'
Date/Time
'.
@@ -2853,6 +2900,8 @@ sub displaySubByDates {
my ($version);
my %mark;
$mark{'correct_by_student'} = $checkIcon;
+ return ' Nothing submitted - no attempts '
+ if (!exists($$record{'1:timestamp'}));
for ($version=1;$version<=$$record{'version'};$version++) {
my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
$studentTable.='
'.$timestamp.'
';
@@ -2860,17 +2909,16 @@ sub displaySubByDates {
my @displaySub = ();
foreach my $partid (@{$parts}) {
my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
- next if ($$record{"$version:resource.$partid.solved"} eq '');
+# next if ($$record{"$version:resource.$partid.solved"} eq '');
$displaySub[0].=(exists $$record{$version.':'.$matchKey[0]}) ?
'Part '.$partid.' '.
($$record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' :
'Trial '.$$record{"$version:resource.$partid.tries"}).' '.
- &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid}).' ' : '';
+ &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid},$$symbx).' ' : '';
$displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ?
'Part '.$partid.' '.
lc($$record{"$version:resource.$partid.award"}).' '.
$mark{$$record{"$version:resource.$partid.solved"}}.' ' : '';
-# $$record{"$version:resource.$partid.solved"}.' ' : '';
$displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ?
$$record{"$version:resource.$partid.regrader"}.' (Part: '.$partid.')' : '';
}
@@ -3385,7 +3433,7 @@ sub gradingmenu {
GRADINGMENUJS
&commonJSfunctions($request);
my $result='
Manual Grading/View Submission
';
- my ($table,$resptype,$hdgrade) = &showResourceInfo($url,$probTitle);
+ my ($table,undef,$hdgrade) = &showResourceInfo($url,$probTitle);
$result.=$table;
my (undef,$sections) = &getclasslist('all','0');
my $savedState = &savedState();
@@ -3397,7 +3445,6 @@ GRADINGMENUJS
$result.='