");
+ pDoc.write("';
- return $result;
-}
-
-
-#FIXME need to look at the metadata spec on what type of data to accept and provide an
-#interface based on that, also do that to above function.
-sub setstudentgrade {
- my ($url,$symb,$courseid,$student,@parts) = @_;
- my $result ='';
- my ($stuname,$domain) = split(/:/,$student);
- my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
- my %newrecord;
-
- foreach my $part (@parts) {
- my ($temp,$part,$type)=split(/_/,$part);
- my $oldscore=$record{"resource.$part.$type"};
- my $newscore=$ENV{"form.GRADE.$student.$part.$type"};
- if ($type eq 'solved') {
- my $update=0;
- if ($newscore eq 'nothing' ) {
- if ($oldscore ne '') {
- $update=1;
- $newscore = '';
- }
- } elsif ($oldscore !~ m/^$newscore/) {
- $update=1;
- $result.="Updating $stuname to $newscore \n";
- 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'; }
- } else {
- #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
- }
- if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
- } else {
- if ($oldscore ne $newscore) {
- $newrecord{"resource.$part.$type"}=$newscore;
- $result.="Updating $student"."'s status for $part.$type to $newscore \n";
- } else {
- #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
- }
- }
- }
- if ( scalar(keys(%newrecord)) > 0 ) {
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
-# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
-
- $result.="Stored away ".scalar(keys(%newrecord))." elements. \n";
- }
- return $result;
-}
+ my $symb=&get_symb($request);
+ my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
+ my $title=''.&mt('Current Grade Status').'';
+ $title.=''.&mt('Current Resource: [_1]',$env{'form.probTitle'}).''."\n";
+ $title.=''.&mt('Section: [_1]',$section_display).''."\n";
+
+ my $result= &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ ''.&mt('No.').' | '.
+ ''.&nameUserString('header')." | \n";
+ my %scoreptr = (
+ 'correct' =>'correct_by_override',
+ 'incorrect'=>'incorrect_by_override',
+ 'excused' =>'excused',
+ 'ungraded' =>'ungraded_attempted',
+ 'nothing' => '',
+ );
+ my ($classlist,undef,$fullname) = &getclasslist($env{'form.section'},'0');
+ my (@partid);
+ my %weight = ();
+ my %columns = ();
+ my ($i,$ctr,$count,$rec_update) = (0,0,0,0);
-sub sub_page_js {
- my $request = shift;
- $request->print(<
- function updateRadio(radioButton,formtextbox,formsel,scores) {
- 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'.
+ ''.&mt('New Score').' | ';
+ $columns{$partid}=2;
+ foreach my $stores (@parts) {
+ my ($part,$type) = &split_part_type($stores);
+ if ($part !~ m/^\Q$partid\E/) { next;}
+ if ($type eq 'awarded' || $type eq 'solved') { next; }
+ my $display=&Apache::lonnet::metadata($url,$stores.'.display');
+ $display =~ s/\[Part: (\w)+\]//;
+ $display =~ s/Number of Attempts/Tries/;
+ $header .= ''.&mt('Old '.$display).' | '.
+ ''.&mt('New '.$display).' | ';
+ $columns{$partid}+=2;
+ }
+ }
+ foreach my $partid (@partid) {
+ my $display_part=&get_display_part($partid,$symb);
+ $result .= ''.
+ &mt('Part: [_1] (Weight = [_2])',$display_part,$weight{$partid}).
+ ' | ';
+
+ }
+ $result .= &Apache::loncommon::end_data_table_header_row().
+ &Apache::loncommon::start_data_table_header_row().
+ $header.
+ &Apache::loncommon::end_data_table_header_row();
+ my @noupdate;
+ my ($updateCtr,$noupdateCtr) = (1,1);
+ for ($i=0; $i<$env{'form.total'}; $i++) {
+ my $line;
+ my $user = $env{'form.ctr'.$i};
+ my ($uname,$udom)=split(/:/,$user);
+ my %newrecord;
+ my $updateflag = 0;
+ $line .= ''.&nameUserString(undef,$$fullname{$user},$uname,$udom).' | ';
+ my $usec=$classlist->{"$uname:$udom"}[5];
+ if (!&canmodify($usec)) {
+ my $numcols=scalar(@partid)*4+2;
+ push(@noupdate,
+ $line."".
+ &mt('Not allowed to modify student')." | |
");
+ next;
}
- }
- updateSelect(formsel);
- scores.value = "0";
- }
+ my %aggregate = ();
+ my $aggregateflag = 0;
+ $user=~s/:/_/; # colon doen't work in javascript for names
+ foreach (@partid) {
+ my $old_aw = $env{'form.GD_'.$user.'_'.$_.'_awarded_s'};
+ my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
+ my $old_part = $old_aw eq '' ? '' : $old_part_pcr;
+ my $old_score = $scoreptr{$env{'form.GD_'.$user.'_'.$_.'_solved_s'}};
+ my $awarded = $env{'form.GD_'.$user.'_'.$_.'_awarded'};
+ my $pcr = $awarded/($weight{$_} ne '0' ? $weight{$_} : 1);
+ my $partial = $awarded eq '' ? '' : $pcr;
+ my $score;
+ if ($partial eq '') {
+ $score = $scoreptr{$env{'form.GD_'.$user.'_'.$_.'_solved_s'}};
+ } elsif ($partial > 0) {
+ $score = 'correct_by_override';
+ } elsif ($partial == 0) {
+ $score = 'incorrect_by_override';
+ }
+ my $dropMenu = $env{'form.GD_'.$user.'_'.$_.'_solved'};
+ $score = 'excused' if (($dropMenu eq 'excused') && ($score ne 'excused'));
- function writeBox(formrad,formsel,pts,scores) {
- formrad.value = pts;
- scores.value = "0";
- updateSelect(formsel,pts);
- return;
- }
+ $newrecord{'resource.'.$_.'.regrader'}=
+ "$env{'user.name'}:$env{'user.domain'}";
+ if ($dropMenu eq 'reset status' &&
+ $old_score ne '') { # ignore if no previous attempts => nothing to reset
+ $newrecord{'resource.'.$_.'.tries'} = '';
+ $newrecord{'resource.'.$_.'.solved'} = '';
+ $newrecord{'resource.'.$_.'.award'} = '';
+ $newrecord{'resource.'.$_.'.awarded'} = '';
+ $updateflag = 1;
+ if ($env{'form.GD_'.$user.'_'.$_.'_aggtries'} > 0) {
+ my $aggtries = $env{'form.GD_'.$user.'_'.$_.'_aggtries'};
+ my $totaltries = $env{'form.GD_'.$user.'_'.$_.'_totaltries'};
+ my $solvedstatus = $env{'form.GD_'.$user.'_'.$_.'_solved_s'};
+ &decrement_aggs($symb,$_,\%aggregate,$aggtries,$totaltries,$solvedstatus);
+ $aggregateflag = 1;
+ }
+ } elsif (!($old_part eq $partial && $old_score eq $score)) {
+ $updateflag = 1;
+ $newrecord{'resource.'.$_.'.awarded'} = $partial if $partial ne '';
+ $newrecord{'resource.'.$_.'.solved'} = $score;
+ $rec_update++;
+ }
- function clearRadBox(radioButton,formbox,formsel,scores) {
- for (var i=0; i