version 1.108, 2010/06/21 02:15:37
|
version 1.120, 2014/12/04 20:43:23
|
Line 58 sub start_essayresponse {
|
Line 58 sub start_essayresponse {
|
if (!defined($maxfilesize)) { |
if (!defined($maxfilesize)) { |
$maxfilesize = 10.0; #FIXME This should become a domain configuration |
$maxfilesize = 10.0; #FIXME This should become a domain configuration |
} |
} |
|
my $hiddendraft; |
if (($Apache::lonhomework::type eq 'survey') || |
if (($Apache::lonhomework::type eq 'survey') || |
($Apache::lonhomework::type eq 'surveycred') || |
($Apache::lonhomework::type eq 'surveycred') || |
($Apache::lonhomework::type eq 'anonsurvey') || |
($Apache::lonhomework::type eq 'anonsurvey') || |
($Apache::lonhomework::type eq 'anonsurveycred')) { |
($Apache::lonhomework::type eq 'anonsurveycred')) { |
$result.= '<input type="hidden" name="HWDRAFT'.$part.'_'.$id.'" value="yes" />'; |
$hiddendraft = '<input type="hidden" name="HWDRAFT'.$part.'_'.$id.'" value="yes" />'; |
} |
} else { |
my $status_text = &mt('Submission type'); |
my $status_text = &mt('Submission type'); |
if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') { |
if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') { |
$status_text .= '<br />'.&mt('(Currently -- draft)'); |
$status_text .= '<br />'.&mt('(Currently -- draft)'); |
} |
} |
$result.= '<p>'.&Apache::lonhtmlcommon::start_pick_box(). |
$result = &Apache::lonhtmlcommon::row_title($status_text); |
&Apache::lonhtmlcommon::row_title($status_text); |
|
if (($Apache::lonhomework::type ne 'survey') && |
|
($Apache::lonhomework::type ne 'surveycred') && |
|
($Apache::lonhomework::type ne 'anonsurvey') && |
|
($Apache::lonhomework::type ne 'anonsurveycred')) { |
|
my $closure; |
my $closure; |
unless ($ncol || $uploadedfiletypes) { |
unless ($ncol || $uploadedfiletypes) { |
$closure = 1; |
$closure = 1; |
Line 95 sub start_essayresponse {
|
Line 91 sub start_essayresponse {
|
'<label>'. |
'<label>'. |
&mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'. |
&mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'. |
$part.'_'.$id.'" value="'.$coll.'" /><br />'. |
$part.'_'.$id.'" value="'.$coll.'" /><br />'. |
&mt('(Enter a maximum of [quant,_1,collaborator] using username or username:domain, e.g. smithje or smithje:[_2].)',$ncol,$env{'user.domain'}); |
&mt('Enter a maximum of [quant,_1,collaborator] using username or username:domain, e.g. smithje or smithje:[_2].',$ncol,$env{'user.domain'}); |
if ($ncol > 1) { |
if ($ncol > 1) { |
$result .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.'); |
$result .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.'); |
} |
} |
Line 111 sub start_essayresponse {
|
Line 107 sub start_essayresponse {
|
} |
} |
$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes, |
$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes, |
$filesfrom,undef,$maxfilesize); |
$filesfrom,undef,$maxfilesize); |
$result.=&Apache::lonhtmlcommon::end_pick_box().'</p>'; |
if ($result) { |
|
$result = |
|
'<div>'.$hiddendraft. |
|
&Apache::lonhtmlcommon::start_pick_box(). |
|
$result. |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'; |
|
} else { |
|
$result = $hiddendraft; |
|
} |
} elsif ($target eq 'web' && |
} elsif ($target eq 'web' && |
$Apache::inputtags::status[-1] ne 'CAN_ANSWER') { |
$Apache::inputtags::status[-1] ne 'CAN_ANSWER') { |
my $part= $Apache::inputtags::part; |
my $part= $Apache::inputtags::part; |
Line 121 sub start_essayresponse {
|
Line 125 sub start_essayresponse {
|
$result .= '<td><i>'.&mt('Collaborated with [_1]',$coll).'</i></td>'; |
$result .= '<td><i>'.&mt('Collaborated with [_1]',$coll).'</i></td>'; |
} |
} |
|
|
my $current_files_display = ¤t_file_submissions($part,$id); |
my $current_files_display = &Apache::inputtags::current_file_submissions($part,$id); |
if ($current_files_display) { |
if ($current_files_display) { |
$result .= '<td><b>'.&mt('Submitted files:').'</b><br />'. |
$result .= '<td><b>'.&mt('Submitted files:').'</b><br />'. |
$current_files_display.'</td>'; |
$current_files_display.'</td>'; |
Line 155 sub end_essayresponse {
|
Line 159 sub end_essayresponse {
|
$increment=&Apache::response::scored_response($part,$id); |
$increment=&Apache::response::scored_response($part,$id); |
} elsif ( &Apache::response::submitted() ) { |
} elsif ( &Apache::response::submitted() ) { |
my $response = $env{'form.HWVAL_'.$id}; |
my $response = $env{'form.HWVAL_'.$id}; |
my $filename = $env{'form.HWFILE'.$part.'_'.$id.'.filename'} || |
my $jspart=$part; |
|
$jspart=~s/\./_/g; |
|
my $filename = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} || |
$env{'form.HWFILETOOBIG'.$part.'_'.$id}; |
$env{'form.HWFILETOOBIG'.$part.'_'.$id}; |
my $portfiles = $env{'form.HWPORT'.$part.'_'.$id}; |
my $portfiles = $env{'form.HWPORT'.$jspart.'_'.$id}; |
my @deletions = &Apache::loncommon::get_env_multiple('form.HWFILE'.$part.'_'.$id.'_delete'); |
my @deletions = &Apache::loncommon::get_env_multiple('form.HWFILE'.$jspart.'_'.$id.'_delete'); |
my ($is_submit,$was_draft); |
my ($is_submit,$was_draft); |
if ($env{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') { |
if ($env{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') { |
$is_submit = 1; |
$is_submit = 1; |
Line 273 sub format_prior_response {
|
Line 279 sub format_prior_response {
|
} |
} |
if ($answer =~ /\S/) { |
if ($answer =~ /\S/) { |
$output.='<p>'.&mt('Submitted text'). |
$output.='<p>'.&mt('Submitted text'). |
'<blockquote>'.$answer.'</blockquote></p>'; |
'<blockquote>'.&HTML::Entities::encode($answer, '"<>&').'</blockquote></p>'; |
} |
} |
|
|
return '<div class="LC_prior_essay">'.$output.'</div>'; |
return '<div class="LC_prior_essay">'.$output.'</div>'; |
} |
} |
|
|
sub file_submission { |
sub file_submission { |
my ($part,$id,$award,$uploadedflag,$totalsize,$deletions)=@_; |
my ($part,$id,$award,$uploadedflag,$totalsize,$deletions,$context,$info)=@_; |
my $files; |
my $files; |
my $jspart=$part; |
my $jspart=$part; |
$jspart=~s/\./_/g; |
$jspart=~s/\./_/g; |
Line 306 sub file_submission {
|
Line 312 sub file_submission {
|
$port_delete{$file} = 1; |
$port_delete{$file} = 1; |
} elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/\Q$cdom\E/\Q$cnum\E/}) { |
} elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/\Q$cdom\E/\Q$cnum\E/}) { |
$uploaded_delete = $file; |
$uploaded_delete = $file; |
|
} elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/[^/]+$}) { |
|
$uploaded_delete = $file; |
} |
} |
} |
} |
} |
} |
Line 316 sub file_submission {
|
Line 324 sub file_submission {
|
} |
} |
} |
} |
if ($uploaded_delete) { |
if ($uploaded_delete) { |
$Apache::lonhomework::results{"resource.$part.$id.uploadedfile"} = ""; |
if ($uploaded_delete eq $uploadedurl) { |
$Apache::lonhomework::results{"resource.$part.$id.uploadedurl"} = ""; |
$Apache::lonhomework::results{"resource.$part.$id.uploadedfile"} = ""; |
|
$Apache::lonhomework::results{"resource.$part.$id.uploadedurl"} = ""; |
|
} else { |
|
undef($uploaded_delete); |
|
} |
} |
} |
} |
} |
if ($env{'form.HWPORT'.$jspart.'_'.$id} ne '') { |
if ($env{'form.HWPORT'.$jspart.'_'.$id} ne '') { |
Line 331 sub file_submission {
|
Line 343 sub file_submission {
|
} |
} |
} |
} |
} |
} |
if ($env{'form.HWFILETOOBIG'.$jspart.'_'.$id} ne '') { |
if ($env{'form.HWFILETOOBIG'.$part.'_'.$id} ne '') { |
$$award = 'EXCESS_FILESIZE'; |
$$award = 'EXCESS_FILESIZE'; |
} elsif ($env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} ne '') { |
} elsif ($env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} ne '') { |
my $newfile = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'}; |
my $newfile = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'}; |
Line 385 sub file_submission {
|
Line 397 sub file_submission {
|
my ($path,$filename) = ($file =~ m{^(.*/)([^/]+)$}); |
my ($path,$filename) = ($file =~ m{^(.*/)([^/]+)$}); |
my $fullpath = '/userfiles/portfolio'.$path; |
my $fullpath = '/userfiles/portfolio'.$path; |
if (!exists($dirlist{$fullpath})) { |
if (!exists($dirlist{$fullpath})) { |
my @list = &Apache::lonnet::dirlist($fullpath,$udom,$uname,1); |
my ($listref,$listerror) = |
$dirlist{$fullpath} = \@list; |
&Apache::lonnet::dirlist($fullpath,$udom,$uname,1); |
|
if (ref($listref) eq 'ARRAY') { |
|
$dirlist{$fullpath} = $listref; |
|
} |
} |
} |
if (ref($dirlist{$fullpath}) eq 'ARRAY') { |
if (ref($dirlist{$fullpath}) eq 'ARRAY') { |
foreach my $dir_line (@{$dirlist{$fullpath}}) { |
foreach my $dir_line (@{$dirlist{$fullpath}}) { |
Line 429 sub file_submission {
|
Line 444 sub file_submission {
|
} |
} |
} |
} |
if ($accepted_upload ne '') { |
if ($accepted_upload ne '') { |
my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb); |
my ($path,$multiresp) = |
my $turnindir; |
&Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom, |
my %userhash = &Apache::lonnet::userenvironment($udom,$uname,'turnindir'); |
'submission'); |
$turnindir = $userhash{'turnindir'}; |
if ($path eq '') { |
if ($turnindir eq '') { |
$$award = 'INTERNAL_ERROR'; |
$turnindir = &mt('turned in'); |
} else { |
$turnindir =~ s/\W+/_/g; |
if ($multiresp) { |
my %newhash = ( |
$path .= '/'.$jspart.'_'.$id; |
'turnindir' => $turnindir, |
} |
); |
my $prefix = 'portfolio'; |
&Apache::lonnet::put('environment',\%newhash,$udom,$uname); |
my $formelement = 'HWFILE'.$jspart.'_'.$id; |
} |
my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formelement.'.filename'}); |
my $prefix = 'portfolio'; |
my $url = '/uploaded/'.$udom.'/'.$uname.'/'.$prefix.$path.'/'.$fname; |
my $path = '/'.$turnindir.'/'; |
my @stat = &Apache::lonnet::stat_file($url); |
my $restitle=&Apache::lonnet::gettitle($symb); |
my $conflicts = 0; |
$restitle =~ s/\W+/_/g; |
if (@stat && $stat[0] ne 'no_such_dir') { |
if ($restitle eq '') { |
my $current_permissions = |
$restitle = ($resurl =~ m{/[^/]+$}); |
&Apache::lonnet::get_portfile_permissions($udom,$uname); |
if ($restitle eq '') { |
if (ref($current_permissions) eq 'HASH') { |
$restitle = time; |
if (ref($current_permissions->{$path.'/'.$fname}) eq 'ARRAY') { |
} |
foreach my $record (@{$current_permissions->{$path.'/'.$fname}}) { |
} |
if (ref($record) eq 'ARRAY') { |
my @pathitems; |
next if (($record->[0] eq $symb) && |
my $navmap = Apache::lonnavmaps::navmap->new(); |
($record->[1] eq $crsid)); |
if (defined($navmap)) { |
$conflicts ++; |
my $mapres = $navmap->getResourceByUrl($map); |
} |
if (ref($mapres)) { |
|
my $pcslist = $mapres->map_hierarchy(); |
|
if ($pcslist ne '') { |
|
foreach my $pc (split(/,/,$pcslist)) { |
|
my $res = $navmap->getByMapPc($pc); |
|
if (ref($res)) { |
|
my $title = $res->compTitle(); |
|
$title =~ s/\W+/_/g; |
|
if ($title ne '') { |
|
push(@pathitems,$title); |
|
} |
|
} |
} |
} |
} |
} |
} |
my $maptitle = $mapres->compTitle(); |
if ($conflicts) { |
$maptitle =~ s/\W+/_/g; |
$$award = 'FILENAME_INUSE'; |
if ($maptitle ne '') { |
|
push(@pathitems,$maptitle); |
|
} |
} |
} else { |
|
$$award = 'INTERNAL_ERROR'; |
|
} |
} |
} else { |
unless ($conflicts) { |
$$award = 'INTERNAL_ERROR'; |
my ($mode,%allfiles,%codebase); |
} |
my $result = &Apache::lonnet::userfileupload($formelement,'', |
push(@pathitems,$restitle); |
|
$path .= join('/',@pathitems); |
|
my $formelement = 'HWFILE'.$jspart.'_'.$id; |
|
my $fname = $env{'form.'.$formelement.'.filename'}; |
|
&Apache::lonnet::clean_filename($fname); |
|
my $url = '/uploaded/'.$udom.'/'.$uname.'/'.$prefix.$path.'/'.$fname; |
|
my @stat = &Apache::lonnet::stat_file($url); |
|
if (@stat && $stat[0] ne 'no_such_dir') { |
|
$$award = 'FILENAME_INUSE'; |
|
} else { |
|
my ($mode,%allfiles,%codebase); |
|
my $result = &Apache::lonnet::userfileupload($formelement,'', |
|
$prefix.$path,$mode,\%allfiles,\%codebase); |
$prefix.$path,$mode,\%allfiles,\%codebase); |
if ($result =~ m{^/uploaded/}) { |
if ($result =~ m{^/uploaded/}) { |
$stored_upload = $path.'/'.$fname; |
$stored_upload = $path.'/'.$fname; |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = $stored_upload; |
unless (grep(/^\Q$stored_upload\E$/,@accepted_portfiles)) { |
push(@tolock,$stored_upload); |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = $stored_upload; |
} else { |
push(@tolock,$stored_upload); |
$$award = 'INTERNAL_ERROR'; |
} |
|
} else { |
|
$$award = 'INTERNAL_ERROR'; |
|
} |
} |
} |
} |
} |
delete($env{'form.HWFILE'.$jspart.'_'.$id}); |
delete($env{'form.HWFILE'.$jspart.'_'.$id}); |
} |
} |
if (@accepted_portfiles) { |
if (@accepted_portfiles) { |
if ($stored_upload) { |
if ($Apache::lonhomework::results{"resource.$part.$id.portfiles"}) { |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} .= ','; |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} .= ','; |
} |
} |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"}.=join(',',@accepted_portfiles); |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"}.=join(',',@accepted_portfiles); |
Line 515 sub file_submission {
|
Line 506 sub file_submission {
|
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = ""; |
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = ""; |
} |
} |
} |
} |
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"} ne $Apache::lonhomework::results{"resource.$part.$id.portfiles"}) { |
if (($Apache::lonhomework::history{"resource.$part.$id.portfiles"} ne |
|
$Apache::lonhomework::results{"resource.$part.$id.portfiles"}) || |
|
($uploaded_delete)) { |
if (ref($uploadedflag)) { |
if (ref($uploadedflag)) { |
$$uploadedflag=1; |
$$uploadedflag=1; |
} |
} |
} |
} |
|
if ($context eq 'externalresponse') { |
|
my @todelete = map { "/uploaded/$udom/$uname/portfolio".$_; } keys(%port_delete); |
|
if (@tolock || @todelete) { |
|
if (ref($info) eq 'HASH') { |
|
if ($info->{'ip'}) { |
|
my @adds; |
|
if (@tolock) { |
|
@adds = map { "/uploaded/$udom/$uname/portfolio".$_; } @tolock; |
|
} |
|
&Apache::lonnet::automated_portfile_access('ip',\@adds,\@todelete,$info); |
|
} |
|
} |
|
} |
|
} |
&Apache::lonnet::unmark_as_readonly($udom,$uname,[$symb,$crsid]); |
&Apache::lonnet::unmark_as_readonly($udom,$uname,[$symb,$crsid]); |
&Apache::lonnet::mark_as_readonly($udom,$uname,[@tolock],[$symb,$crsid]); |
&Apache::lonnet::mark_as_readonly($udom,$uname,[@tolock],[$symb,$crsid]); |
&Apache::lonnet::clear_selected_files($uname); |
&Apache::lonnet::clear_selected_files($uname); |