'.
''.
@@ -478,91 +456,175 @@ 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 = "";
+ 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
+}
- }
- document.SCORE.submit();
- }
+#--- javascript for essay type problem --
+sub sub_page_kw_js {
+ my $request = shift;
+ $request->print(<
//===================== Show list of keywords ====================
function keywords(keyform) {
@@ -697,21 +759,21 @@ sub sub_page_js {
pWin.document.write("");
pWin.document.write("Subject ");
pWin.document.write(" ");
- pWin.document.write(" ");
+ pWin.document.write(" ");
}
function displaySavedMsg(ctr,msg,shwsel) {
pWin.document.write("");
pWin.document.write(""+ctr+" ");
pWin.document.write(" ");
- pWin.document.write(" ");
+ pWin.document.write(" ");
}
function newMsg(newmsg,shwsel) {
pWin.document.write("");
pWin.document.write("New ");
pWin.document.write(" ");
- pWin.document.write(" ");
+ pWin.document.write(" ");
}
function msgTail() {
@@ -820,6 +882,90 @@ function displaySavedMsg(ctr,msg,shwsel)
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,$viewon) = @_;
+ my $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'});
+ if ($removeform) {
+ $companswer=~s|||g;
+ $rendered=~s|name="submit"|name="would_have_been_submit"|g;
+ }
+ my $result.='';
+ $result.='';
+ $result.=' View of the problem - '.$ENV{'form.fullname'}.
+ ' ' if ($viewon);
+ $result.=''.$rendered.' ';
+ $result.='Correct answer: '.$companswer;
+ $result.='
';
+ $result.='
';
+ return $result;
+# $request->print($result);
+}
# --------------------------- show submissions of a student, option to grade
sub submission {
@@ -835,30 +981,20 @@ sub submission {
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' : '');
- $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';
- my ($classlist,$seclist,$ids,$stusec,$fullname);
+# $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';
# header info
if ($counter == 0) {
&sub_page_js($request);
+ &sub_page_kw_js($request);
$request->print(' Submission Record '."\n".
- ' Resource: '.$url.' '."\n");
+ ' Problem: '.
+ &Apache::lonnet::metadata($url,'title').' '."\n");
# 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.=' View of the problem - '.$ENV{'form.fullname'}.
- ' '.$rendered.' ';
- $result.='Correct answer: '.$companswer;
- $result.='
';
- $result.='
';
- $request->print($result);
+ if ($ENV{'form.vProb'} eq 'yes' or !$ENV{'form.vProb'}) {
+ $request->print(&show_problem($request,$symb,$uname,$udom,0,1));
}
# kwclr is the only variable that is guaranteed to be non blank
@@ -921,6 +1057,11 @@ KEYWORDS
}
}
+ if ($ENV{'form.vProb'} eq 'all') {
+ $request->print(' ') if ($counter > 0);
+ $request->print(&show_problem($request,$symb,$uname,$udom,1,1));
+ }
+
my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
my ($partlist,$handgrade) = &response_type($url);
@@ -937,49 +1078,61 @@ KEYWORDS
# If this is handgraded, then check for collaborators
my @col_fullnames;
+ my ($classlist,$fullname);
if ($ENV{'form.handgrade'} eq 'yes') {
my @col_list;
- ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');
+ ($classlist,undef,$fullname) = &getclasslist('all','0');
for (keys (%$handgrade)) {
my $ncol = &Apache::lonnet::EXT('resource.'.$_.
- '.maxcollaborators',$symb,$udom,$uname);
- if ($ncol > 0) {
- s/\_/\./g;
- if ($record{'resource.'.$_.'.collaborators'} ne '') {
- my (@collaborators) = split(/,?\s+/,
- $record{'resource.'.$_.'.collaborators'});
- my (@badcollaborators);
- if (scalar(@collaborators) != 0) {
- $result.='Collaborators: ';
- foreach my $collaborator (@collaborators) {
- $collaborator = $collaborator =~ /\@|:/ ?
- (split(/@|:/,$collaborator))[0] : $collaborator;
- next if ($collaborator eq $uname);
- if (!grep /^$collaborator:/i,keys %$classlist) {
- push @badcollaborators,$collaborator;
- next;
- }
- push @col_list, $collaborator;
- my ($lastname,$givenn) = split(/,/,$$fullname{$collaborator.':'.$udom});
- push @col_fullnames, $givenn.' '.$lastname;
- $result.=$$fullname{$collaborator.':'.$udom}.' ';
- }
- $result.=' '."\n";
- $result.=''.
- 'This student has submitted '.
- (scalar (@badcollaborators) > 1 ? '' : 'an').
- ' invalid collaborator'.(scalar (@badcollaborators) > 1 ? 's. ' : '. ').
- (join ', ',@badcollaborators).'
'
- if (scalar(@badcollaborators) > 0);
-
- $result.=''.
- 'This student has submitted too many collaborators. Maximum is '.
- $ncol.'.
' if (scalar(@collaborators) > $ncol);
- $result.=' '."\n";
- }
- }
- }
+ '.maxcollaborators',
+ $symb,$udom,$uname);
+ next if ($ncol <= 0);
+ s/\_/\./g;
+ next if ($record{'resource.'.$_.'.collaborators'} eq '');
+ my (@collaborators) = split(/,?\s+/,
+ $record{'resource.'.$_.'.collaborators'});
+ my (@badcollaborators);
+ if (scalar(@collaborators) != 0) {
+ $result.='Collaborators: ';
+ foreach my $collaborator (@collaborators) {
+ my ($co_name,$co_dom) = split /\@|:/,$collaborator;
+ $co_dom = $udom if (! defined($co_dom));
+ next if ($co_name eq $uname && $co_dom eq $udom);
+ # Doing this grep allows 'fuzzy' specification
+ my @Matches = grep /^$co_name:$co_dom/i,
+ keys %$classlist;
+ if (! scalar(@Matches)) {
+ push @badcollaborators,$collaborator;
+ next;
+ }
+ push @col_list, @Matches;
+ foreach (@Matches) {
+ my ($lastname,$givenn) = split(/,/,$$fullname{$_});
+ push @col_fullnames, $givenn.' '.$lastname;
+ $result.=$$fullname{$_}.' ';
+ }
+ }
+ $result.=' '."\n";
+ if (scalar(@badcollaborators) > 0) {
+ $result.='';
+ $result.='This student has submitted ';
+ if (scalar(@badcollaborators) == 1) {
+ $result .= 'an invalid collaborator';
+ } else {
+ $result .= 'invalid collaborators';
+ }
+ $result .= ': '.join(', ',@badcollaborators);
+
+ }
+ if (scalar(@collaborators > $ncol)) {
+ $result .= '';
+ $result .= 'This student has sumbitted too many '.
+ 'collaborators. Maximum is '.$ncol;
+ $result .= '
';
+ }
+ $result.=' '."\n";
+ }
}
}
$request->print($result."\n");
@@ -1002,7 +1155,7 @@ KEYWORDS
} else {
my ($string,$timestamp)=
&get_last_submission (%record);
- my $lastsubonly.=''.
+ my $lastsubonly=''.
($$timestamp eq '' ? '' : 'Date Submitted: '.
$$timestamp).'';
if ($$timestamp eq '') {
@@ -1015,7 +1168,12 @@ KEYWORDS
my ($ressub,$subval) = split(/:/,$_,2);
$lastsubonly.=' Part '.
$partid.' ( ID '.$respid.
- ' ) Answer: '.
+ ' ) '.
+ ($record{"resource.$partid.$respid.uploadedurl"}?
+ ' File uploaded by student Like all files provided by users, this file may contain virusses ':'').
+ 'Answer: '.
&keywords_highlight($subval).' '."\n"
if ($ENV{'form.lastSub'} eq 'lastonly' ||
($ENV{'form.lastSub'} eq 'hdgrade' &&
@@ -1067,48 +1225,10 @@ KEYWORDS
$seen{$partid}++;
next if ($$handgrade{$_} =~ /:no$/);
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($result);
}
$result=' '."\n";
@@ -1126,7 +1246,7 @@ KEYWORDS
' '."\n";
if ($ENV{'form.handgrade'} eq 'yes') {
$endform.=' '."\n";
my $ntstu =''.
'1 2 '.
@@ -1139,9 +1259,9 @@ KEYWORDS
$endform.=' '."\n";
}
$endform.=' '."\n".
+ 'onClick="javascript:checksubmit(this.form,\'Next\');" TARGET=_self> '."\n".
' ';
+ 'onClick="javascript:checksubmit(this.form,\'Previous\');" TARGET=_self> ';
$endform.='(Next and Previous do not save the scores.)'."\n"
if ($ENV{'form.handgrade'} eq 'yes');
$endform.='
';
@@ -1161,9 +1281,9 @@ sub get_last_submission {
for ($version=1;$version<=$returnhash{'version'};$version++) {
foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
$lasthash{$_}=$returnhash{$version.':'.$_};
- if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
+# if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
$timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
- }
+# }
}
}
foreach ((keys %lasthash)) {
@@ -1187,8 +1307,13 @@ sub keywords_highlight {
(my $styleoff = $styleon) =~ s/\\<\//;
my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
foreach (@keylist) {
- $string =~ s/\b$_(\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;
}
@@ -1206,10 +1331,14 @@ sub processHandGrade {
while ($ctr < $ngrade) {
my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
+ if ($errorflag eq 'no_score') {
+ $ctr++;
+ next;
+ }
my $includemsg = $ENV{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
- if ($includemsg =~ /savemsg|new$ctr/) {
+ if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
$subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);
my (@msgnum) = split(/,/,$includemsg);
foreach (@msgnum) {
@@ -1297,7 +1426,7 @@ sub processHandGrade {
$laststu = $firststu if ($ctr > $ngrade);
}
- my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
+ 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) {
@@ -1359,12 +1488,17 @@ sub saveHandGrade {
my %newrecord;
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
- $newrecord{'resource.'.$_.'.solved'} = 'excused'
- if ($record{'resource.'.$_.'.solved'} ne 'excused');
+ if ($record{'resource.'.$_.'.solved'} ne 'excused') {
+ $newrecord{'resource.'.$_.'.solved'} = 'excused';
+ if (exists($record{'resource.'.$_.'.awarded'})) {
+ $newrecord{'resource.'.$_.'.awarded'} = '';
+ }
+ }
} else {
my $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 '');
my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
$ENV{'form.WGT'.$newflg.'_'.$_};
my $partial= $pts/$wgt;
@@ -1573,7 +1707,8 @@ sub viewgrades {
my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'});
my $result='Manual Grading ';
- $result.='Resource: '.$ENV{'form.url'}.' '."\n";
+ $result.='Problem: '.&Apache::lonnet::metadata($ENV{'form.url'},'title')
+ .' '."\n";
#view individual student submission form - called using Javascript viewOneStudent
$result.=&jscriptNform($url,$symb);
@@ -1636,7 +1771,7 @@ sub viewgrades {
$weight{$partid}.' (problem weight)'."\n";
$result.= ' '.
+ $weight{$partid}.')"> '.
' '.
'excused '."\n";
$ctsparts++;
@@ -1678,7 +1813,7 @@ sub viewgrades {
#get info for each student
#list all the students - with points and grade status
- my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
+ my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
my $ctr = 0;
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
my ($uname,$udom) = split(/:/);
@@ -1704,8 +1839,8 @@ sub viewstudentgrade {
''.$fullname.' '.
''.$uname.' '.$udom.' '."\n";
- foreach my $part (@$parts) {
- my ($part,$type) = &split_part_type($part);
+ 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};
@@ -1749,7 +1884,8 @@ sub editgrades {
my $symb=$ENV{'form.symb'};
my $url =$ENV{'form.url'};
my $title='Current Grade Status ';
- $title.='Resource: '.$ENV{'form.url'}.' '."\n";
+ $title.='Problem: '.
+ &Apache::lonnet::metadata($ENV{'form.url'},'title').' '."\n";
$title.='Section: '.$ENV{'form.section'}.' '."\n";
$title.= &show_grading_menu_form ($symb,$url);
my $result= ''."\n";
@@ -1763,7 +1899,7 @@ sub editgrades {
'ungraded' =>'ungraded_attempted',
'nothing' => '',
);
- my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
+ my ($classlist,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
my (@partid);
my %weight = ();
@@ -1973,7 +2109,8 @@ sub csvuploadmap_header {
}
my $result='';
- $result.='Resource: '.$url.' ';
+ $result.='Problem: '.&Apache::lonnet::metadata($url,'title')
+ .' ';
my ($partlist,$handgrade) = &response_type($url);
my ($resptype,$hdgrade)=('','no');
for (sort keys(%$handgrade)) {
@@ -2157,7 +2294,8 @@ sub gradingmenu {
if (!$symb) {return '';}
my $result=' Select a Grading Method ';
$result.='';
- $result.='Resource: '.$url.' ';
+ $result.='Problem: '.
+ &Apache::lonnet::metadata($ENV{'form.url'},'title').' ';
my ($partlist,$handgrade) = &response_type($url);
my ($resptype,$hdgrade)=('','no');
for (sort keys(%$handgrade)) {
@@ -2172,6 +2310,7 @@ sub gradingmenu {
$result.=&view_edit_entire_class_form($symb,$url).' ';
$result.=&upcsvScores_form($symb,$url).' ';
$result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).' ';
+ $result.=&gradeByPage_form($symb,$url,$resptype,$hdgrade).' ';
$result.=&verifyReceipt_form($symb,$url)
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb));
@@ -2181,7 +2320,7 @@ sub gradingmenu {
#--- Menu for grading a section or the whole class ---
sub view_edit_entire_class_form {
my ($symb,$url)=@_;
- my ($classlist,$sections) = &getclasslist('all','0');
+ my ($classlist,$sections,undef) = &getclasslist('all','0');
my $result.=''."\n";
$result.=''."\n";
$result.=' Grade Entire Section or Class '."\n";
@@ -2243,12 +2382,7 @@ sub viewGradeaStu_form {
my $result.=''."\n";
$result.=''."\n";
$result.=' ';
- if ($handgrade eq 'yes') {
- $result.="View/Grade ";
- } else {
- $result.="View ";
- }
- $result.='an Individual Student\'s Submission '."\n";
+ $result.=($handgrade eq 'yes' ? 'View/Grade' : 'View').' an Individual Student\'s Submission'."\n";
$result.=''."\n";
$result.='