'.
'';
@@ -737,7 +747,7 @@ LISTJAVASCRIPT
if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
foreach (sort keys(%status)) {
next if (/^resource.*?submitted_by$/);
- $gradeTable.=' '.$status{$_}.' | '."\n";
+ $gradeTable.=' '.$status{$_}.' | '."\n";
}
}
# $gradeTable.=' | ' if ($ctr%2 ==1);
@@ -1346,16 +1356,24 @@ sub gradeBox {
my $result=''."\n";
my $display_part=&get_display_part($partid,undef,$symb);
+
+ my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
+ [$partid]);
+ my $aggtries = $$record{'resource.'.$partid.'.tries'};
+ if ($last_resets{$partid}) {
+ $aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
+ }
+
$result.=''.
'Part: '.$display_part.' Points: | '."\n";
my $ctr = 0;
$result.=''."\n";
return $result;
}
@@ -1593,7 +1615,6 @@ KEYWORDS
}
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
-
my ($partlist,$handgrade,$responseType) = &response_type($url,$symb);
# Display student info
@@ -2109,7 +2130,7 @@ sub processHandGrade {
#---- Save the score and award for each student, if changed
sub saveHandGrade {
my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter,$part) = @_;
- my $v_flag=0;
+ my @v_flag;
my $usec = &Apache::lonnet::getsection($domain,$stuname,
$env{'request.course.id'});
if (!&canmodify($usec)) { return('not_allowed'); }
@@ -2117,6 +2138,8 @@ sub saveHandGrade {
my @parts_graded;
my %newrecord = ();
my ($pts,$wgt) = ('','');
+ my %aggregate = ();
+ my $aggregateflag = 0;
foreach my $new_part (split(/:/,$env{'form.partlist'.$newflg})) {
#collaborator may vary for different parts
if ($submitter && $new_part ne $part) { next; }
@@ -2136,6 +2159,21 @@ sub saveHandGrade {
}
$newrecord{'resource.'.$new_part.'.regrader'}=
"$env{'user.name'}:$env{'user.domain'}";
+ my $totaltries = $record{'resource.'.$part.'.tries'};
+
+ my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
+ [$new_part]);
+ my $aggtries =$totaltries;
+ if ($last_resets{$new_part}) {
+ $aggtries = &get_num_tries(\%record,$last_resets{$new_part},
+ $new_part);
+ }
+
+ my $solvedstatus = $record{'resource.'.$new_part.'.solved'};
+ if ($aggtries > 0) {
+ &decrement($symb,$new_part,\%aggregate,$aggtries,$totaltries,$solvedstatus);
+ $aggregateflag = 1;
+ }
} elsif ($dropMenu eq '') {
$pts = ($env{'form.GD_BOX'.$newflg.'_'.$new_part} ne '' ?
$env{'form.GD_BOX'.$newflg.'_'.$new_part} :
@@ -2174,34 +2212,100 @@ sub saveHandGrade {
}
# unless problem has been graded, set flag to version the submitted files
unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/ || $record{'resource.'.$new_part.'.solved'} eq 'incorrect_by_override') {
- $v_flag = 1;
+ push (@v_flag,$new_part);
}
}
if (scalar(keys(%newrecord)) > 0) {
- if ($v_flag) {
- &Apache::lonnet::unmark_as_readonly($domain,$stuname,$symb.$env{'request.course.id'});
- &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname);
+ if (scalar(@v_flag)) {
+ &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@v_flag);
}
&Apache::lonnet::cstore(\%newrecord,$symb,
$env{'request.course.id'},$domain,$stuname);
}
+ if ($aggregateflag) {
+ &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ }
return '',$pts,$wgt;
}
+# ----------- Provides number of tries since last reset.
+sub get_num_tries {
+ my ($record,$last_reset,$part) = @_;
+ my $timestamp = '';
+ my $num_tries = 0;
+ if ($$record{'version'}) {
+ for (my $version=$$record{'version'};$version>=1;$version--) {
+ if (exists($$record{$version.':resource.'.$part.'.solved'})) {
+ $timestamp = $$record{$version.':timestamp'};
+ if ($timestamp > $last_reset) {
+ $num_tries ++;
+ } else {
+ last;
+ }
+ }
+ }
+ }
+ return $num_tries;
+}
+
+# ----------- Determine decrements required in aggregate totals
+sub decrement_aggs {
+ my ($symb,$part,$aggregate,$aggtries,$totaltries,$solvedstatus) = @_;
+ my %decrement = (
+ attempts => 0,
+ users => 0,
+ correct => 0
+ );
+ $decrement{'attempts'} = $aggtries;
+ if ($solvedstatus =~ /^correct/) {
+ $decrement{'correct'} = 1;
+ }
+ if ($aggtries == $totaltries) {
+ $decrement{'users'} = 1;
+ }
+ foreach my $type (keys (%decrement)) {
+ $$aggregate{$symb."\0".$part."\0".$type} = -$decrement{$type};
+ }
+ return;
+}
+
+# ----------- Determine timestamps for last reset of aggregate totals for parts
+sub get_last_resets {
+ my ($symb,$courseid,$partids) =@_;
+ my %last_resets;
+ my $cdom = $env{'course.'.$courseid.'.domain'};
+ my $cname = $env{'course.'.$courseid.'.num'};
+ my @keys;
+ foreach my $part (@{$partids}) {
+ push(@keys,"$symb\0$part\0resettime");
+ }
+ my %results=&Apache::lonnet::get('nohist_resourcetracker',\@keys,
+ $cdom,$cname);
+ foreach my $part (@{$partids}) {
+ $last_resets{$part}=$results{"$symb\0$part\0resettime"};
+ }
+ return %last_resets;
+}
+
# ----------- Handles creating versions for portfolio files as answers
sub version_portfiles {
- my ($record, $parts_graded, $courseid, $symb, $domain, $stuname) = @_;
+ my ($record, $parts_graded, $courseid, $symb, $domain, $stuname, $v_flag) = @_;
+ my $version_parts = join('|',@$v_flag);
my $parts = join('|', @$parts_graded);
my $portfolio_root = &Apache::loncommon::propath($domain,
$stuname).
'/userfiles/portfolio';
- foreach my $key(keys %$record) {
- #&Apache::lonnet::logthis("key is $key, value is $$record{$key}");
+ foreach my $key (keys(%$record)) {
my $new_portfiles;
- if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) {
+
+ if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
my @v_portfiles;
my @portfiles = split(/,/,$$record{$key});
+ &Apache::lonnet::logthis("should be unmarking and remarking $key",@portfiles);
foreach my $file (@portfiles) {
+ &Apache::lonnet::unmark_as_readonly($domain,$stuname,[$symb,$env{'request.course.id'}],$file);
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*$)/);
my $version = 0;
my @answer_file_parts = split(/\./, $answer_file);
@@ -2222,14 +2326,16 @@ sub version_portfiles {
}
}
$version++;
- my $home_server = &Apache::lonnet::homeserver($stuname,$domain,undef);
$env{'form.copy'} = &Apache::lonnet::getfile("/uploaded/$domain/$stuname/portfolio$directory$answer_file");
if($env{'form.copy'} eq '-1') {
&Apache::lonnet::logthis('problem getting file '.$directory.$answer_file);
} else {
- my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,$home_server,'copy',
+ my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,'copy',
'/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
- push(@v_portfiles, $answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
+ push(@v_portfiles, $directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
+ &Apache::lonnet::mark_as_readonly($domain,$stuname,
+ ['/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]],
+ [$symb,$env{'request.course.id'},'graded']);
}
}
$$record{$key} = join(',',@v_portfiles);
@@ -2304,6 +2410,7 @@ sub viewgrades_js {
function writeRadText(partid,weight) {
var selval = document.classgrade["SELVAL_"+partid];
var radioButton = document.classgrade["RADVAL_"+partid];
+ var override = document.classgrade["FORCE_"+partid].checked;
var textbox = document.classgrade["TEXTVAL_"+partid];
if (selval[1].selected || selval[2].selected) {
for (var i=0; i';
my $ctr = 0;
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
- $result.= ' | \n";
+ ','.$ctr.')" />'.$ctr."\n";
$result.=(($ctr+1)%10 == 0 ? ' ' : '');
$ctr++;
}
@@ -2488,7 +2595,8 @@ sub viewgrades {
$weight{$partid}.')"> '.
''.
''.
- ' '."\n";
+ ' | '.
+ ' | '."\n";
$ctsparts++;
}
$result.=' '.' '.' |