version 1.258, 2005/04/07 07:03:23
|
version 1.259, 2005/04/07 22:44:03
|
Line 2109 sub processHandGrade {
|
Line 2109 sub processHandGrade {
|
#---- Save the score and award for each student, if changed |
#---- Save the score and award for each student, if changed |
sub saveHandGrade { |
sub saveHandGrade { |
my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter,$part) = @_; |
my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter,$part) = @_; |
|
my $v_flag=0; |
my $usec = &Apache::lonnet::getsection($domain,$stuname, |
my $usec = &Apache::lonnet::getsection($domain,$stuname, |
$env{'request.course.id'}); |
$env{'request.course.id'}); |
if (!&canmodify($usec)) { return('not_allowed'); } |
if (!&canmodify($usec)) { return('not_allowed'); } |
Line 2116 sub saveHandGrade {
|
Line 2117 sub saveHandGrade {
|
my @parts_graded; |
my @parts_graded; |
my %newrecord = (); |
my %newrecord = (); |
my ($pts,$wgt) = ('',''); |
my ($pts,$wgt) = ('',''); |
foreach (split(/:/,$env{'form.partlist'.$newflg})) { |
foreach my $new_part (split(/:/,$env{'form.partlist'.$newflg})) { |
#collaborator may vary for different parts |
#collaborator may vary for different parts |
if ($submitter && $_ ne $part) { next; } |
if ($submitter && $new_part ne $part) { next; } |
my $dropMenu = $env{'form.GD_SEL'.$newflg.'_'.$_}; |
my $dropMenu = $env{'form.GD_SEL'.$newflg.'_'.$new_part}; |
if ($dropMenu eq 'excused') { |
if ($dropMenu eq 'excused') { |
if ($record{'resource.'.$_.'.solved'} ne 'excused') { |
if ($record{'resource.'.$new_part.'.solved'} ne 'excused') { |
$newrecord{'resource.'.$_.'.solved'} = 'excused'; |
$newrecord{'resource.'.$new_part.'.solved'} = 'excused'; |
if (exists($record{'resource.'.$_.'.awarded'})) { |
if (exists($record{'resource.'.$new_part.'.awarded'})) { |
$newrecord{'resource.'.$_.'.awarded'} = ''; |
$newrecord{'resource.'.$new_part.'.awarded'} = ''; |
} |
} |
$newrecord{'resource.'.$_.'.regrader'}="$env{'user.name'}:$env{'user.domain'}"; |
$newrecord{'resource.'.$new_part.'.regrader'}="$env{'user.name'}:$env{'user.domain'}"; |
} |
} |
} elsif ($dropMenu eq 'reset status' |
} elsif ($dropMenu eq 'reset status' |
&& exists($record{'resource.'.$_.'.solved'})) { #don't bother if no old records -> no attempts |
&& exists($record{'resource.'.$new_part.'.solved'})) { #don't bother if no old records -> no attempts |
foreach my $key (keys (%record)) { |
foreach my $key (keys (%record)) { |
if ($key=~/^resource\.\Q$_\E\./) { $newrecord{$key} = ''; } |
if ($key=~/^resource\.\Q$new_part\E\./) { $newrecord{$key} = ''; } |
} |
} |
$newrecord{'resource.'.$_.'.regrader'}= |
$newrecord{'resource.'.$new_part.'.regrader'}= |
"$env{'user.name'}:$env{'user.domain'}"; |
"$env{'user.name'}:$env{'user.domain'}"; |
} elsif ($dropMenu eq '') { |
} elsif ($dropMenu eq '') { |
$pts = ($env{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? |
$pts = ($env{'form.GD_BOX'.$newflg.'_'.$new_part} ne '' ? |
$env{'form.GD_BOX'.$newflg.'_'.$_} : |
$env{'form.GD_BOX'.$newflg.'_'.$new_part} : |
$env{'form.RADVAL'.$newflg.'_'.$_}); |
$env{'form.RADVAL'.$newflg.'_'.$new_part}); |
if ($pts eq '' && $env{'form.GD_SEL'.$newflg.'_'.$_} eq '') { |
if ($pts eq '' && $env{'form.GD_SEL'.$newflg.'_'.$new_part} eq '') { |
next; |
next; |
} |
} |
$wgt = $env{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : |
$wgt = $env{'form.WGT'.$newflg.'_'.$new_part} eq '' ? 1 : |
$env{'form.WGT'.$newflg.'_'.$_}; |
$env{'form.WGT'.$newflg.'_'.$new_part}; |
my $partial= $pts/$wgt; |
my $partial= $pts/$wgt; |
if ($partial eq $record{'resource.'.$_.'.awarded'}) { |
if ($partial eq $record{'resource.'.$new_part.'.awarded'}) { |
#do not update score for part if not changed. |
#do not update score for part if not changed. |
next; |
next; |
} else { |
} else { |
push @parts_graded, $_; |
push @parts_graded, $new_part; |
} |
} |
if ($record{'resource.'.$_.'.awarded'} ne $partial) { |
if ($record{'resource.'.$new_part.'.awarded'} ne $partial) { |
$newrecord{'resource.'.$_.'.awarded'} = $partial; |
$newrecord{'resource.'.$new_part.'.awarded'} = $partial; |
} |
} |
my $reckey = 'resource.'.$_.'.solved'; |
my $reckey = 'resource.'.$new_part.'.solved'; |
if ($partial == 0) { |
if ($partial == 0) { |
if ($record{$reckey} ne 'incorrect_by_override') { |
if ($record{$reckey} ne 'incorrect_by_override') { |
$newrecord{$reckey} = 'incorrect_by_override'; |
$newrecord{$reckey} = 'incorrect_by_override'; |
Line 2165 sub saveHandGrade {
|
Line 2166 sub saveHandGrade {
|
} |
} |
} |
} |
if ($submitter && |
if ($submitter && |
($record{'resource.'.$_.'.submitted_by'} ne $submitter)) { |
($record{'resource.'.$new_part.'.submitted_by'} ne $submitter)) { |
$newrecord{'resource.'.$_.'.submitted_by'} = $submitter; |
$newrecord{'resource.'.$new_part.'.submitted_by'} = $submitter; |
} |
} |
$newrecord{'resource.'.$_.'.regrader'}= |
$newrecord{'resource.'.$new_part.'.regrader'}= |
"$env{'user.name'}:$env{'user.domain'}"; |
"$env{'user.name'}:$env{'user.domain'}"; |
} |
} |
|
# 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; |
|
&Apache::lonnet::logthis("v_flag is $v_flag"); |
|
&Apache::lonnet::logthis('the record info is '.$record{'resource.'.$new_part.'.solved'}); |
|
} else { |
|
&Apache::lonnet::logthis('the record info is '.$record{'resource.'.$new_part.'.solved'}); |
|
} |
} |
} |
if (scalar(keys(%newrecord)) > 0) { |
if (scalar(keys(%newrecord)) > 0) { |
&version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname); |
if ($v_flag) { |
|
&Apache::lonnet::logthis("v_flag (setting stuff) is $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); |
|
} |
&Apache::lonnet::cstore(\%newrecord,$symb, |
&Apache::lonnet::cstore(\%newrecord,$symb, |
$env{'request.course.id'},$domain,$stuname); |
$env{'request.course.id'},$domain,$stuname); |
} |
} |
Line 2188 sub version_portfiles {
|
Line 2201 sub version_portfiles {
|
$stuname). |
$stuname). |
'/userfiles/portfolio'; |
'/userfiles/portfolio'; |
foreach my $key(keys %$record) { |
foreach my $key(keys %$record) { |
|
#&Apache::lonnet::logthis("key is $key, value is $$record{$key}"); |
|
my $new_portfiles; |
if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) { |
if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) { |
|
|
|
my @v_portfiles; |
my @portfiles = split(/,/,$$record{$key}); |
my @portfiles = split(/,/,$$record{$key}); |
foreach my $file (@portfiles) { |
foreach my $file (@portfiles) { |
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*$)/); |
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*$)/); |
Line 2212 sub version_portfiles {
|
Line 2229 sub version_portfiles {
|
} |
} |
$version++; |
$version++; |
my $home_server = &Apache::lonnet::homeserver($stuname,$domain,undef); |
my $home_server = &Apache::lonnet::homeserver($stuname,$domain,undef); |
$env{'form.copy'} = &Apache::lonnet::getfile("/uploaded/$domain/$stuname/$directory$answer_file"); |
$env{'form.copy'} = &Apache::lonnet::getfile("/uploaded/$domain/$stuname/portfolio$directory$answer_file"); |
# $env{'form.copy.filename'}=''; |
if($env{'form.copy'} eq '-1') { |
my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,$home_server,'copy', |
&Apache::lonnet::logthis('problem getting file '.$directory.$answer_file); |
|
} else { |
|
my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,$home_server,'copy', |
'/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); |
'/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); |
&Apache::lonnet::logthis('copy result is '.$copy_result); |
push(@v_portfiles, $answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); |
&Apache::lonnet::logthis('answer file is '.$answer_file. |
&Apache::lonnet::logthis('copy result is '.$copy_result); |
|
&Apache::lonnet::logthis('answer file is '.$answer_file. |
' becomes '.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); |
' becomes '.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); |
&Apache::lonnet::logthis('from dir list is '.$file_names[0].' has '.@file_name_parts.' parts'); |
} |
} |
} |
&Apache::lonnet::logthis('found key portfiles '.$key); |
$$record{$key} = join(/,/,@v_portfiles); |
&Apache::lonnet::logthis('found value portfiles '.$$record{$key}); |
|
} |
} |
} |
} |
|
return 'ok'; |
|
|
} |
} |
|
|