';
if ($numremref) {
$output .= '- '.&mt('reference is to a URL which points to another server').'
'."\n";
@@ -8699,7 +8631,7 @@ sub ask_for_embedded_content {
$embed_file,\%mapping,
$allfiles,$codebase);
} else {
- $pathchange_output .=
+ $pathchange_output .=
&start_data_table_row().
' | '.
@@ -8718,7 +8650,7 @@ sub ask_for_embedded_content {
$output .= ''."\n";
}
- if (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank') ||
+ if (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank') ||
($actionurl eq '/adm/imsimport')) {
$output .= ''."\n";
} elsif ($actionurl eq '/adm/portfolio' || $actionurl eq '/adm/coursegrp_portfolio') {
@@ -8730,8 +8662,8 @@ sub ask_for_embedded_content {
my %pathchange = ();
$output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output);
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
- $output .= ''.&mt('or').'
';
- }
+ $output .= ''.&mt('or').'
';
+ }
}
return ($output,$num,$numpathchg);
}
@@ -8746,7 +8678,7 @@ sub embedded_file_element {
}
$output .= '';
- unless (($context eq 'upload_embedded') &&
+ unless (($context eq 'upload_embedded') &&
($mapping->{$embed_file} eq $embed_file)) {
$output .='
';
@@ -8847,7 +8779,7 @@ sub upload_embedded {
next;
} else {
$output .= &mt('Uploaded [_1]',''.
- $path.$fname.'').'
';
+ $path.$fname.'').'
';
}
}
} elsif ($context eq 'coursedoc') {
@@ -8954,7 +8886,7 @@ sub modify_html_form {
''.
&end_data_table_row();
- }
+ }
}
} else {
$modifyform = $pathchgtable;
@@ -9005,7 +8937,7 @@ sub modify_html_refs {
$content = &Apache::lonnet::getfile($container);
return if ($content eq '-1');
} else {
- return unless ($container =~ /^\Q$dir_root\E/);
+ return unless ($container =~ /^\Q$dir_root\E/);
if (open(my $fh,"<$container")) {
$content = join('', <$fh>);
close($fh);
@@ -9017,7 +8949,7 @@ sub modify_html_refs {
my $mm = new File::MMagic;
my $mime_type = $mm->checktype_contents($content);
if ($mime_type eq 'text/html') {
- my $parse_result =
+ my $parse_result =
&Apache::lonnet::extract_embedded_items($container,\%allfiles,
\%codebase,\$content);
if ($parse_result eq 'ok') {
@@ -9050,7 +8982,7 @@ sub modify_html_refs {
my ($fname) = ($container =~ m{/([^/]+)$});
$output = ''.&mt('Updated [quant,_1,reference] in [_2].',
$count,''.
- $fname.'').'
';
+ $fname.'').'';
} else {
$output = ''.
&mt('Error: update failed for: [_1].',
@@ -9102,7 +9034,7 @@ sub check_for_upload {
my $filesize = length($env{'form.'.$element});
if (!$filesize) {
my $msg = ''.
- &mt('Unable to upload [_1]. (size = [_2] bytes)',
+ &mt('Unable to upload [_1]. (size = [_2] bytes)',
''.$fname.'',
$filesize).'
'.
&mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'
'.
@@ -9135,7 +9067,7 @@ sub check_for_upload {
if ($crsid eq $env{'request.course.id'}) {
if (ref($navmap)) {
my $res = $navmap->getBySymb($symb);
- foreach my $part (@{$res->parts()}) {
+ foreach my $part (@{$res->parts()}) {
my ($slot_status,$slot_time,$slot_name)=$res->check_for_slot($part);
unless (($slot_status == $res->RESERVED) ||
($slot_status == $res->RESERVED_LOCATION)) {
@@ -9233,6 +9165,113 @@ sub check_for_traversal {
=pod
+=item * &get_turnedin_filepath()
+
+Determines path in a user's portfolio file for storage of files uploaded
+to a specific essayresponse or dropbox item.
+
+Inputs: 3 required + 1 optional.
+$symb is symb for resource, $uname and $udom are for current user (required).
+$caller is optional (can be "submission", if routine is called when storing
+an upoaded file when "Submit Answer" button was pressed).
+
+Returns array containing $path and $multiresp.
+$path is path in portfolio. $multiresp is 1 if this resource contains more
+than one file upload item. Callers of routine should append partid as a
+subdirectory to $path in cases where $multiresp is 1.
+
+Called by: homework/essayresponse.pm and homework/structuretags.pm
+
+=cut
+
+sub get_turnedin_filepath {
+ my ($symb,$uname,$udom,$caller) = @_;
+ my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
+ my $turnindir;
+ my %userhash = &Apache::lonnet::userenvironment($udom,$uname,'turnindir');
+ $turnindir = $userhash{'turnindir'};
+ my ($path,$multiresp);
+ if ($turnindir eq '') {
+ if ($caller eq 'submission') {
+ $turnindir = &mt('turned in');
+ $turnindir =~ s/\W+/_/g;
+ my %newhash = (
+ 'turnindir' => $turnindir,
+ );
+ &Apache::lonnet::put('environment',\%newhash,$udom,$uname);
+ }
+ }
+ if ($turnindir ne '') {
+ $path = '/'.$turnindir.'/';
+ my ($multipart,$turnin,@pathitems);
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (defined($navmap)) {
+ 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();
+ $maptitle =~ s/\W+/_/g;
+ if ($maptitle ne '') {
+ push(@pathitems,$maptitle);
+ }
+ unless ($env{'request.state'} eq 'construct') {
+ my $res = $navmap->getBySymb($symb);
+ if (ref($res)) {
+ my $partlist = $res->parts();
+ my $totaluploads = 0;
+ if (ref($partlist) eq 'ARRAY') {
+ foreach my $part (@{$partlist}) {
+ my @types = $res->responseType($part);
+ my @ids = $res->responseIds($part);
+ for (my $i=0; $i < scalar(@ids); $i++) {
+ if ($types[$i] eq 'essay') {
+ my $partid = $part.'_'.$ids[$i];
+ if (&Apache::lonnet::EXT("resource.$partid.uploadedfiletypes") ne '') {
+ $totaluploads ++;
+ }
+ }
+ }
+ }
+ if ($totaluploads > 1) {
+ $multiresp = 1;
+ }
+ }
+ }
+ }
+ } else {
+ return;
+ }
+ } else {
+ return;
+ }
+ my $restitle=&Apache::lonnet::gettitle($symb);
+ $restitle =~ s/\W+/_/g;
+ if ($restitle eq '') {
+ $restitle = ($resurl =~ m{/[^/]+$});
+ if ($restitle eq '') {
+ $restitle = time;
+ }
+ }
+ push(@pathitems,$restitle);
+ $path .= join('/',@pathitems);
+ }
+ return ($path,$multiresp);
+}
+
+=pod
+
=back
=head1 CSV Upload/Handling functions
@@ -11152,6 +11191,8 @@ sub construct_course {
############################################################
############################################################
+#SD
+# only Community and Course, or anything else?
sub course_type {
my ($cid) = @_;
if (!defined($cid)) {
@@ -11317,15 +11358,12 @@ sub init_user_environment {
my %userenv = &Apache::lonnet::dump('environment',$domain,$username);
my ($tmp) = keys(%userenv);
if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
- # default remote control to off
- if ($userenv{'remote'} ne 'on') { $userenv{'remote'} = 'off'; }
} else {
undef(%userenv);
}
if (($userenv{'interface'}) && (!$form->{'interface'})) {
$form->{'interface'}=$userenv{'interface'};
}
- $env{'environment.remote'}=$userenv{'remote'};
if ($userenv{'texengine'} eq 'ttm') { $clientmathml=1; }
# --------------- Do not trust query string to be put directly into environment
@@ -11357,16 +11395,17 @@ sub init_user_environment {
$initial_env{"browser.localres"} = $form->{'localres'};
}
- if ($public) {
- $initial_env{"environment.remote"} = "off";
- }
if ($form->{'interface'}) {
$form->{'interface'}=~s/\W//gs;
$initial_env{"browser.interface"} = $form->{'interface'};
$env{'browser.interface'}=$form->{'interface'};
}
+
my %is_adv = ( is_adv => $env{'user.adv'} );
- my %domdef = &Apache::lonnet::get_domain_defaults($domain);
+ my %domdef;
+ unless ($domain eq 'public') {
+ %domdef = &Apache::lonnet::get_domain_defaults($domain);
+ }
foreach my $tool ('aboutme','blog','portfolio') {
$userenv{'availabletools.'.$tool} =