version 1.109, 2010/08/22 19:00:15
|
version 1.128, 2025/03/02 05:22:43
|
Line 47 sub start_essayresponse {
|
Line 47 sub start_essayresponse {
|
my $id = &Apache::response::start_response($parstack,$safeeval); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
if ($target eq 'meta') { |
if ($target eq 'meta') { |
$result=&Apache::response::meta_package_write('essayresponse'); |
$result=&Apache::response::meta_package_write('essayresponse'); |
} elsif ($target eq 'web' && |
} elsif ($target eq 'web') { |
$Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
my $part= $Apache::inputtags::part; |
my $part= $Apache::inputtags::part; |
my $coll; |
my $ncol= &Apache::lonnet::EXT("resource.$part".'_'."$id.maxcollaborators"); |
if ($Apache::lonhomework::history{"resource.$part.$id.collaborators"} =~ /\S/) { |
my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"'); |
$coll = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"'); |
my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes"); |
} |
$uploadedfiletypes=~s/[^\w\,]//g; |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
my $maxfilesize=&Apache::lonnet::EXT("resource.$part".'_'."$id.maxfilesize"); |
my $ncol= &Apache::lonnet::EXT("resource.$part".'_'."$id.maxcollaborators"); |
if (!defined($maxfilesize)) { |
my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes"); |
$maxfilesize = 10.0; #FIXME This should become a domain configuration |
$uploadedfiletypes=~s/[^\w\,]//g; |
|
my $maxfilesize=&Apache::lonnet::EXT("resource.$part".'_'."$id.maxfilesize"); |
|
if (!defined($maxfilesize)) { |
|
$maxfilesize = 10.0; #FIXME This should become a domain configuration |
|
} |
|
my $hiddendraft; |
|
if (($Apache::lonhomework::type eq 'survey') || |
|
($Apache::lonhomework::type eq 'surveycred') || |
|
($Apache::lonhomework::type eq 'anonsurvey') || |
|
($Apache::lonhomework::type eq 'anonsurveycred')) { |
|
$hiddendraft = '<input type="hidden" name="HWDRAFT'.$part.'_'.$id.'" value="yes" />'; |
|
} else { |
|
$result = &draft_row($part,$id,$ncol,$uploadedfiletypes,'essayresponse'); |
|
} |
|
if ($ncol > 0) { |
|
$result .= &get_collab_row($part,$id,$coll,$ncol); |
|
} |
|
my $filesfrom = 'both'; |
|
my $stuname = &Apache::lonnet::EXT('user.name'); |
|
my $studom = &Apache::lonnet::EXT('user.domain'); |
|
if (!&Apache::lonnet::usertools_access($stuname,$studom,'portfolio')) { |
|
$filesfrom = 'uploadonly'; |
|
} |
|
$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes, |
|
$filesfrom,undef,$maxfilesize); |
|
if ($result) { |
|
$result = |
|
'<div>'.$hiddendraft. |
|
&Apache::lonhtmlcommon::start_pick_box(). |
|
$result. |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'; |
|
} else { |
|
$result = $hiddendraft; |
|
} |
|
} else { |
|
$result = &show_status_table($part,$id,$coll); |
} |
} |
if (($Apache::lonhomework::type eq 'survey') || |
} |
($Apache::lonhomework::type eq 'surveycred') || |
return $result; |
($Apache::lonhomework::type eq 'anonsurvey') || |
} |
($Apache::lonhomework::type eq 'anonsurveycred')) { |
|
$result.= '<input type="hidden" name="HWDRAFT'.$part.'_'.$id.'" value="yes" />'; |
|
} |
|
my $status_text = &mt('Submission type'); |
|
if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') { |
|
$status_text .= '<br />'.&mt('(Currently -- draft)'); |
|
} |
|
$result.= '<p>'.&Apache::lonhtmlcommon::start_pick_box(). |
|
&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; |
|
unless ($ncol || $uploadedfiletypes) { |
|
$closure = 1; |
|
} |
|
$result.= |
|
'<label>'. |
|
'<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="yes" checked="checked" /> '. |
|
&mt('Submit entries below as answer to receive credit'). |
|
'</label> <br />'. |
|
'<label>'. |
|
'<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="no" /> '. |
|
&mt('Save entries below (not submitted for credit yet)'). |
|
'</label>'. |
|
&Apache::lonhtmlcommon::row_closure($closure); |
|
} |
|
|
|
if ($ncol > 0) { |
sub draft_row { |
$result.= &Apache::lonhtmlcommon::row_title(&mt('Collaborators')). |
my ($part,$id,$ncol,$uploadedfiletypes,$resptype) = @_; |
'<label>'. |
my $status_text = &mt('Submission type'); |
&mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'. |
if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') { |
$part.'_'.$id.'" value="'.$coll.'" /><br />'. |
$status_text .= '<br />'.&mt('(Currently -- draft)'); |
&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) { |
my $closure; |
$result .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.'); |
unless ($ncol || $uploadedfiletypes) { |
} |
$closure = 1; |
$result .= '</label><br />'; |
} |
$result .= &check_collaborators($ncol,$coll) if ($coll =~ /\w+/); |
my %label = ( |
$result .= &Apache::lonhtmlcommon::row_closure(); |
draft => { |
} |
essayresponse => &mt('Save entries below (not submitted for credit yet)'), |
my $filesfrom = 'both'; |
externalresponse => &mt('Save entries below (not submitted for grading yet)'), |
my $stuname = &Apache::lonnet::EXT('user.name'); |
}, |
my $studom = &Apache::lonnet::EXT('user.domain'); |
submit => { |
if (!&Apache::lonnet::usertools_access($stuname,$studom,'portfolio')) { |
essayresponse => &mt('Submit entries below as answer to receive credit'), |
$filesfrom = 'uploadonly'; |
externalresponse => &mt('Submit entries below for grading'), |
} |
} |
$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes, |
); |
$filesfrom,undef,$maxfilesize); |
return &Apache::lonhtmlcommon::row_title($status_text). |
$result.=&Apache::lonhtmlcommon::end_pick_box().'</p>'; |
'<fieldset class="LC_landmark">'. |
} elsif ($target eq 'web' && |
'<legend class="LC_visually_hidden">'.$status_text.'</legend>'. |
$Apache::inputtags::status[-1] ne 'CAN_ANSWER') { |
'<div><label><input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="yes" checked="checked" />'. |
my $part= $Apache::inputtags::part; |
' '.$label{'submit'}{$resptype}.'</label></div>'. |
my @msgs; |
'<div><label>'. |
if ($Apache::lonhomework::history{"resource.$part.$id.collaborators"} =~ /\S/) { |
'<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="no" /> '. |
my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"'); |
$label{'draft'}{$resptype}.'</label></div></fieldset>'. |
$result .= '<td><i>'.&mt('Collaborated with [_1]',$coll).'</i></td>'; |
&Apache::lonhtmlcommon::row_closure($closure); |
} |
} |
|
|
my $current_files_display = &Apache::inputtags::current_file_submissions($part,$id); |
sub get_collab_row { |
if ($current_files_display) { |
my ($part,$id,$coll,$ncol,$closure) = @_; |
$result .= '<td><b>'.&mt('Submitted files:').'</b><br />'. |
my $output = &Apache::lonhtmlcommon::row_title(&mt('Collaborators')). |
$current_files_display.'</td>'; |
'<label>'. |
} |
&mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'. |
|
$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'}); |
|
if ($ncol > 1) { |
|
$output .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.'); |
|
} |
|
$output .= '</label><br />'; |
|
$output .= &check_collaborators($ncol,$coll) if ($coll =~ /\w+/); |
|
$output .= &Apache::lonhtmlcommon::row_closure($closure); |
|
return $output; |
|
} |
|
|
if ($result ne '') { |
sub show_status_table { |
$result = |
my ($part,$id,$coll) = @_; |
'<table class="LC_pastsubmission"><tr>'.$result. |
my $output; |
'</tr></table>'; |
if ($coll) { |
} |
my $udom = $env{'user.domain'}; |
|
my $uname = $env{'user.name'}; |
|
my @collaborators; |
|
foreach my $possible_collaborator |
|
(split(/[,;\s]+/,$coll)) { |
|
$possible_collaborator =~ s/[\$\^\(\)]//g; |
|
next if ($possible_collaborator eq ''); |
|
my ($co_name,$co_dom) = split(/:/,$possible_collaborator); |
|
$co_dom = $udom if (! defined($co_dom) || $co_dom =~ /^domain$/i); |
|
next if ($co_name eq $uname && $co_dom eq $udom); |
|
push(@collaborators,$possible_collaborator); |
|
} |
|
if (@collaborators) { |
|
$output = '<div style="display: inline-block; float: left">'."\n". |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::data_table_caption(&mt('Collaborators'),'LC_filesub_status'). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Username').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row()."\n"; |
|
foreach my $user (@collaborators) { |
|
$output .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$user.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
$output .= &Apache::loncommon::end_data_table().'</div>'; |
|
} |
|
} |
|
my $current_files_display = |
|
&Apache::inputtags::current_file_submissions($part,$id,'',&mt('Submitted files')); |
|
if ($current_files_display) { |
|
$output .= '<div style="display: inline-block; float:left;">'. |
|
$current_files_display.'</div>'; |
|
} |
|
if ($output ne '') { |
|
return '<div style="padding:0;clear:both;margin:0;border:0"></div>'. |
|
$output. |
|
'<div style="padding:0;clear:both;margin:0;border:0"></div>'; |
} |
} |
return $result; |
return; |
} |
} |
|
|
sub end_essayresponse { |
sub end_essayresponse { |
Line 143 sub end_essayresponse {
|
Line 197 sub end_essayresponse {
|
my $increment = &Apache::response::repetition(); |
my $increment = &Apache::response::repetition(); |
my $result; |
my $result; |
if ( $target eq 'grade' ) { |
if ( $target eq 'grade' ) { |
# Deal with collaborators |
&get_collaborators($part,$id); |
my $collaborators = $env{'form.HWCOL'.$part.'_'.$id}; |
|
my $previous_list= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"'); |
|
if ($collaborators ne $previous_list) { |
|
# &Apache::lonnet::logthis("New collaborators [$collaborators] [$previous_list]"); |
|
$Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators; |
|
} |
|
# Scantron |
# Scantron |
if ( &Apache::response::submitted('scantron') ) { |
if ( &Apache::response::submitted('scantron') ) { |
$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 204 sub end_essayresponse {
|
Line 254 sub end_essayresponse {
|
&escape($crsid)); |
&escape($crsid)); |
my $essayurl= |
my $essayurl= |
&Apache::lonnet::declutter($ENV{'REQUEST_URI'}); |
&Apache::lonnet::declutter($ENV{'REQUEST_URI'}); |
my ($adom,$aname,$apath)= |
if ($essayurl eq 'lib/templates/simpleproblem.problem') { |
($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/); |
my %crsinfo = &Apache::lonnet::coursedescription($crsid); |
$apath=&escape($apath); |
my $cdom = $crsinfo{'domain'}; |
$apath=~s/\W/\_/gs; |
my $cnum = $crsinfo{'num'}; |
&Apache::lonnet::put('nohist_essay_'.$apath, |
my ($map,$id,$res) = &Apache::lonnet::decode_symb($symb); |
{ $akey => $response },$adom,$aname); |
if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(default(?:|_\d+)\.(?:sequence|page))$}) { |
} |
my $apath = $1.'_'.$id; |
|
$apath=~s/\W/\_/gs; |
|
my $akey = join('.',&escape($name),&escape($domain)); |
|
&Apache::lonnet::put('nohist_essay_'.$apath, |
|
{ $akey => $response },$cdom,$cnum); |
|
} |
|
} else { |
|
my ($adom,$aname,$apath)= |
|
($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/); |
|
$apath=&escape($apath); |
|
$apath=~s/\W/\_/gs; |
|
&Apache::lonnet::put('nohist_essay_'.$apath, |
|
{ $akey => $response },$adom,$aname); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::end_table(); |
$result.=&Apache::edit::end_table(); |
|
|
Line 249 sub end_essayresponse {
|
Line 313 sub end_essayresponse {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub get_collaborators { |
|
my ($part,$id) = @_; |
|
my $collaborators = $env{'form.HWCOL'.$part.'_'.$id}; |
|
my $previous_list= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"' |
|
); |
|
if ($collaborators ne $previous_list) { |
|
$Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators; |
|
} |
|
} |
|
|
sub format_prior_response { |
sub format_prior_response { |
my ($mode,$answer,$other_data) = @_; |
my ($mode,$answer,$other_data) = @_; |
my $output; |
my $output; |
Line 273 sub format_prior_response {
|
Line 347 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 295 sub file_submission {
|
Line 369 sub file_submission {
|
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"} || |
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"} || |
$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}) { |
$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}) { |
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}) { |
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}) { |
@portfiles = split(/,/,$Apache::lonhomework::history{"resource.$part.$id.portfiles"}); |
my @possfiles = split(/,/,$Apache::lonhomework::history{"resource.$part.$id.portfiles"}); |
|
foreach my $file (@possfiles) { |
|
my ($path,$name) = ($file =~ m{^(.*/)([^/]+)$}); |
|
my ($origname,$version,$ext) = &Apache::lonnet::file_name_version_ext($name); |
|
unless ($version) { |
|
push(@portfiles,$file); |
|
} |
|
} |
} |
} |
$uploadedurl = $Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}; |
$uploadedurl = $Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}; |
if (ref($deletions) eq 'ARRAY') { |
if (ref($deletions) eq 'ARRAY') { |
Line 306 sub file_submission {
|
Line 387 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 399 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 418 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 472 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 519 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 581 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'}) && ($info->{'is_submit'})) { |
|
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); |
Line 603 described at http://www.lon-capa.org.
|
Line 685 described at http://www.lon-capa.org.
|
|
|
=item start_essayresponse() |
=item start_essayresponse() |
|
|
|
=item draft_row() |
|
|
|
=item get_collab_row() |
|
|
|
=item show_status_table() |
|
|
=item end_essayresponse() |
=item end_essayresponse() |
|
|
|
=item get_collaborators() |
|
|
=item format_prior_response() |
=item format_prior_response() |
|
|
=item file_submission() |
=item file_submission() |