[LON-CAPA-cvs] cvs: loncom /homework grades.pm
ng
lon-capa-cvs@mail.lon-capa.org
Thu, 18 Jul 2002 21:27:57 -0000
This is a MIME encoded message
--ng1027027677
Content-Type: text/plain
ng Thu Jul 18 17:27:57 2002 EDT
Modified files:
/loncom/homework grades.pm
Log:
handles handgrading of different types of problems
requires a modified classlist or else it is too slow
highlight option has a refresh button so a user can see the changes immediately
--ng1027027677
Content-Type: text/plain
Content-Disposition: attachment; filename="ng-20020718172757.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.38 loncom/homework/grades.pm:1.39
--- loncom/homework/grades.pm:1.38 Wed Jul 10 17:08:38 2002
+++ loncom/homework/grades.pm Thu Jul 18 17:27:57 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.38 2002/07/10 21:08:38 ng Exp $
+# $Id: grades.pm,v 1.39 2002/07/18 21:27:57 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,7 @@
use Apache::lonhomework;
use Apache::lonmsg qw(:user_normal_msg);
use Apache::Constants qw(:common);
-use Time::HiRes qw( gettimeofday tv_interval );
+#use Time::HiRes qw( gettimeofday tv_interval );
sub moreinfo {
my ($request,$reason) = @_;
@@ -96,26 +96,23 @@
}
sub student_gradeStatus {
- my ($url,$udom,$uname) = @_;
- my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
- my %record= &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
- 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/);
+ my ($url,$udom,$uname,$partlist) = @_;
+ my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
+ my %record= &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+ my %partstatus = ();
+ foreach (@$partlist) {
+ my ($status,$foo)=split(/_/,$record{"resource.$_.solved"},2);
$status = 'nothing' if ($status eq '');
- return $type,$status;
- }
- }
- return '';
+ $partstatus{$_} = $status;
+ }
+ return %partstatus;
}
sub get_fullname {
- my ($sname,$sdom) = @_;
+ my ($uname,$udom) = @_;
my %name=&Apache::lonnet::get('environment', ['lastname','generation',
'firstname','middlename'],
- $sdom,$sname);
+ $udom,$uname);
my $fullname;
my ($tmp) = keys(%name);
if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
@@ -126,6 +123,25 @@
return $fullname;
}
+sub response_type {
+ my ($url) = shift;
+ my $allkeys = &Apache::lonnet::metadata($url,'keys');
+ my %seen = ();
+ my (@partlist,%handgrade);
+ foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
+ if (/^\w+response_\d{1,2}.*/) {
+ my ($responsetype,$part) = split(/_/,$_,2);
+ my ($partid,$respid) = split(/_/,$part);
+ $handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no');
+ next if ($seen{$partid} > 0);
+ $seen{$partid}++;
+ push @partlist,$partid;
+ }
+ }
+ return \@partlist,\%handgrade;
+}
+
+
sub listStudents {
my ($request) = shift;
my $cdom =$ENV{"course.$ENV{'request.course.id'}.domain"};
@@ -133,25 +149,32 @@
my $getsec =$ENV{'form.section'};
my $submitonly=$ENV{'form.submitonly'};
+ my $result='<h2><font color="#339933"> View Submissions for a Student or a Group of Students</font></h2>';
+ $result.='<table border="0">';
+ $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font></td></tr>';
+ my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
+ for (sort keys(%$handgrade)) {
+ my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
+ $result.='<tr><td><b>Part id: </b>'.$_.'</td>'.
+ '<td><b>Type: </b>'.$responsetype.'</td>'.
+ '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
+ }
+ $result.='</table>';
+ $request->print($result);
+
$request->print(<<ENDTABLEST);
-<h2><font color="#339933"> View Submissions for a Student or a Group of Students</font></h2>
- <font size=+1><b>Resource:</b> $ENV{'form.url'}<br /><br />
-<form action="/adm/grades" method="post"> <b>View Options</b></font><br />
+<form action="/adm/grades" method="post">
<b>View Problem: </b><input type="radio" name="vProb" value="no" checked> no
<input type="radio" name="vProb" value="yes"> yes <br />
<b>Submissions: </b>
-<input type="radio" name="lastSub" value="lastonly" checked> last sub only
-<input type="radio" name="lastSub" value="last"> last sub & parts info
-<input type="radio" name="lastSub" value="all"> all details
-<input type="hidden" name="section" value="$getsec">
-<input type="hidden" name="submitonly" value="$submitonly">
-<input type="hidden" name="response" value="$ENV{'form.response'}">
-<input type="hidden" name="handgrade" value="$ENV{'form.handgrade'}">
-<table border="0"><tr><td bgcolor="#777777">
-<table border="0"><tr bgcolor="#e6ffff">
-<td><b> Select </b></td><td><b> Username </b></td>
-<td><b> Fullname </b></td><td><b> Domain </b></td>
-<td><b> Grade Status </b></td></tr>
+<input type="radio" name="lastSub" value="lastonly" checked /> last sub only
+<input type="radio" name="lastSub" value="last" /> last sub & parts info
+<input type="radio" name="lastSub" value="all" /> all details
+<input type="hidden" name="section" value="$getsec" />
+<input type="hidden" name="submitonly" value="$submitonly" />
+<input type="hidden" name="response" value="$ENV{'form.response'}" />
+<input type="hidden" name="handgrade" value="$ENV{'form.handgrade'}" />
+<input type="submit" name="submit" value="View/Grade" />
ENDTABLEST
if ($ENV{'form.url'}) {
$request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'."\n");
@@ -161,32 +184,40 @@
}
$request->print('<input type="hidden" name="command" value="processGroup" />'."\n");
- my $t0=&Time::HiRes::time();
+ my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');
- my ($classlist) = &getclasslist($getsec,'0');
- my $t1=&Time::HiRes::time();
- print "getclasslist=",$t1-$t0,"<br />";
-
- 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');
+ $result='<table border="0"><tr><td bgcolor="#777777">'.
+ '<table border="0"><tr bgcolor="#e6ffff">'.
+ '<td><b> Select </b></td><td><b> Username </b></td>'.
+ '<td><b> Fullname </b></td><td><b> Domain </b></td>';
+ foreach (sort(@$partlist)) {
+ $result.='<td><b> Part ID '.$_.' Status </b></td>';
+ }
+ $request->print($result.'</tr>'."\n");
+
+ foreach my $student (sort(@{ $$classlist{$getsec} }) ) {
+ my ($uname,$udom) = split(/:/,$student);
+ 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 '' && $submitonly eq 'yes');
- my $fullname = &get_fullname($sname,$sdom);
if ( $Apache::grades::viewgrades eq 'F' ) {
- $request->print("\n".'<tr bgcolor="#ffffe6">'.
- '<td align="center"><input type=checkbox name="stuinfo" value="'.
- $student.':'.$fullname.'"></td>'."\n".
- '<td> '.$sname.' </td>'."\n".
- '<td> '.$fullname.' </td>'."\n".
- '<td align="middle"> '.$sdom.' </td>'."\n");
- $request->print('<td align="middle"> '.$status.' </td>'."\n");
+ $result='<tr bgcolor="#ffffe6">'.
+ '<td align="center"><input type=checkbox name="stuinfo" value="'.
+ $student.':'.$$fullname{$student}.'"></td>'."\n".
+ '<td> '.$uname.' </td>'."\n".
+ '<td> '.$$fullname{$student}.' </td>'."\n".
+ '<td align="middle"> '.$udom.' </td>'."\n";
- $request->print('</tr>');
+ foreach (sort keys(%status)) {
+ $result.='<td align="middle"> '.$status{$_}.' </td>'."\n";
+ }
+ $request->print($result.'</tr>'."\n");
}
}
- my $t2=&Time::HiRes::time();
- print "processclasslist=",$t2-$t1,"<br />";
$request->print('</table></td></tr></table>');
$request->print('<input type="submit" name="submit" value="View/Grade" /><form />');
}
@@ -202,13 +233,13 @@
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 {
@@ -237,28 +268,32 @@
}
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 {
@@ -275,14 +310,13 @@
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.="<tr bgcolor=$cellclr><td>$username</td><td>$fullname</td><td align=\"middle\">$domain</td>\n";
+ my $result="<tr bgcolor=$cellclr><td>$username</td><td>$fullname</td><td align=\"middle\">$domain</td>\n";
foreach my $part (@parts) {
my ($temp,$part,$type)=split(/_/,$part);
my $score=$record{"resource.$part.$type"};
@@ -293,7 +327,7 @@
my ($status,$foo)=split(/_/,$score,2);
$result.="<td align=\"middle\"><select name=\"GRADE.$student.$part.$type\">\n";
my $optsel = '<option>correct</option><option>incorrect</option><option>excused</option>'.
- '<option>ungraded</option><option>partial</option><option>nothing</option>'."\n";
+ '<option>ungraded</option><option>nothing</option>'."\n";
$status = 'nothing' if ($status eq '');
$optsel =~ s/<option>$status/<option selected="on">$status/;
$result.=$optsel;
@@ -333,7 +367,7 @@
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:<br />\n";
}
@@ -392,7 +426,7 @@
$request->print($result);
}
- # kwclr is the only variable that is non blank if this has been used once.
+ # 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',
@@ -411,6 +445,7 @@
}
$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n".
'<input type="hidden" name="command" value="handgrade" />'."\n".
+ '<input type="hidden" name="refresh" value="off" />'."\n".
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
'<input type="hidden" name="url" value="'.$url.'" />'."\n".
'<input type="hidden" name="vProb" value="'.$ENV{'form.vProb'}.'" />'."\n".
@@ -453,16 +488,16 @@
my $fullname = ($ENV{'form.fullname'} ne '' ? $ENV{'form.fullname'} : &get_fullname($uname,$udom));
my $result.='<table border="0" width=100%><tr><td bgcolor="#777777">'.
'<table border="0" width=100%><tr bgcolor="#ffffff"><td>';
- $result.='<table border="0"><tr bgcolor="#ffffff"><td><b>Username: </b>'.$uname.
- '</td><td><b>Fullname: </b>'.$fullname.
- '</td><td><b>Domain: </b>'.$udom.'</td></tr>';
+ $result.='<table border="0"><tr bgcolor="#ffffff"><td><b>Fullname: </b>'.$fullname.
+ '</td><td> <b>Username: </b>'.$uname.
+ '</td><td> <b>Domain: </b>'.$udom.'</td></tr>';
if ($ENV{'form.handgrade'} eq 'yes') {
# my $subonly = &get_last_submission($symb,$uname,$udom,$ENV{'request.course.id'});
my ($classlist) = &getclasslist('all','0');
my @collaborators;
# foreach ( sort(@{ $$classlist{'all'} }) ) {
-# my ($sname,$sdom) = split(/:/);
-# push @collaborators,$sname if (grep /\b$sname(\b|\.)/i,$subonly);
+# my ($uname,$udom) = split(/:/);
+# push @collaborators,$uname if (grep /\b$uname(\b|\.)/i,$subonly);
# }
# push @collaborators,'leede','carlandmm','freyniks'; # as a test to display collaborators.
if (scalar(@collaborators) != 0) {
@@ -478,16 +513,30 @@
$result.='</table>'."\n";
$request->print($result);
+ my ($partlist,$handgrade) = &response_type($url);
+
# print student answer
if ($ENV{'form.lastSub'} eq 'lastonly') {
my ($string,$timestamp)=&get_last_submission ($symb,$uname,$udom,$ENV{'request.course.id'});
- $string=&keywords_highlight(join('::::',@$string));
my $lastsubonly='<table border="0" width=100%><tr><td bgcolor="#777777">';
$lastsubonly.='<table border="0" width=100%><tr bgcolor="#ddffff">';
$lastsubonly.='<td><b>Last Submission Only</b>'.
- ($timestamp eq '' ? '' : ' <b>Date Submitted:</b> '.@$timestamp).'</td></tr>';
- $lastsubonly.='<tr><td bgcolor="#ffffe6">';
- $lastsubonly.=$string;
+ ($$timestamp eq '' ? '' : ' <b>Date Submitted:</b> '.$$timestamp).'</td></tr>';
+ if ($$timestamp eq '') {
+ $lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0].'</td></tr>';
+ } else {
+ for my $part (sort keys(%$handgrade)) {
+ foreach (@$string) {
+ my ($partid,$respid) = /^resource\.(\d{1,2})\.(\d{1,2})\.submission/;
+ if ($part eq ($partid.'_'.$respid)) {
+ my ($ressub,$subval) = split(/:/,$_,2);
+ $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part ID</b> '.
+ $partid.' <b>Response ID</b> '.$respid.
+ ' <b>Submission</b> '.&keywords_highlight($subval).'</td></tr>';
+ }
+ }
+ }
+ }
$lastsubonly.='</td></tr></table></td></tr></table>'."\n";
$request->print($lastsubonly);
} else {
@@ -496,60 +545,67 @@
'.submission','Apache::grades::keywords_highlight'));
}
- my $wgt = &Apache::lonnet::EXT('resource.partid.weight',$symb,$udom,$uname);
- my $wgtmsg = ($wgt > 0 ? '(problem weight)' : '<font color="red">problem weight assigned by computer</font>');
- $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);
-
- # display grading options
- $result='<input type="hidden" name="WGT'.$counter.'" value="'.$wgt.'" />'.
+ $result='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n".
+ '<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
'<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'.$udom.'" />'."\n";
- $result.='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n";
- $result.='<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n";
- $result.='<table border="0"><tr><td><b>Points</b></td><td>';
-
- my $ctr = 0;
- $result.='<table border="0"><tr>'; # display radio buttons in a nice table with 10 across
- while ($ctr<=$wgt) {
- $result.= '<td><input type="radio" name="RADVAL'.$counter.'" '.
- 'onclick="javascript:writeBox(this.form.GRADE_BOX'.$counter.
- ',this.form.GRADE_SEL'.$counter.','.$ctr.','.$wgt.')" '.
- ($score eq $ctr ? 'checked':'').' /> '.$ctr."</td>\n";
- $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : '');
- $ctr++;
- }
- $result.='</tr></table>';
+ $result.=' <a href="javascript:msgCenter(document.SCORE,'.$counter.
+ ',\''.$fullname.'\')"; TARGET=_self>Compose Message</a><br />'."\n" if ($ENV{'form.handgrade'} eq 'yes');
+ $request->print($result);
- $result.='</td><td> <b>or</b> </td>';
- $result.='<td><input type="text" name="GRADE_BOX'.$counter.'"'.
- ($score ne ''? ' value = "'.$score.'"':'').' size="4" '.
- 'onChange="javascript:updateRadio(this.form.RADVAL'.$counter.
- ',this.form.GRADE_BOX'.$counter.
- ',this.form.GRADE_SEL'.$counter.',\''.$wgt.'\')" /></td>'."\n";
- $result.='<td>/'.$wgt.' '.$wgtmsg.' </td><td>';
+ my %seen = ();
+ my @partlist;
+ for (sort keys(%$handgrade)) {
+ my ($partid,$respid) = split(/_/);
+ next if ($seen{$partid} > 0);
+ $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)' : '<font color="red">problem weight assigned by computer</font>');
+ $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);
- foreach my $part (&getpartlist($url)) {
- print "parts=$part<br>";
- 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.='<select name="GRADE_SEL'.$counter.'">'."\n";
- my $optsel = '<option>correct</option><option>incorrect</option>'.
- '<option>excused</option><option>ungraded</option>'.
- '<option>partial</option><option>nothing</option>'."\n";
- $optsel =~ s/<option>$status/<option selected="on">$status/;
- $result.=$optsel;
- $result.="</select>  \n";
- }
+ # display grading options
+ $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />';
+
+ $result.='<table border="0"><tr><td><b>Part </b>'.$partid.' <b>Points</b></td><td>';
+
+ my $ctr = 0;
+ $result.='<table border="0"><tr>'; # display radio buttons in a nice table 10 across
+ while ($ctr<=$wgt) {
+ $result.= '<td><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '.
+ 'onclick="javascript:writeBox(this.form.GRADE_BOX'.$counter.'_'.$partid.
+ ',this.form.GRADE_SEL'.$counter.'_'.$partid.','.$ctr.
+ ',this.form.stores'.$counter.'_'.$partid.')" '.
+ ($score eq $ctr ? 'checked':'').' /> '.$ctr."</td>\n";
+ $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : '');
+ $ctr++;
+ }
+ $result.='</tr></table>';
+
+ $result.='</td><td> <b>or</b> </td>';
+ $result.='<td><input type="text" name="GRADE_BOX'.$counter.'_'.$partid.'"'.
+ ($score ne ''? ' value = "'.$score.'"':'').' size="4" '.
+ 'onChange="javascript:updateRadio(this.form.RADVAL'.$counter.'_'.$partid.
+ ',this.form.GRADE_BOX'.$counter.'_'.$partid.
+ ',this.form.GRADE_SEL'.$counter.'_'.$partid.
+ ',this.form.stores'.$counter.'_'.$partid.')" /></td>'."\n";
+ $result.='<td>/'.$wgt.' '.$wgtmsg.' </td><td>';
+
+ $result.='<select name="GRADE_SEL'.$counter.'_'.$partid.'" '.
+ 'onChange="javascript:clearRadBox(this.form.RADVAL'.$counter.'_'.$partid.
+ ',this.form.GRADE_BOX'.$counter.'_'.$partid.
+ ',this.form.GRADE_SEL'.$counter.'_'.$partid.
+ ',this.form.stores'.$counter.'_'.$partid.')" />'."\n".
+ '<option selected="on"> </option>'.
+ '<option>excused</option></select>'."  \n";
+ $result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="0" />';
+ $result.='</td></tr></table>';
+ $request->print($result);
}
- $result.='<a href="javascript:msgCenter(document.SCORE,'.$counter.
- ',\''.$fullname.'\')"; TARGET=_self>Compose Message</a></td></tr></table>'."\n";
-# $result.='</table>';
- $result.='</td></tr></table></td></tr></table>';
- $request->print($result);
+ $request->print('<input type="hidden" name="partlist'.$counter.'" value="'.(join ":",@partlist).'" />'."\n");
+ $request->print('</td></tr></table></td></tr></table>'."\n");
# print end of form
if ($counter == $total) {
@@ -574,26 +630,23 @@
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.':'.$_};
+ 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)) {
- print "lasthash key=$_<br>";
- if ($_ =~ /\.submission$/) {push @string, $_,$lasthash{$_}}
- if ($_ =~ /timestamp/) {push @timestamp, scalar(localtime($lasthash{$_}))};
-# if ($_ =~ /\.submission$/) {$string = $lasthash{$_}}
-# if ($_ =~ /timestamp/) {$timestamp=scalar(localtime($lasthash{$_}))};
- }
- }
- @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
- return \@string,\@timestamp;
+ 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;
}
}
@@ -604,7 +657,6 @@
(my $styleoff = $styleon) =~ s/\</\<\//;
my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
foreach (@keylist) {
- # next if ($_ eq '');
$string =~ s/\b$_(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi;
}
return $string;
@@ -621,7 +673,7 @@
my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
my %keyhash = ();
$ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
- $keyhash{$symb.'_handgrade'} = 'activated';
+ $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
$keyhash{$symb.'_keywords'} = $ENV{'form.keywords'};
$keyhash{$symb.'_subject'} = $ENV{'form.msgsub'};
$keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'};
@@ -652,13 +704,22 @@
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
- my (@parts) = sort(&getpartlist($url));
+ if ($ENV{'form.refresh'} eq 'on') {
+ my $ctr = 0;
+ while ($ctr < $ntstu) {
+ ($ENV{'form.student'},my $udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
+ &submission($request,$ctr,$ntstu-1);
+ $ctr++;
+ }
+ return '';
+ }
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);
+ my ($errorflg) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
+ return '' if ($errorflg eq 'error');
my $includemsg = $ENV{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
@@ -674,7 +735,7 @@
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);
}
@@ -688,23 +749,30 @@
my ($classlist) = &getclasslist($ENV{'form.section'},'0');
my (@nextlist,@prevlist);
- my ($nextflg,$prevflg,$ctr,$ctprev) = (0,0,0,0);
+ my ($nextflg,$ctr,$ctprev) = (0,0,0);
+ my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
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');
+ 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 '' && $ENV{'form.submitonly'} eq 'yes');
if ($nextflg == 1 && $button =~ /Next$/) {
push @nextlist,$uname if ($ctr < $ntstu);
$ctr++;
+ last if ($ctr == $ntstu);
}
$nextflg = 1 if ($student eq $laststu);
- $prevflg = 1 if ($student eq $firststu);
- if ($prevflg == 0 && $button eq 'Previous') {
+ if ($button eq 'Previous') {
+ last if ($student eq $firststu);
push @prevlist,$uname;
$ctprev++;
}
}
+
if ($button eq 'Previous') {
if ($ctprev <= $ntstu) {
@nextlist = @prevlist;
@@ -717,6 +785,7 @@
}
}
}
+
$ctr = 0;
my $total = scalar(@nextlist)-1;
foreach my $student (@nextlist) {
@@ -735,50 +804,35 @@
}
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:<br>\n";
-# }
-# print "symb=$symb,courseid=$ENV{'request.course.id'},dom=$domain,name=$stuname<br>";
+ while (my ($k,$v) = each %newrecord) {
+ print "k=$k:v=$v:<br>\n";
+ }
# &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},$domain,$stuname);
}
return '';
@@ -807,39 +861,70 @@
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'));
- $allkeys=~s/,/\<br\>/g;
-# print "allkeys=$allkeys<br><br>";
- $Apache::lonxml::debug=1;
- &Apache::lonxml::debug(join(':',&Apache::lonnet::metadata($url,'packages')));
- $Apache::lonxml::debug=0;
-
my $result='<h2> <font color="#339933">Select a Grading Method</font></h2>';
$result.='<table border="0">';
- $result.='<tr><td><font size=+1><b>Resource: </b></font></td>'.
- '<td><font size=+1>'.$url.'</font></td></tr>';
- $result.='<tr><td><font size=+1><b>Type: </b></font></td>'.
- '<td><font size=+1>'.$responsetype.' <b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
+ $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
+ 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.='<tr><td><b>Part id: </b>'.$_.'</td>'.
+ '<td><b>Type: </b>'.$responsetype.'</td>'.
+ '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
+ }
$result.='</table>';
- my $t0=&Time::HiRes::time();
$result.=&view_edit_entire_class_form($symb,$url).'<br />';
- my $t1=&Time::HiRes::time();
- print "elapsed10=",$t1-$t0,"<br />";
$result.=&upcsvScores_form($symb,$url).'<br />';
- my $t2=&Time::HiRes::time();
- print "elapsed21=",$t2-$t1,"<br />";
- $result.=&viewGradeaStu_form($symb,$url,$responsetype,$handgrade).'<br />';
- my $t3=&Time::HiRes::time();
- print "elapsed32=",$t3-$t2,"<br />";
- $result.=&verifyReceipt_form($symb,$url);
- my $t4=&Time::HiRes::time();
- print "elapsed43=",$t4-$t3,"<br />";
- print "Total elapsed time=",$t4-$t0,"<br />";
+ $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />';
+ $result.=&verifyReceipt_form($symb,$url).'<br />';
+ $result.=&view_classlist_form($symb,$url);
+
+ return $result;
+}
+
+sub view_classlist_form {
+ my ($symb,$url)=@_;
+ my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
+ $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
+ $result.=' <b>View Class List</b></td></tr>'."\n";
+ $result.='<tr bgcolor=#ffffe6><td>'."\n";
+ $result.='<form action="/adm/grades" method="post">'."\n".
+ '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
+ '<input type="hidden" name="url" value="'.$url.'" />'."\n".
+ '<input type="hidden" name="command" value="viewclasslist" />'."\n";
+ $result.=' <input type="submit" name="submit" value="View Class" /></form>'."\n";
+ $result.='</td></tr></table>'."\n";
+ $result.='</td></tr></table>'."\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('<table border=1>');
+ 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('<tr><td>'.$_.' </td><td><pre> '.$classlist{$_}.'</pre></td></tr>');
+ }
+ $request->print('</table>');
+# 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.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
@@ -883,16 +968,7 @@
sub viewGradeaStu_form {
my ($symb,$url,$response,$handgrade) = @_;
-
-
- my $t3=&Time::HiRes::time();
-
my ($classlist,$sections) = &getclasslist('all','0');
-
- my $t4=&Time::HiRes::time();
- print "elapsed_getclasslist=",$t4-$t3,"<br />";
-
-
my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
$result.=' <b>View/Grade an Individual Student\'s Submission</b></td></tr>'."\n";
@@ -905,8 +981,8 @@
'<input type="hidden" name="command" value="submission" />'."\n";
$result.=' <b>Select section:</b> <select name="section">'."\n";
- foreach my $section (sort (@$sections)) {
- $result.= '<option>'.$section.'</option>'."\n";
+ foreach (sort (@$sections)) {
+ $result.= '<option>'.$_.'</option>'."\n";
}
$result.= '<option selected="on">all</select>'."\n";
$result.=' <b>Display students who has: </b>'.
@@ -1027,7 +1103,7 @@
my $request = shift;
$request->print(<<SUBJAVASCRIPT);
<script type="text/javascript" language="javascript">
- function updateRadio(radioButton,formtextbox,formsel,wgt) {
+ function updateRadio(radioButton,formtextbox,formsel,scores) {
var pts = formtextbox.value;
var resetbox =false;
if (isNaN(pts) || pts < 0) {
@@ -1050,28 +1126,37 @@
radioButton[i].checked=true;
}
}
- updateSelect(formsel,pts,wgt);
+ updateSelect(formsel);
+ scores.value = "0";
}
- function writeBox(formrad,formsel,pts,wgt) {
+ function writeBox(formrad,formsel,pts,scores) {
formrad.value = pts;
- updateSelect(formsel,pts,wgt);
+ scores.value = "0";
+ updateSelect(formsel,pts);
return;
}
- function updateSelect(formsel,pts,wgt) {
- if (pts == 0) {
- formsel[1].selected = true;
- }
- if (pts > 0 && pts < wgt) {
- formsel[4].selected = true;
+ function clearRadBox(radioButton,formbox,formsel,scores) {
+ for (var i=0; i<formsel.length; i++) {
+ if (formsel[i].selected) {
+ var selectx=i;
+ }
}
- if (pts == wgt) {
- formsel[0].selected = true;
+ if (selectx == scores.value) { return };
+ formbox.value = "";
+ for (var i=0; i<radioButton.length; i++) {
+ radioButton[i].checked=false;
}
+ scores.value = selectx;
+ }
+
+ function updateSelect(formsel) {
+ formsel[0].selected = true;
return;
}
+//===================== Show list of keywords ====================
function keywords(keyform) {
var keywds = keyform.value;
var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds);
@@ -1202,7 +1287,7 @@
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
pWin.document.write("<td align=\\"center\\">New</td>");
pWin.document.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
- pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" value=\\""+newmsg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");
+ pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" value=\\""+newmsg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");
}
function msgTail() {
@@ -1252,10 +1337,14 @@
hwdWin.document.write("<title>Highlight Central</title>");
hwdWin.document.write("<script language=javascript>");
- hwdWin.document.write("function updateChoice() {");
+ hwdWin.document.write("function updateChoice(flag) {");
hwdWin.document.write(" opener.document.SCORE.kwclr.value = radioSelection(document.hlCenter.kwdclr);");
hwdWin.document.write(" opener.document.SCORE.kwsize.value = radioSelection(document.hlCenter.kwdsize);");
hwdWin.document.write(" opener.document.SCORE.kwstyle.value = radioSelection(document.hlCenter.kwdstyle);");
+ hwdWin.document.write(" if (flag==1){");
+ hwdWin.document.write(" opener.document.SCORE.refresh.value = \\"on\\";");
+ hwdWin.document.write(" opener.document.SCORE.submit();");
+ hwdWin.document.write(" }");
hwdWin.document.write(" self.close()");
hwdWin.document.write("}");
@@ -1296,7 +1385,8 @@
function highlightend() {
hwdWin.document.write("</table>");
hwdWin.document.write("</td></tr></table> ");
- hwdWin.document.write("<input type=\\"button\\" value=\\"Set Options\\" onClick=\\"javascript:updateChoice()\\"> ");
+ hwdWin.document.write("<input type=\\"button\\" value=\\"Refresh\\" onClick=\\"javascript:updateChoice(1)\\"> ");
+ hwdWin.document.write("<input type=\\"button\\" value=\\"Set Options\\" onClick=\\"javascript:updateChoice(0)\\"> ");
hwdWin.document.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br><br>");
hwdWin.document.write("</form>");
hwdWin.document.write("</body></html>");
@@ -1621,6 +1711,8 @@
$request->print(&verifyreceipt($request));
} elsif ($command eq 'csvupload') {
$request->print(&csvupload($request));
+ } elsif ($command eq 'viewclasslist') {
+ $request->print(&viewclasslist($request));
} elsif ($command eq 'csvuploadmap') {
$request->print(&csvuploadmap($request));
# } elsif ($command eq 'receiptInput') {
--ng1027027677--