'.
- ''.
- ' Select Fullname '.
- ' Username Domain ';
- foreach (sort(@$partlist)) {
- $gradeTable.=' Part '.(split(/_/))[0].' Status ';
+ '';
+ my $loop = 0;
+ while ($loop < 2) {
+ $gradeTable.=' Select Fullname '.
+ '(Username) ';
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (sort(@$partlist)) {
+ $gradeTable.=' Part '.(split(/_/))[0].' Status ';
+ }
+ }
+ $loop++;
}
$gradeTable.=' '."\n";
my $ctr = 0;
foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
my ($uname,$udom) = split(/:/,$student);
- my (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
- my $statusflg = '';
- foreach (keys(%status)) {
- $statusflg = 1 if ($status{$_} ne 'nothing');
- my ($foo,$partid,$foo1) = split(/\./,$_);
- if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
- $statusflg = '';
- $gradeTable.=' ';
+ my %status = ();
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
+ my $statusflg = '';
+ foreach (keys(%status)) {
+ $statusflg = 1 if ($status{$_} ne 'nothing');
+ my ($foo,$partid,$foo1) = split(/\./,$_);
+ if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
+ $statusflg = '';
+ $gradeTable.=' ';
+ }
}
+ next if ($statusflg eq '' && $submitonly eq 'yes');
}
- next if ($statusflg eq '' && $submitonly eq 'yes');
$ctr++;
- if ( $Apache::grades::viewgrades eq 'F' ) {
- $gradeTable.=''.
- ' '."\n".
- ' '.$$fullname{$student}.' '."\n".
- ' '.$uname.' '."\n".
- ' '.$udom.' '."\n";
-
- foreach (sort keys(%status)) {
- next if (/^resource.*?submitted_by$/);
- $gradeTable.=' '.$status{$_}.' '."\n";
+ if ( $perm{'vgr'} eq 'F' ) {
+ $gradeTable.=' ' if ($ctr%2 ==1);
+ $gradeTable.=' '."\n".
+ ' '.$$fullname{$student}.' '."\n".
+ '('.$uname.') '."\n";
+
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (sort keys(%status)) {
+ next if (/^resource.*?submitted_by$/);
+ $gradeTable.=' '.$status{$_}.' '."\n";
+ }
}
- $gradeTable.=' '."\n";
+ $gradeTable.=''."\n" if ($ctr%2 ==0);
}
}
+ if ($ctr%2 ==1) {
+ $gradeTable.=' ';
+ if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (@$partlist) {
+ $gradeTable.=' ';
+ }
+ }
+ $gradeTable.='';
+ }
+
$gradeTable.='
'.
' '."\n";
if ($ctr == 0) {
- $gradeTable=' '.
- 'No submission found for this resource. ';
+ my $num_students=(scalar(keys(%$fullname)));
+ if ($num_students eq 0) {
+ $gradeTable=' There are no students currently enrolled. ';
+ } else {
+ $gradeTable=' '.
+ 'No submissions found for this resource for any students. ('.$num_students.
+ ' checked for submissions ';
+ }
} elsif ($ctr == 1) {
$gradeTable =~ s/type=checkbox/type=checkbox checked/;
}
@@ -453,96 +624,183 @@ 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
+}
+
+#--- javascript for essay type problem --
+sub sub_page_kw_js {
+ my $request = shift;
+ my $iconpath = $request->dir_config('lonIconsURL');
+ &commonJSfunctions($request);
+ $request->print(<
//===================== 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);
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value);
if (nret==null) return;
keyform.value = nret;
@@ -584,6 +842,12 @@ sub sub_page_js {
}
//====================== Script for composing message ==============
+ // preload images
+ img1 = new Image();
+ img1.src = "$iconpath/mailbkgrd.gif";
+ img2 = new Image();
+ img2.src = "$iconpath/mailto.gif";
+
function msgCenter(msgform,usrctr,fullname) {
var Nmsg = msgform.savemsgN.value;
savedMsgHeader(Nmsg,usrctr,fullname);
@@ -612,90 +876,105 @@ sub sub_page_js {
}
function savedMsgHeader(Nmsg,usrctr,fullname) {
- var height = 30*Nmsg+250;
+ var height = 70*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+',screenx=70,screeny=75,width=600,height='+height);
- pWin.document.write("");
- pWin.document.write("Message Central ");
-
- pWin.document.write("
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) = @_;
+ my ($request,$symb,$uname,$udom,$removeform,$viewon) = @_;
my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
$ENV{'request.course.id'});
if ($removeform) {
@@ -813,13 +1156,14 @@ sub show_problem {
$rendered=~s|name="submit"|name="would_have_been_submit"|g;
}
my $result.='';
- $result.='';
- $result.=' View of the problem - '.$ENV{'form.fullname'}.
- ' '.$rendered.' ';
+ $result.='';
+ $result.=' View of the problem - '.$ENV{'form.fullname'}.
+ ' ' if ($viewon);
+ $result.=''.$rendered.' ';
$result.='Correct answer: '.$companswer;
$result.='
';
$result.='
';
- $request->print($result);
+ return $result;
}
# --------------------------- show submissions of a student, option to grade
@@ -827,33 +1171,50 @@ sub submission {
my ($request,$counter,$total) = @_;
(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) = ($ENV{'form.student'},$ENV{'form.userdom'});
- ($uname,$udom) = &finduser($uname) if $udom eq '';
+ my $usec = &Apache::lonnet::getsection($udom,$uname,$ENV{'request.course.id'});
$ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq '';
-# 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 ''; }
+
+ if (!&canview($usec)) {
+ $request->print('Unable to view requested student.('.
+ $uname.$udom.$usec.$ENV{'request.course.id'}.') ');
+ $request->print(&show_grading_menu_form($symb,$url));
+ return;
+ }
+
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
-# $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) if ($ENV{'form.handgrade'} eq 'yes');
+ $ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ?
+ &Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'};
+
$request->print(' Submission Record '."\n".
- ' Resource: '.$url.' '."\n");
+ ' 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);
+ }
# 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') {
- &show_problem($request,$symb,$uname,$udom,0);
+ 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
# if this subroutine has been called once.
my %keyhash = ();
- if ($ENV{'form.kwclr'} eq '') {
+ if ($ENV{'form.kwclr'} eq '' && $ENV{'form.handgrade'} eq 'yes') {
%keyhash = &Apache::lonnet::dump('nohist_handgrade',
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
@@ -864,13 +1225,15 @@ sub submission {
$ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
$ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
$ENV{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
- $keyhash{$symb.'_subject'} : &Apache::lonnet::metadata($url,'title');
+ $keyhash{$symb.'_subject'} : $ENV{'form.probTitle'};
$ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
}
$request->print(''."\n");
+ $request->print(&show_grading_menu_form($symb,$url))
+ if (($ENV{'form.command'} eq 'submission') ||
+ ($ENV{'form.command'} eq 'processGroup' && $counter == $total));
return;
}
- # Grading options
- $result=' '."\n".
- ' '."\n".
- ' '."\n";
- my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
- my $msgfor = $givenn.' '.$lastname;
- if (scalar(@col_fullnames) > 0) {
- my $lastone = pop @col_fullnames;
- $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
- }
- $result.=' '."\n".
- ' '.
- 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').' '.
- ' (Message will be sent when you click on Save & Next below.)'."\n"
- if ($ENV{'form.handgrade'} eq 'yes');
- $request->print($result);
+ # essay grading options
+ if ($ENV{'form.handgrade'} eq 'yes') {
+ $result=' '."\n".
+ ' '."\n".
+ ' '."\n";
+ my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
+ my $msgfor = $givenn.' '.$lastname;
+ if (scalar(@col_fullnames) > 0) {
+ my $lastone = pop @col_fullnames;
+ $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
+ }
+ $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
+# $result.=' '."\n".
+ $result.=' '.
+ 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').' '.
+ ' '."\n".
+ ' (Message will be sent when you click on Save & Next below.)'."\n"
+ if ($ENV{'form.handgrade'} eq 'yes');
+ $request->print($result);
+ }
my %seen = ();
my @partlist;
@@ -1071,56 +1477,10 @@ KEYWORDS
my ($partid,$respid) = split(/_/);
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$_} =~ /:no$/);
+ next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/);
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(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
}
$result=' '."\n";
@@ -1136,9 +1496,9 @@ KEYWORDS
if ($counter == $total) {
my $endform='';
$endform.=&show_grading_menu_form($symb,$url);
$request->print($endform);
@@ -1173,9 +1533,7 @@ 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)$/) {
$timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
-# }
}
}
foreach ((keys %lasthash)) {
@@ -1222,8 +1580,16 @@ sub processHandGrade {
my $ctr = 0;
while ($ctr < $ngrade) {
my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
- my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
-
+ my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
+ if ($errorflag eq 'no_score') {
+ $ctr++;
+ next;
+ }
+ if ($errorflag eq 'not_allowed') {
+ $request->print("Not allowed to modify grades for $uname:$udom ");
+ $ctr++;
+ next;
+ }
my $includemsg = $ENV{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
@@ -1232,19 +1598,27 @@ sub processHandGrade {
foreach (@msgnum) {
$message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
}
- $message =~ s/\s+/ /g;
+ $message =&Apache::lonfeedback::clear_out_html($message);
+ $message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt;
+ $message.=" for $ENV{'form.probTitle'} ";
$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,
$ENV{'form.msgsub'},$message);
}
if ($ENV{'form.collaborator'.$ctr}) {
my (@collaborators) = split(/:/,$ENV{'form.collaborator'.$ctr});
foreach (@collaborators) {
- &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
- $ENV{'form.unamedom'.$ctr});
- if ($message ne '') {
- $msgstatus = &Apache::lonmsg::user_normal_msg ($_,$udom,
- $ENV{'form.msgsub'},
- $message);
+ my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,$ENV{'form.unamedom'.$ctr});
+ if ($errorflag eq 'not_allowed') {
+ $request->print("Not allowed to modify grades for $_:$udom ");
+ next;
+ } else {
+ if ($message ne '') {
+ $msgstatus = &Apache::lonmsg::user_normal_msg ($_,$udom,
+ $ENV{'form.msgsub'},
+ $message);
+ }
}
}
}
@@ -1293,12 +1667,20 @@ 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');
if ($ENV{'form.refresh'} eq 'on') {
- my $ctr = 0;
- $ENV{'form.NTSTU'}=$ngrade;
+ my ($ctr,$total) = (0,0);
while ($ctr < $ngrade) {
- ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$ENV{'form.unamedom'.$ctr});
- &submission($request,$ctr,$ngrade-1);
+ $total++ if $ENV{'form.unamedom'.$ctr} ne '';
+ $ctr++;
+ }
+ $ENV{'form.NTSTU'}=$ngrade;
+ $ctr = 0;
+ while ($ctr < $total) {
+ my $processUser = $ENV{'form.unamedom'.$ctr};
+ ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser);
+ $ENV{'form.fullname'} = $$fullname{$processUser};
+ &submission($request,$ctr,$total-1);
$ctr++;
}
return '';
@@ -1314,7 +1696,6 @@ sub processHandGrade {
$laststu = $firststu if ($ctr > $ngrade);
}
- 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) {
@@ -1354,8 +1735,6 @@ sub processHandGrade {
$ENV{'form.student'} = $uname;
$ENV{'form.userdom'} = $udom;
$ENV{'form.fullname'} = $$fullname{$_};
-# $ENV{'form.'.$_.':submitted_by'} = $submitter;
-# print "submitter=$ENV{'form.'.$_.':submitted_by'}= $submitter: ";
&submission($request,$ctr,$total);
$ctr++;
}
@@ -1372,8 +1751,12 @@ sub processHandGrade {
#---- Save the score and award for each student, if changed
sub saveHandGrade {
my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter) = @_;
- my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
- my %newrecord;
+ my $usec = &Apache::lonnet::getsection($domain,$stuname,
+ $ENV{'request.course.id'});
+ if (!&canmodify($usec)) { return('not_allowed'); }
+ my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
+ my %newrecord = ();
+ my ($pts,$wgt) = ('','');
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
if ($record{'resource.'.$_.'.solved'} ne 'excused') {
@@ -1383,10 +1766,11 @@ sub saveHandGrade {
}
}
} else {
- my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
- $ENV{'form.GD_BOX'.$newflg.'_'.$_} :
- $ENV{'form.RADVAL'.$newflg.'_'.$_});
- my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
+ $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 '');
+ $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
$ENV{'form.WGT'.$newflg.'_'.$_};
my $partial= $pts/$wgt;
$newrecord{'resource.'.$_.'.awarded'} = $partial
@@ -1401,15 +1785,15 @@ sub saveHandGrade {
}
$newrecord{'resource.'.$_.'.submitted_by'} = $submitter
if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
+ $newrecord{'resource.'.$_.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
}
}
if (scalar(keys(%newrecord)) > 0) {
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
&Apache::lonnet::cstore(\%newrecord,$symb,
$ENV{'request.course.id'},$domain,$stuname);
}
- return '';
+ return '',$pts,$wgt;
}
#--------------------------------------------------------------------------------------
@@ -1427,8 +1811,8 @@ sub viewgrades_js {
var textbox = eval("document.classgrade.TEXTVAL_"+partid);
if (point == "textval") {
var point = eval("document.classgrade.TEXTVAL_"+partid+".value");
- if (isNaN(point) || point < 0) {
- alert("A number equal or greater than 0 is expected. Entered value = "+point);
+ if (isNaN(point) || parseFloat(point) < 0) {
+ alert("A number equal or greater than 0 is expected. Entered value = "+parseFloat(point));
var resetbox = false;
for (var i=0; i weight) {
- var resp = confirm("You entered a value ("+point+
+ if (parseFloat(point) > parseFloat(weight)) {
+ var resp = confirm("You entered a value ("+parseFloat(point)+
") greater than the weight for the part. Accept?");
if (resp == false) {
textbox.value = "";
@@ -1451,7 +1835,7 @@ sub viewgrades_js {
}
for (var i=0; i weight) {
- var resp = confirm("You entered a value ("+point+
+ if (parseFloat(point) > parseFloat(weight)) {
+ var resp = confirm("You entered a value ("+parseFloat(point)+
") greater than the weight of the part. Accept?");
if (resp == false) {
textbox.value = "";
@@ -1594,7 +1978,7 @@ sub viewgrades {
my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'});
my $result='Manual Grading ';
- $result.='Resource: '.$ENV{'form.url'}.' '."\n";
+ $result.='Current Resource: '.$ENV{'form.probTitle'}.' '."\n";
#view individual student submission form - called using Javascript viewOneStudent
$result.=&jscriptNform($url,$symb);
@@ -1604,7 +1988,10 @@ sub viewgrades {
' '."\n".
' '."\n".
' '."\n".
- ' '."\n";
+ ' '."\n".
+ ' '."\n".
+ ' '."\n";
+
$result.='Assign Common Grade To ';
if ($ENV{'form.section'} eq 'all') {
$result.='Class ';
@@ -1615,12 +2002,6 @@ sub viewgrades {
}
$result.= ''."\n".
'';
-# $result.='To assign the same score for all the students use the radio buttons or '.
-# 'text box below. To assign scores individually fill in the score boxes for '.
-# 'each student in the table below. A part that has already '.
-# 'been graded does not get changed using the radio buttons or text box. '.
-# 'If needed, it has to be changed individually. ';
-# $result.=' ';
#radio buttons/text box for assigning points for a section or class.
#handles different parts of a problem
my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
@@ -1665,9 +2046,9 @@ sub viewgrades {
$result.='
'.'
'.'
'."\n".
' ';
$result.=' ';
- $result.=' '."\n";
+ 'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self>';
+# $result.=' '."\n";
#table listing all the students in a section/class
#header of table
@@ -1681,10 +2062,11 @@ sub viewgrades {
}
$result.= ''."\n".
''.
- 'Fullname Username Domain '."\n";
+ 'Fullname (Username) '."\n";
my (@parts) = sort(&getpartlist($url));
foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
+ next if ($display =~ /Number of Attempts/);
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
if ($display =~ /^Partial Credit Factor/) {
my ($partid) = &split_part_type($part);
@@ -1699,10 +2081,11 @@ sub viewgrades {
#get info for each student
#list all the students - with points and grade status
- my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');
+ my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
my $ctr = 0;
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
- my ($uname,$udom) = split(/:/);
+ my $uname = $_;
+ $uname=~s/:/_/;
$result.=' '."\n";
$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
$_,$$fullname{$_},\@parts,\%weight);
@@ -1712,6 +2095,11 @@ sub viewgrades {
$result.=' '."\n";
$result.=' '."\n";
+ if (scalar(%$fullname) eq 0) {
+ my $colspan=3+scalar(@parts);
+ $result='There are no students in section "'.$ENV{'form.section'}.
+ '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade. ';
+ }
$result.=&show_grading_menu_form($symb,$url);
return $result;
}
@@ -1720,42 +2108,43 @@ sub viewgrades {
sub viewstudentgrade {
my ($url,$symb,$courseid,$student,$fullname,$parts,$weight) = @_;
my ($uname,$udom) = split(/:/,$student);
+ $student=~s/:/_/;
my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
my $result=' '.
''.$fullname.' '.
- ' '.$uname.' '.$udom.' '."\n";
- foreach my $part (@$parts) {
- my ($part,$type) = &split_part_type($part);
+ '\')"; TARGET=_self>'.$fullname.' '.
+ '('.$uname.($ENV{'user.domain'} eq $udom ? '' : ':'.$udom).') '."\n";
+ 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};
$result.=' '."\n";
+ 'GD_'.$student.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n";
$result.=' '."\n";
} elsif ($type eq 'solved') {
my ($status,$foo)=split(/_/,$score,2);
$status = 'nothing' if ($status eq '');
- $result.=' '."\n";
$result.=''."\n";
+ 'GD_'.$student.'_'.$part.'_solved" '.
+ 'onChange="javascript:changeOneScore(\''.$part.'\',\''.$student.'\')" >'."\n";
my $optsel = ' excused '."\n";
$optsel = ' excused '."\n"
if ($status eq 'excused');
$result.=$optsel;
$result.=" \n";
- } else {
- $result.=' '.
- "\n";
- $result.=' '."\n";
+# } else {
+# $result.=' '.
+# "\n";
+# $result.=' '."\n";
}
}
$result.=' ';
@@ -1770,12 +2159,11 @@ sub editgrades {
my $symb=$ENV{'form.symb'};
my $url =$ENV{'form.url'};
my $title='Current Grade Status ';
- $title.='Resource: '.$ENV{'form.url'}.' '."\n";
+ $title.='Current Resource: '.$ENV{'form.probTitle'}.' '."\n";
$title.='Section: '.$ENV{'form.section'}.' '."\n";
- $title.= &show_grading_menu_form ($symb,$url);
my $result= ''."\n";
$result.= ''.
- 'Username Fullname '."\n";
+ 'Username Domain Fullname '."\n";
my %scoreptr = (
'correct' =>'correct_by_override',
@@ -1823,16 +2211,24 @@ sub editgrades {
$result .= ' ';
$result .= $header;
$result .= ' '."\n";
-
+ my $noupdate;
for ($i=0; $i<$ENV{'form.total'}; $i++) {
+ my $line;
my $user = $ENV{'form.ctr'.$i};
+ my $usercolon = $user;
+ $usercolon =~s/_/:/;
+ my ($uname,$udom)=split(/_/,$user);
my %newrecord;
my $updateflag = 0;
- my @userdom = grep /^$user:/,keys %$classlist;
- my (undef,$udom) = split(/:/,$userdom[0]);
-
- $result .= ''.$user.' '.
- $$fullname{$userdom[0]}.' ';
+ $line .= ''.$uname.' '.
+ $udom.' '.
+ $$fullname{$usercolon}.' ';
+ my $usec=$classlist->{"$uname:$udom"}[5];
+ if (!&canmodify($usec)) {
+ my $numcols=scalar(@partid)*(scalar(@parts)-1)*2;
+ $noupdate.=$line."Not allowed to modify student ";
+ next;
+ }
foreach (@partid) {
my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_awarded_s'};
my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
@@ -1852,7 +2248,7 @@ sub editgrades {
}
$score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_solved'} eq 'excused') &&
($score ne 'excused'));
- $result .= ''.$old_aw.' '.
+ $line .= ''.$old_aw.' '.
''.$awarded.
($score eq 'excused' ? $score : '').' ';
@@ -1872,21 +2268,29 @@ 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'}";
$updateflag=1;
}
- $result .= ''.$old_aw.' '.
+ $line .= ''.$old_aw.' '.
''.$awarded.' ';
}
}
- $result .= ''."\n";
+ $line.=''."\n";
if ($updateflag) {
$count++;
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
- $udom,$user);
+ $udom,$uname);
+ $result.=$line;
+ } else {
+ $noupdate.=$line;
}
}
- $result .= '
'."\n";
+ if ($noupdate) {
+ my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
+ $result .= 'No Changes Occured For the Students Below '.$noupdate;
+ }
+ $result .= '
'."\n".
+ &show_grading_menu_form ($symb,$url);
my $msg = 'Number of records updated = '.$rec_update.
' for '.$count.' student'.($count <= 1 ? '' : 's').'. '.
'Total number of students = '.$ENV{'form.total'}.' ';
@@ -1993,19 +2397,8 @@ sub csvuploadmap_header {
$javascript=&csvupload_javascript_forward_associate();
}
- my $result='';
- $result.='Resource: '.$url.' ';
- 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.='Part '.(split(/_/))[0].' '.
- 'Type: '.$responsetype.' '.
- 'Handgrade: '.$handgrade.' ';
- }
- $result.='
';
+ my ($result,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
+
$request->print(<
Uploading Class Grades
@@ -2025,13 +2418,16 @@ to this page if the data selected is ins
value="$ENV{'form.upfile_associate'}" />
+
+
ENDPICK
-return '';
+ $request->print(&show_grading_menu_form($symb,$url));
+ return '';
}
@@ -2061,10 +2457,54 @@ sub csvuploadmap_footer {
ENDPICK
}
+sub upcsvScores_form {
+ my ($request) = shift;
+ my ($symb,$url)=&get_symb_and_url($request);
+ if (!$symb) {return '';}
+ my $result =<
+ function checkUpload(formname) {
+ if (formname.upfile.value == "") {
+ alert("Please use the browse button to select a file from your local directory.");
+ return false;
+ }
+ formname.submit();
+ }
+
+CSVFORMJS
+ $ENV{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
+ my ($table) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ $result.=$table;
+ $result.=''."\n";
+ $result.=''."\n";
+ $result.='
'."\n";
+ $result.=&show_grading_menu_form($symb,$url);
+ return $result;
+}
+
+
sub csvuploadmap {
my ($request)= @_;
my ($symb,$url)=&get_symb_and_url($request);
if (!$symb) {return '';}
+
my $datatoken;
if (!$ENV{'form.datatoken'}) {
$datatoken=&Apache::loncommon::upfile_store($request);
@@ -2093,6 +2533,8 @@ sub csvuploadmap {
}
}
&csvuploadmap_footer($request,$i,$keyfields);
+ $request->print(&show_grading_menu_form($symb,$url));
+
return '';
}
@@ -2117,7 +2559,8 @@ sub csvuploadassign {
}
$request->print('Assigning Grades ');
my $courseid=$ENV{'request.course.id'};
- my ($classlist) = &getclasslist('all','1');
+ my ($classlist) = &getclasslist('all',0);
+ my @notallowed;
my @skipped;
my $countdone=0;
foreach my $grade (@gradedata) {
@@ -2128,6 +2571,11 @@ sub csvuploadassign {
push(@skipped,"$username:$domain");
next;
}
+ my $usec=$classlist->{"$username:$domain"}[5];
+ if (!&canmodify($usec)) {
+ push(@notallowed,"$username:$domain");
+ next;
+ }
my %grades;
foreach my $dest (keys(%fields)) {
if ($dest eq 'username' || $dest eq 'domain') { next; }
@@ -2146,205 +2594,903 @@ sub csvuploadassign {
}
$request->print(" Stored $countdone students\n");
if (@skipped) {
- $request->print('Skipped Students ');
- foreach my $student (@skipped) { $request->print(" $student"); }
+ $request->print('Skipped Students
');
+ foreach my $student (@skipped) { $request->print("$student \n"); }
+ }
+ if (@notallowed) {
+ $request->print('Students Not Allowed to Modify
');
+ foreach my $student (@notallowed) { $request->print("$student \n"); }
}
- $request->print(&view_edit_entire_class_form($symb,$url));
+ $request->print(" \n");
$request->print(&show_grading_menu_form($symb,$url));
return '';
}
#------------- end of section for handling csv file upload ---------
#
#-------------------------------------------------------------------
+#
+#-------------- Next few routines handles grading by page/sequence
+#
+#--- Select a page/sequence and a student to grade
+sub pickStudentPage {
+ my ($request) = shift;
+
+ $request->print(<
+
+function checkPickOne(formname) {
+ if (radioSelection(formname.student) == null) {
+ alert("Please select the student you wish to grade.");
+ return;
+ }
+ var ptr = pullDownSelection(formname.selectpage);
+ formname.page.value = eval("formname.page"+ptr+".value");
+ formname.title.value = eval("formname.title"+ptr+".value");
+ formname.submit();
+}
+
+
+LISTJAVASCRIPT
+ &commonJSfunctions($request);
+ my ($symb,$url) = &get_symb_and_url($request);
+ my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"};
+ my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"};
+ my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
+
+ my $result=' '.
+ 'Manual Grading by Page or Sequence ';
+
+ $result.=''."\n";
+
+ $studentTable.=&show_grading_menu_form($symb,$url);
+ $request->print($studentTable);
+
+ return '';
+}
+
+sub getSymbMap {
+ my ($request) = @_;
+ my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db',
+ $ENV{'request.course.fn'}.'_parms.db');
+ $navmap->init();
+
+ my %symbx = ();
+ my @titles = ();
+ my $minder = 0;
+
+ # Gather every sequence that has problems.
+ my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, 1);
+ for my $sequence ($navmap->getById('0.0'), @sequences) {
+ if ($navmap->hasResource($sequence, sub { shift->is_problem(); }, 0) ) {
+ my $title = $minder.'.'.$sequence->compTitle();
+ push @titles, $title; # minder in case two titles are identical
+ $symbx{$title} = $sequence->symb();
+ $minder++;
+ }
+ }
+
+ $navmap->untieHashes();
+ return \@titles,\%symbx;
+}
-#-------------------------- Menu interface -------------------------
#
-#--- Show a Grading Menu button - Calls the next routine ---
-sub show_grading_menu_form {
- my ($symb,$url)=@_;
- my $result.='