'."\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');
@@ -1807,10 +1991,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);
@@ -1820,6 +2005,10 @@ 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;
}
@@ -1828,30 +2017,31 @@ 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";
+ '\')"; 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');
@@ -1859,10 +2049,10 @@ sub viewstudentgrade {
$result.=" \n";
} else {
$result.=' '.
+ 'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
"\n";
$result.=' '."\n";
}
}
@@ -1882,7 +2072,7 @@ sub editgrades {
$title.='Section: '.$ENV{'form.section'}.' '."\n";
my $result= ''."\n";
$result.= ''.
- 'Username Fullname '."\n";
+ 'Username Domain Fullname '."\n";
my %scoreptr = (
'correct' =>'correct_by_override',
@@ -1930,16 +2120,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);
@@ -1959,7 +2157,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 : '').' ';
@@ -1982,17 +2180,24 @@ sub editgrades {
$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++;
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
- $udom,$user);
+ $udom,$uname);
+ $result.=$line;
+ } else {
+ $noupdate.=$line;
}
}
+ 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.
@@ -2018,48 +2223,6 @@ sub split_part_type {
#
#-------------------------- Next few routines handles grading by csv upload
#
-#--- Menu to upload a csv scores ---
-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();
- if (navigator.appName !="Netscape") {self.close()}; //if netscape if appears to close before submit!!!
- // any suggestion how to get around this??
- }
-
-CSVFORMJS
- $ENV{'form.probTitle'} = &Apache::lonnet::metadata($url,'title');
- $result.=''."\n";
- $result.=''."\n";
- $result.='
'."\n";
- return $result;
-}
-
#--- Javascript to handle csv upload
sub csvupload_javascript_reverse_associate {
return(<
-
-
+
@@ -2214,6 +2376,48 @@ 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);
+ $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);
@@ -2273,7 +2477,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) {
@@ -2284,6 +2489,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; }
@@ -2302,10 +2512,14 @@ 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"); }
}
- $request->print(&view_edit_entire_class_form($symb,$url));
+ if (@notallowed) {
+ $request->print('Students Not Allowed to Modify
');
+ foreach my $student (@notallowed) { $request->print("$student \n"); }
+ }
+ $request->print(" \n");
$request->print(&show_grading_menu_form($symb,$url));
return '';
}
@@ -2323,8 +2537,7 @@ sub pickStudentPage {
@@ -2363,9 +2584,9 @@ LISTJAVASCRIPT
my $result=' '.
'Manual Grading by Page or Sequence ';
- $result.='