version 1.361, 2006/06/12 18:56:22
|
version 1.374, 2006/09/14 17:52:22
|
Line 36 use Apache::lonhtmlcommon;
|
Line 36 use Apache::lonhtmlcommon;
|
use Apache::lonnavmaps; |
use Apache::lonnavmaps; |
use Apache::lonhomework; |
use Apache::lonhomework; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonmsg qw(:user_normal_msg); |
use Apache::lonmsg(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use String::Similarity; |
use String::Similarity; |
Line 1551 sub handback_box {
|
Line 1551 sub handback_box {
|
next if (!@$files); |
next if (!@$files); |
my $file_counter = 1; |
my $file_counter = 1; |
foreach my $file (@$files) { |
foreach my $file (@$files) { |
my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|); |
if ($file =~ /\/portfolio\//) { |
my ($name,$version,$ext) = &file_name_version_ext($file_disp); |
my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|); |
$file_disp = "$name.$ext"; |
my ($name,$version,$ext) = &file_name_version_ext($file_disp); |
$file = $file_path.$file_disp; |
$file_disp = "$name.$ext"; |
$result.=&mt('Return commented version of [_1] to student.', |
$file = $file_path.$file_disp; |
'<span class="LC_filename">'.$file_disp.'</span>'); |
$result.=&mt('Return commented version of [_1] to student.', |
$result.='<input type="file" name="'.$prefix.'returndoc'.$file_counter.'" />'."\n"; |
'<span class="LC_filename">'.$file_disp.'</span>'); |
$result.='<input type="hidden" name="'.$prefix.'origdoc'.$file_counter.'" value="'.$file.'" /><br />'; |
$result.='<input type="file" name="'.$prefix.'returndoc'.$file_counter.'" />'."\n"; |
$file_counter++; |
$result.='<input type="hidden" name="'.$prefix.'origdoc'.$file_counter.'" value="'.$file.'" /><br />'; |
|
$result.='(File will be uploaded when you click on Save & Next below.)<br />'; |
|
$file_counter++; |
|
} |
} |
} |
} |
} |
return $result; |
return $result; |
Line 1576 sub show_problem {
|
Line 1579 sub show_problem {
|
if ($removeform) { |
if ($removeform) { |
$rendered=~s|<form(.*?)>||g; |
$rendered=~s|<form(.*?)>||g; |
$rendered=~s|</form>||g; |
$rendered=~s|</form>||g; |
$rendered=~s|name="submit"|name="would_have_been_submit"|g; |
$rendered=~s|(<input[^>]*name\s*=\s*"?)(\w+)("?)|$1would_have_been_$2$3|g; |
} |
} |
my $companswer; |
my $companswer; |
if ($mode eq 'both' or $mode eq 'answer') { |
if ($mode eq 'both' or $mode eq 'answer') { |
Line 2107 sub processHandGrade {
|
Line 2110 sub processHandGrade {
|
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { |
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { |
$subject = $env{'form.msgsub'} if ($includemsg =~ /msgsub/); |
$subject = $env{'form.msgsub'} if ($includemsg =~ /msgsub/); |
unless ($subject=~/\w/) { $subject=&mt('Grading Feedback'); } |
unless ($subject=~/\w/) { $subject=&mt('Grading Feedback'); } |
|
$subject.=' ['.&Apache::lonnet::declutter($url).']'; |
my (@msgnum) = split(/,/,$includemsg); |
my (@msgnum) = split(/,/,$includemsg); |
foreach (@msgnum) { |
foreach (@msgnum) { |
$message.=$env{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); |
$message.=$env{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); |
Line 2119 sub processHandGrade {
|
Line 2123 sub processHandGrade {
|
"?symb=$symb\">$env{'form.probTitle'}</a>"; |
"?symb=$symb\">$env{'form.probTitle'}</a>"; |
} |
} |
$msgstatus = &Apache::lonmsg::user_normal_msg($uname,$udom, |
$msgstatus = &Apache::lonmsg::user_normal_msg($uname,$udom, |
$subject.' ['. |
$subject, |
&Apache::lonnet::declutter($url).']',$message); |
$message); |
$request->print('<br />'.&mt('Sending message to [_1]@[_2]',$uname,$udom).': '. |
$request->print('<br />'.&mt('Sending message to [_1]@[_2]',$uname,$udom).': '. |
$msgstatus); |
$msgstatus); |
} |
} |
Line 2133 sub processHandGrade {
|
Line 2137 sub processHandGrade {
|
&saveHandGrade($request,$symb,$collaborator,$udom,$ctr, |
&saveHandGrade($request,$symb,$collaborator,$udom,$ctr, |
$env{'form.unamedom'.$ctr},$part); |
$env{'form.unamedom'.$ctr},$part); |
if ($errorflag eq 'not_allowed') { |
if ($errorflag eq 'not_allowed') { |
$request->print("<font color=\"red\">Not allowed to modify grades for $collaborator:$udom</font>"); |
$request->print("<span class=\"LC_error\">".&mt('Not allowed to modify grades for [_1]',"$collaborator:$udom")."</span>"); |
next; |
next; |
} else { |
} else { |
if ($message ne '') { |
if ($message ne '') { |
$msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$env{'form.msgsub'},$message); |
$msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message); |
} |
} |
} |
} |
} |
} |
Line 2329 sub saveHandGrade {
|
Line 2333 sub saveHandGrade {
|
if (exists($record{'resource.'.$new_part.'.awarded'})) { |
if (exists($record{'resource.'.$new_part.'.awarded'})) { |
$newrecord{'resource.'.$new_part.'.awarded'} = ''; |
$newrecord{'resource.'.$new_part.'.awarded'} = ''; |
} |
} |
$newrecord{'resource.'.$new_part.'.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.'.$new_part.'.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 |
Line 2389 sub saveHandGrade {
|
Line 2393 sub saveHandGrade {
|
} |
} |
$newrecord{'resource.'.$new_part.'.regrader'}= |
$newrecord{'resource.'.$new_part.'.regrader'}= |
"$env{'user.name'}:$env{'user.domain'}"; |
"$env{'user.name'}:$env{'user.domain'}"; |
&handback_files($request,$symb,$stuname,$domain,$newflg,$new_part,\%newrecord); |
|
} |
} |
# unless problem has been graded, set flag to version the submitted files |
# unless problem has been graded, set flag to version the submitted files |
unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/ || |
unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/ || |
Line 2404 sub saveHandGrade {
|
Line 2407 sub saveHandGrade {
|
|
|
if (%newrecord) { |
if (%newrecord) { |
if (@version_parts) { |
if (@version_parts) { |
my @changed_keys = &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts); |
my @changed_keys = &version_portfiles(\%record, \@parts_graded, |
|
$env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts); |
@newrecord{@changed_keys} = @record{@changed_keys}; |
@newrecord{@changed_keys} = @record{@changed_keys}; |
|
foreach my $new_part (@version_parts) { |
|
&handback_files($request,$symb,$stuname,$domain,$newflg, |
|
$new_part,\%newrecord); |
|
} |
} |
} |
&Apache::lonnet::cstore(\%newrecord,$symb, |
&Apache::lonnet::cstore(\%newrecord,$symb, |
$env{'request.course.id'},$domain,$stuname); |
$env{'request.course.id'},$domain,$stuname); |
Line 2437 sub handback_files {
|
Line 2445 sub handback_files {
|
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) { |
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) { |
# if multiple files are uploaded names will be 'returndoc2','returndoc3' |
# if multiple files are uploaded names will be 'returndoc2','returndoc3' |
my $file_counter = 1; |
my $file_counter = 1; |
|
my $file_msg; |
while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) { |
while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) { |
my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'}; |
my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'}; |
my ($directory,$answer_file) = |
my ($directory,$answer_file) = |
Line 2446 sub handback_files {
|
Line 2455 sub handback_files {
|
my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/); |
my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/); |
my @dir_list = &Apache::lonnet::dirlist($portfolio_path,$domain,$stuname,$portfolio_root); |
my @dir_list = &Apache::lonnet::dirlist($portfolio_path,$domain,$stuname,$portfolio_root); |
my $version = &get_next_version($answer_name, $answer_ext, \@dir_list); |
my $version = &get_next_version($answer_name, $answer_ext, \@dir_list); |
my $new_answer = &version_selected_portfile($domain, $stuname, $portfolio_path, $answer_file, $version); |
|
$$newrecord{"resource.$new_part.$resp_id.handback"} = $new_answer; |
|
$version++; |
|
# fix file name |
# fix file name |
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/); |
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/); |
my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain, |
my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain, |
Line 2460 sub handback_files {
|
Line 2466 sub handback_files {
|
} else { |
} else { |
# mark the file as read only |
# mark the file as read only |
my @files = ($save_file_name); |
my @files = ($save_file_name); |
my @what = ($symb,'handback'); |
my @what = ($symb,$env{'request.course.id'},'handback'); |
&Apache::lonnet::mark_as_readonly($domain,$stuname,\@files,\@what); |
&Apache::lonnet::mark_as_readonly($domain,$stuname,\@files,\@what); |
my $subject = "File Handed Back by Instructor "; |
if (exists($$newrecord{"resource.$new_part.$resp_id.handback"})) { |
my $message = "A file has been returned that was originally submitted in reponse to: <br />"; |
$$newrecord{"resource.$new_part.$resp_id.handback"}.=','; |
$message .= "<strong>".&Apache::lonnet::gettitle($symb)."</strong><br />"; |
} |
$message .= " The returned file is named: <br /><strong>".$save_file_name."</strong><br />"; |
$$newrecord{"resource.$new_part.$resp_id.handback"} .= $save_file_name; |
$message .= " and can be found in your portfolio space."; |
$file_msg.= "\n".'<br /><span class="LC_filename"><a href="/uploaded/'."$domain/$stuname/".$save_file_name.'">'.$save_file_name."</a></span><br />"; |
&Apache::lonnet::logthis($message); |
|
my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain, |
|
$subject.' [File Returned]',$message); |
|
} |
} |
$request->print("<br />".$fname." will be the uploaded file name"); |
$request->print("<br />".$fname." will be the uploaded file name"); |
$request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter}); |
$request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter}); |
$file_counter++; |
$file_counter++; |
} |
} |
|
my $subject = "File Handed Back by Instructor "; |
|
my $message = "A file has been returned that was originally submitted in reponse to: <br />"; |
|
$message .= "<strong>".&Apache::lonnet::gettitle($symb)."</strong><br />"; |
|
$message .= ' The returned file(s) are named: '. $file_msg; |
|
$message .= " and can be found in your portfolio space."; |
|
my $url = (&Apache::lonnet::decode_symb($symb))[2]; |
|
$url = &Apache::lonnet::declutter($url); |
|
my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain, |
|
$subject.' (File Returned) ['.$url.']',$message); |
|
|
} |
} |
} |
} |
return; |
return; |
Line 2566 sub version_portfiles {
|
Line 2580 sub version_portfiles {
|
my $new_portfiles; |
my $new_portfiles; |
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) { |
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) { |
my @versioned_portfiles; |
my @versioned_portfiles; |
my @portfiles = split(/,/,$$record{$key}); |
my @portfiles = split(/\s*,\s*/,$$record{$key}); |
foreach my $file (@portfiles) { |
foreach my $file (@portfiles) { |
&Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file); |
&Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file); |
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/); |
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/); |
Line 2578 sub version_portfiles {
|
Line 2592 sub version_portfiles {
|
if ($new_answer ne 'problem getting file') { |
if ($new_answer ne 'problem getting file') { |
push(@versioned_portfiles, $directory.$new_answer); |
push(@versioned_portfiles, $directory.$new_answer); |
&Apache::lonnet::mark_as_readonly($domain,$stu_name, |
&Apache::lonnet::mark_as_readonly($domain,$stu_name, |
['/portfolio'.$directory.$new_answer], |
[$directory.$new_answer], |
[$symb,$env{'request.course.id'},'graded']); |
[$symb,$env{'request.course.id'},'graded']); |
} |
} |
} |
} |
Line 3428 sub upcsvScores_form {
|
Line 3442 sub upcsvScores_form {
|
$result.=$table; |
$result.=$table; |
$result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n"; |
$result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n"; |
$result.='<table width="100%" border="0"><tr bgcolor="#e6ffff"><td>'."\n"; |
$result.='<table width="100%" border="0"><tr bgcolor="#e6ffff"><td>'."\n"; |
$result.=' <b>Specify a file containing the class scores for current resource'. |
$result.=' <b>'.&mt('Specify a file containing the class scores for current resource'). |
'.</b></td></tr>'."\n"; |
'.</b></td></tr>'."\n"; |
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
|
my $upload=&mt("Upload Scores"); |
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
my $ignore=&mt('Ignore First Line'); |
my $ignore=&mt('Ignore First Line'); |
$result.=<<ENDUPFORM; |
$result.=<<ENDUPFORM; |
Line 3440 sub upcsvScores_form {
|
Line 3455 sub upcsvScores_form {
|
<input type="hidden" name="probTitle" value="$env{'form.probTitle'}" /> |
<input type="hidden" name="probTitle" value="$env{'form.probTitle'}" /> |
<input type="hidden" name="saveState" value="$env{'form.saveState'}" /> |
<input type="hidden" name="saveState" value="$env{'form.saveState'}" /> |
$upfile_select |
$upfile_select |
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Scores" /> |
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="$upload" /> |
<label><input type="checkbox" name="noFirstLine" />$ignore</label> |
<label><input type="checkbox" name="noFirstLine" />$ignore</label> |
</form> |
</form> |
ENDUPFORM |
ENDUPFORM |
$result.='</td></tr></table>'."\n"; |
$result.=&Apache::loncommon::help_open_topic("Course_Convert_To_CSV", |
|
&mt("How do I create a CSV file from a spreadsheet")) |
|
.'</td></tr></table>'."\n"; |
$result.='</td></tr></table><br /><br />'."\n"; |
$result.='</td></tr></table><br /><br />'."\n"; |
$result.=&show_grading_menu_form($symb); |
$result.=&show_grading_menu_form($symb); |
return $result; |
return $result; |
Line 4591 sub scantron_parse_scanline {
|
Line 4608 sub scantron_parse_scanline {
|
substr($questions,0,$$scantron_config{'Qlength'})=''; |
substr($questions,0,$$scantron_config{'Qlength'})=''; |
if (length($currentquest) < $$scantron_config{'Qlength'}) { next; } |
if (length($currentquest) < $$scantron_config{'Qlength'}) { next; } |
if ($$scantron_config{'Qon'} eq 'letter') { |
if ($$scantron_config{'Qon'} eq 'letter') { |
if ($currentquest eq '?') { |
if ($currentquest eq '?' |
|
|| $currentquest eq '*') { |
push(@{$record{'scantron.doubleerror'}},$questnum); |
push(@{$record{'scantron.doubleerror'}},$questnum); |
$record{"scantron.$questnum.answer"}=''; |
$record{"scantron.$questnum.answer"}=''; |
} elsif (!$currentquest |
} elsif (!$currentquest |
Line 4605 sub scantron_parse_scanline {
|
Line 4623 sub scantron_parse_scanline {
|
$record{"scantron.$questnum.answer"}=$currentquest; |
$record{"scantron.$questnum.answer"}=$currentquest; |
} |
} |
} elsif ($$scantron_config{'Qon'} eq 'number') { |
} elsif ($$scantron_config{'Qon'} eq 'number') { |
if ($currentquest eq '?') { |
if ($currentquest eq '?' |
|
|| $currentquest eq '*') { |
push(@{$record{'scantron.doubleerror'}},$questnum); |
push(@{$record{'scantron.doubleerror'}},$questnum); |
$record{"scantron.$questnum.answer"}=''; |
$record{"scantron.$questnum.answer"}=''; |
} elsif (!$currentquest |
} elsif (!$currentquest |
Line 4616 sub scantron_parse_scanline {
|
Line 4635 sub scantron_parse_scanline {
|
push(@{$record{"scantron.missingerror"}},$questnum); |
push(@{$record{"scantron.missingerror"}},$questnum); |
} |
} |
} else { |
} else { |
$record{"scantron.$questnum.answer"}= |
# wrap zero back to J |
$alphabet[$currentquest-1]; |
if ($currentquest eq '0') { |
|
$record{"scantron.$questnum.answer"}= |
|
$alphabet[9]; |
|
} else { |
|
$record{"scantron.$questnum.answer"}= |
|
$alphabet[$currentquest-1]; |
|
} |
} |
} |
} else { |
} else { |
my @array=split($$scantron_config{'Qon'},$currentquest,-1); |
my @array=split($$scantron_config{'Qon'},$currentquest,-1); |
Line 4788 sub scantron_warning_screen {
|
Line 4813 sub scantron_warning_screen {
|
my ($button_text)=@_; |
my ($button_text)=@_; |
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'}); |
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'}); |
my %scantron_config=&get_scantron_config($env{'form.scantron_format'}); |
my %scantron_config=&get_scantron_config($env{'form.scantron_format'}); |
my $CODElist="a"; |
my $CODElist; |
if ($scantron_config{'CODElocation'} && |
if ($scantron_config{'CODElocation'} && |
$scantron_config{'CODEstart'} && |
$scantron_config{'CODEstart'} && |
$scantron_config{'CODElength'}) { |
$scantron_config{'CODElength'}) { |
$CODElist=$env{'form.scantron_CODElist'}; |
$CODElist=$env{'form.scantron_CODElist'}; |
if ($CODElist eq '') { $CODElist='<font color="red">None</font>'; } |
if ($env{'form.scantron_CODElist'} eq '') { $CODElist='<font color="red">None</font>'; } |
$CODElist= |
$CODElist= |
'<tr><td><b>List of CODES to validate against:</b></td><td><tt>'. |
'<tr><td><b>List of CODES to validate against:</b></td><td><tt>'. |
$CODElist.'</tt></td></tr>'; |
$env{'form.scantron_CODElist'}.'</tt></td></tr>'; |
} |
} |
return (<<STUFF); |
return (<<STUFF); |
<p> |
<p> |