LISTJAVASCRIPT
@@ -397,6 +424,10 @@ LISTJAVASCRIPT
if ($ENV{'form.handgrade'} eq 'yes') {
$gradeTable.=' handgrade only'."\n";
}
+
+ my $saveStatus = $ENV{'form.status'} eq '' ? 'Active' : $ENV{'form.status'};
+ $ENV{'form.status'} = $saveStatus;
+
$gradeTable.=' last sub only'."\n".
' last sub & parts info'."\n".
' all details'."\n".
@@ -409,58 +440,85 @@ LISTJAVASCRIPT
' '."\n".
' '."\n".
' '."\n".
- 'To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n".
+ ' '."\n";
+
+ $gradeTable.='Student Status: '.
+ 'Active '.
+ 'Expired '.
+ 'Any '.
+ ' '."\n";
+
+ $gradeTable.='To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n".
'click on the '.$viewgrade.' button. To view the submissions for a group of students, click'."\n".
' on the check boxes for the group of students. '."\n".
- ' '."\n".
- ' '."\n";
+ $gradeTable.=' '."\n";
-
- my (undef,undef,$fullname) = &getclasslist($getsec,$ENV{'form.showgrading'} eq 'yes' ? '1' : '0');
-
+
+ my (undef, undef, $fullname) = &getclasslist($getsec,'1');
$gradeTable.=''.
- ''.
- ' 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.='
'.
' There are no students currently enrolled. ';
} else {
$gradeTable=' '.
- 'No submissions found for this resource for any students. ('.$num_students.' checked for submissions ';
+ 'No submissions found for this resource for any students. ('.$num_students.
+ ' checked for submissions ';
}
} elsif ($ctr == 1) {
$gradeTable =~ s/type=checkbox/type=checkbox checked/;
@@ -1050,11 +1109,18 @@ sub submission {
(my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
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 '';
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' : '');
# header info
@@ -1249,7 +1315,7 @@ KEYWORDS
} else {
for my $part (sort keys(%$handgrade)) {
foreach (@$string) {
- my ($partid,$respid) = /^resource\.(\d+)\.(\d+)\.submission/;
+ my ($partid,$respid) = /^resource\.(\w+)\.(\w+)\.submission/;
if ($part eq ($partid.'_'.$respid)) {
my ($ressub,$subval) = split(/:/,$_,2);
# Similarity check
@@ -1288,7 +1354,7 @@ KEYWORDS
}
# return if view submission with no grading option
- if ($ENV{'form.showgrading'} eq '') {
+ if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) {
$request->print('
'."\n");
$request->print(&show_grading_menu_form($symb,$url))
if (($ENV{'form.command'} eq 'submission') ||
@@ -1307,7 +1373,7 @@ KEYWORDS
my $lastone = pop @col_fullnames;
$msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
}
- $msgfor =~ s/\'/\\'/g; #' stupid emacs
+ $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
$result.=''."\n".
' '.
@@ -1432,6 +1498,11 @@ sub processHandGrade {
$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/) {
@@ -1451,12 +1522,16 @@ sub processHandGrade {
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);
+ }
}
}
}
@@ -1589,6 +1664,9 @@ sub processHandGrade {
#---- Save the score and award for each student, if changed
sub saveHandGrade {
my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter) = @_;
+ 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) = ('','');
@@ -1646,8 +1724,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 = "";
@@ -1670,7 +1748,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 = "";
@@ -1881,9 +1959,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
@@ -2053,10 +2131,15 @@ sub editgrades {
my ($uname,$udom)=split(/_/,$user);
my %newrecord;
my $updateflag = 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);
@@ -2114,7 +2197,8 @@ sub editgrades {
}
}
if ($noupdate) {
- $result .= 'No Changes Occured For the Students Below '.$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);
@@ -2317,7 +2401,7 @@ CSVFORMJS
$result.=''."\n";
my $upfile_select=&Apache::loncommon::upfile_select_html();
$result.=<
+ ';
- my ($depth,$ctr,$question) = (1,0,1);
+ my ($depth,$question) = (1,1);
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
- while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
+ while ($depth > 0) {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
- if($curRes == $iterator->END_MAP) { $depth++; }
+ if($curRes == $iterator->END_MAP) { $depth--; }
if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
my $parts = $curRes->parts();
@@ -2746,19 +2846,21 @@ sub displayPage {
'','.submission');
}
-
- foreach my $partid (@{$parts}) {
- $studentTable.=&gradeBox($request,$symbx,$uname,$udom,$question,$partid,\%record);
- $studentTable.=' '."\n";
- $question++;
+ if (&canmodify($usec)) {
+ foreach my $partid (@{$parts}) {
+ $studentTable.=&gradeBox($request,$symbx,$uname,$udom,$question,$partid,\%record);
+ $studentTable.=' '."\n";
+ $question++;
+ }
}
$studentTable.='';
- }
+ }
$curRes = $iterator->next();
- $ctr++;
}
+ $navmap->untieHashes();
+
$studentTable.=''."\n".
' '.
@@ -2776,9 +2878,14 @@ sub updateGradeByPage {
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"};
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
my $pageTitle = $ENV{'form.page'};
- my (undef,undef,$fullname) = &getclasslist($getsec,'1');
+ my ($classlist,undef,$fullname) = &getclasslist($getsec,'1');
my ($uname,$udom) = split(/:/,$ENV{'form.student'});
-
+ my $usec=$classlist->{$ENV{'form.student'}}[5];
+ if (!&canmodify($usec)) {
+ $request->print('Unable to modify requested student.('.$ENV{'form.student'}.' ');
+ $request->print(&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'}));
+ return;
+ }
my $result=' '.$ENV{'form.title'}.' ';
$result.=' Student: '.$$fullname{$ENV{'form.student'}}.
' ('.$uname.($udom eq $cdom ? '':':'.$udom).') '."\n";
@@ -2802,10 +2909,10 @@ sub updateGradeByPage {
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
- my ($depth,$ctr,$question,$changeflag)= (1,0,1,0);
- while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
+ my ($depth,$question,$changeflag)= (1,1,0);
+ while ($depth > 0) {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
- if($curRes == $iterator->END_MAP) { $depth++; }
+ if($curRes == $iterator->END_MAP) { $depth--; }
if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
my $parts = $curRes->parts();
@@ -2865,9 +2972,10 @@ sub updateGradeByPage {
}
$curRes = $iterator->next();
- $ctr++;
}
+ $navmap->untieHashes();
+
$studentTable.='';
$studentTable.=&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'});
my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' :
@@ -3395,7 +3503,8 @@ GRADINGMENUJS
sub handler {
my $request=$_[0];
-
+
+ undef(%perm);
if ($ENV{'browser.mathml'}) {
$request->content_type('text/xml');
} else {
@@ -3424,15 +3533,14 @@ sub handler {
if ($tsymb) {
my ($map,$id,$url)=split(/\_\_\_/,$tsymb);
if (&Apache::lonnet::allowed('mgr',$tcrsid)) {
- $request->print(
- &Apache::lonnet::ssi('/res/'.$url,
- ('grade_username' => $tuname,
- 'grade_domain' => $tudom,
- 'grade_courseid' => $tcrsid,
- 'grade_symb' => $tsymb)));
+ $request->print(&Apache::lonnet::ssi_body('/res/'.$url,
+ ('grade_username' => $tuname,
+ 'grade_domain' => $tudom,
+ 'grade_courseid' => $tcrsid,
+ 'grade_symb' => $tsymb)));
} else {
$request->print('Not authorized: '.$token.' ');
- }
+ }
} else {
$request->print('Not a valid DocID: '.$token.' ');
}
@@ -3441,36 +3549,48 @@ sub handler {
}
}
} else {
- $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
- if ($command eq 'submission') {
+ if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}))) {
+ if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {
+ $perm{'vgr_section'}=$ENV{'request.course.sec'};
+ } else {
+ delete($perm{'vgr'});
+ }
+ }
+ if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}))) {
+ if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {
+ $perm{'mgr_section'}=$ENV{'request.course.sec'};
+ } else {
+ delete($perm{'mgr'});
+ }
+ }
+
+ if ($command eq 'submission' && $perm{'vgr'}) {
($ENV{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
- } elsif ($command eq 'pickStudentPage') {
+ } elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {
&pickStudentPage($request);
- } elsif ($command eq 'displayPage') {
+ } elsif ($command eq 'displayPage' && $perm{'vgr'}) {
&displayPage($request);
- } elsif ($command eq 'gradeByPage') {
+ } elsif ($command eq 'gradeByPage' && $perm{'mgr'}) {
&updateGradeByPage($request);
- } elsif ($command eq 'processGroup') {
+ } elsif ($command eq 'processGroup' && $perm{'vgr'}) {
&processGroup($request);
- } elsif ($command eq 'gradingmenu') {
+ } elsif ($command eq 'gradingmenu' && $perm{'vgr'}) {
$request->print(&gradingmenu($request));
- } elsif ($command eq 'viewgrades') {
+ } elsif ($command eq 'viewgrades' && $perm{'vgr'}) {
$request->print(&viewgrades($request));
- } elsif ($command eq 'handgrade') {
+ } elsif ($command eq 'handgrade' && $perm{'mgr'}) {
$request->print(&processHandGrade($request));
- } elsif ($command eq 'editgrades') {
+ } elsif ($command eq 'editgrades' && $perm{'mgr'}) {
$request->print(&editgrades($request));
- } elsif ($command eq 'verify') {
+ } elsif ($command eq 'verify' && $perm{'vgr'}) {
$request->print(&verifyreceipt($request));
- } elsif ($command eq 'csvform') {
+ } elsif ($command eq 'csvform' && $perm{'mgr'}) {
$request->print(&upcsvScores_form($request));
- } elsif ($command eq 'csvupload') {
+ } elsif ($command eq 'csvupload' && $perm{'mgr'}) {
$request->print(&csvupload($request));
- } elsif ($command eq 'viewclasslist') {
- $request->print(&viewclasslist($request));
- } elsif ($command eq 'csvuploadmap') {
+ } elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) {
$request->print(&csvuploadmap($request));
- } elsif ($command eq 'csvuploadassign') {
+ } elsif ($command eq 'csvuploadassign' && $perm{'mgr'}) {
if ($ENV{'form.associate'} ne 'Reverse Association') {
$request->print(&csvuploadassign($request));
} else {
@@ -3481,12 +3601,12 @@ sub handler {
}
$request->print(&csvuploadmap($request));
}
- } elsif ($command eq 'scantron_selectphase') {
+ } elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
$request->print(&scantron_selectphase($request));
- } elsif ($command eq 'scantron_process') {
+ } elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
$request->print(&scantron_process_students($request));
- } else {
- $request->print("Unknown action: $command:");
+ } elsif ($command) {
+ $request->print("Access Denied");
}
}
&send_footer($request);