--- loncom/homework/lonhomework.pm 2011/12/20 22:46:06 1.334 +++ loncom/homework/lonhomework.pm 2013/08/20 14:37:33 1.339 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.334 2011/12/20 22:46:06 raeburn Exp $ +# $Id: lonhomework.pm,v 1.339 2013/08/20 14:37:33 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -163,7 +163,7 @@ sub get_target { } } # -# End of Construction Space +# End of Authoring Space # } # @@ -508,7 +508,6 @@ sub check_access { # return ('UNCHECKEDOUT','needs to be checked out'); #} - &Apache::lonxml::debug("sending back :$status:$datemsg:"); if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) { &Apache::lonxml::debug("should be allowed to browse a resource when closed"); @@ -608,6 +607,9 @@ sub showhashsubset { sub setuppermissions { $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$env{'request.filename'}); + unless ($Apache::lonhomework::browse eq 'F') { + $Apache::lonhomework::browse=&Apache::lonnet::allowed('bro',$env{'request.filename'}); + } my $viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); if (! $viewgrades && exists($env{'request.course.sec'}) && @@ -667,7 +669,7 @@ sub setupheader { } sub handle_save_or_undo { - my ($request,$problem,$result) = @_; + my ($request,$problem,$result,$getobjref) = @_; my $file = &Apache::lonnet::filelocation("",$request->uri); my $filebak =$file.".bak"; @@ -710,6 +712,30 @@ sub handle_save_or_undo { my $fh=Apache::File->new(">$file"); if (defined($fh)) { print $fh $$result; + if (ref($getobjref) eq 'SCALAR') { + if ($file =~ m{([^/]+)\.(html?)$}) { + my $fname = $1; + my $ext = $2; + my $path = $file; + $path =~ s/\Q$fname\E\.\Q$ext\E$//; + my (%allfiles,%codebase); + &Apache::lonnet::extract_embedded_items($file,\%allfiles, + \%codebase,$result); + if (keys(%allfiles) > 0) { + my $url = $request->uri; + my $state = < + +STATE + $$getobjref = "

".&mt("Reference Warning")."

". + "

".&mt("Completed upload of the file. This file contained references to other files.")."

". + "

".&mt("Please select the locations from which the referenced files are to be uploaded.")."

". + &Apache::loncommon::ask_for_embedded_content($url,$state,\%allfiles,\%codebase, + {'error_on_invalid_names' => 1, + 'ignore_remote_references' => 1,}); + } + } + } } else { &Apache::lonxml::info(''. &mt("Unable to write to [_1]", @@ -728,7 +754,7 @@ sub analyze_header { # Breadcrumbs my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Construction Space'}, + 'text' => 'Authoring Space'}, {'href' => '', 'text' => 'Problem Testing'}, {'href' => '', @@ -779,13 +805,9 @@ sub analyze { my $rndseed=$env{'form.rndseed'}; &analyze_header($request); my %prog_state= - &Apache::lonhtmlcommon::Create_PrgWin($request,&mt('Analyze Progress'), - &mt('Getting Problem Variants'), - $env{'form.numtoanalyze'}, - 'inline',undef); + &Apache::lonhtmlcommon::Create_PrgWin($request,$env{'form.numtoanalyze'}); for(my $i=1;$i<$env{'form.numtoanalyze'}+1;$i++) { - &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state, - &mt('last problem')); + &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,'last problem'); if (&Apache::loncommon::connection_aborted($request)) { return; } my $thisseed=$i+$rndseed; my $subresult=&Apache::lonnet::ssi($request->uri, @@ -794,7 +816,7 @@ sub analyze { (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); my %analyze=&Apache::lonnet::str2hash($subresult); my @parts; - if (defined(@{ $analyze{'parts'} })) { + if (ref($analyze{'parts'}) eq 'ARRAY') { @parts=@{ $analyze{'parts'} }; } foreach my $part (@parts) { @@ -827,15 +849,15 @@ sub analyze { } } } - &Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, - &mt('Analyzing Results')); + &Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state,&mt('Analyzing Results')); $request->print('
' .'

' .&mt('List of possible answers') .'

' ); foreach my $part (sort(keys(%allparts))) { - if (defined(@{ $overall{$part.'.answer'} })) { + if ((ref($overall{$part.'.answer'}) eq 'ARRAY') && + (@{$overall{$part.'.answer'}} > 0)) { for (my $i=0;$iprint(&Apache::loncommon::start_data_table() @@ -966,7 +988,7 @@ sub editxmlmode { # Breadcrumbs my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Construction Space'}, + 'text' => 'Authoring Space'}, {'href' => '', 'text' => 'Problem Editing'}]; @@ -1043,13 +1065,11 @@ sub renderpage { $problem=''; my $filename=(split('/',$file))[-1]; my $error = - '

' - .&mt('Unable to find [_1]', - ''.$filename.'') - ."

"; + &mt('Unable to find [_1]', + ''.$filename.''); $result.= &Apache::loncommon::simple_error_page($request,'Not available', - $error); + $error,{'no_auto_mt_msg'}); return; } @@ -1192,7 +1212,7 @@ sub newproblem { my $errormsg; my $instructions; my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Construction Space'}, + 'text' => 'Authoring Space'}, {'href' => '', 'text' => "Create New $extension"}]; my $start_page =