Diff for /loncom/homework/lonhomework.pm between versions 1.335 and 1.338

version 1.335, 2011/12/21 21:25:36 version 1.338, 2013/06/04 22:20:24
Line 163  sub get_target { Line 163  sub get_target {
     }      }
         }          }
 #  #
 # End of Construction Space  # End of Authoring Space
 #  #
     }      }
 #  #
Line 508  sub check_access { Line 508  sub check_access {
   #    return ('UNCHECKEDOUT','needs to be checked out');    #    return ('UNCHECKEDOUT','needs to be checked out');
   #}    #}
   
   
     &Apache::lonxml::debug("sending back :$status:$datemsg:");      &Apache::lonxml::debug("sending back :$status:$datemsg:");
     if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) {      if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) {
  &Apache::lonxml::debug("should be allowed to browse a resource when closed");   &Apache::lonxml::debug("should be allowed to browse a resource when closed");
Line 608  sub showhashsubset { Line 607  sub showhashsubset {
   
 sub setuppermissions {  sub setuppermissions {
     $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$env{'request.filename'});      $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'});      my $viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
     if (! $viewgrades &&       if (! $viewgrades && 
  exists($env{'request.course.sec'}) &&    exists($env{'request.course.sec'}) && 
Line 667  sub setupheader { Line 669  sub setupheader {
 }  }
   
 sub handle_save_or_undo {  sub handle_save_or_undo {
     my ($request,$problem,$result) = @_;      my ($request,$problem,$result,$getobjref) = @_;
   
     my $file    = &Apache::lonnet::filelocation("",$request->uri);      my $file    = &Apache::lonnet::filelocation("",$request->uri);
     my $filebak =$file.".bak";      my $filebak =$file.".bak";
Line 710  sub handle_save_or_undo { Line 712  sub handle_save_or_undo {
  my $fh=Apache::File->new(">$file");   my $fh=Apache::File->new(">$file");
  if (defined($fh)) {   if (defined($fh)) {
     print $fh $$result;      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;
       <input type="hidden" name="action" value="upload_embedded" />
       <input type="hidden" name="url" value="$url" />
   STATE
                           $$getobjref = "<h3>".&mt("Reference Warning")."</h3>".
                                         "<p>".&mt("Completed upload of the file. This file contained references to other files.")."</p>".
                                         "<p>".&mt("Please select the locations from which the referenced files are to be uploaded.")."</p>".
                                         &Apache::loncommon::ask_for_embedded_content($url,$state,\%allfiles,\%codebase,
                                         {'error_on_invalid_names'   => 1,
                                          'ignore_remote_references' => 1,});
                       }
                   }
               }
  } else {   } else {
     &Apache::lonxml::info('<span class="LC_error">'.      &Apache::lonxml::info('<span class="LC_error">'.
   &mt("Unable to write to [_1]",    &mt("Unable to write to [_1]",
Line 728  sub analyze_header { Line 754  sub analyze_header {
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),      my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                    'text' => 'Construction Space'},                     'text' => 'Authoring Space'},
                   {'href' => '',                    {'href' => '',
                    'text' => 'Problem Testing'},                     'text' => 'Problem Testing'},
                   {'href' => '',                    {'href' => '',
Line 790  sub analyze { Line 816  sub analyze {
  (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);   (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);
  my %analyze=&Apache::lonnet::str2hash($subresult);   my %analyze=&Apache::lonnet::str2hash($subresult);
  my @parts;   my @parts;
  if (defined(@{ $analyze{'parts'} })) {          if (ref($analyze{'parts'}) eq 'ARRAY') {
     @parts=@{ $analyze{'parts'} };      @parts=@{ $analyze{'parts'} };
  }   }
  foreach my $part (@parts) {   foreach my $part (@parts) {
Line 830  sub analyze { Line 856  sub analyze {
                    .'</h3>'                     .'</h3>'
     );      );
     foreach my $part (sort(keys(%allparts))) {      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;$i<scalar(@{ $overall{$part.'.answer'} });$i++) {      for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) {
  my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] });   my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] });
                 $request->print(&Apache::loncommon::start_data_table()                  $request->print(&Apache::loncommon::start_data_table()
Line 961  sub editxmlmode { Line 988  sub editxmlmode {
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),      my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                    'text' => 'Construction Space'},                     'text' => 'Authoring Space'},
                   {'href' => '',                    {'href' => '',
                    'text' => 'Problem Editing'}];                     'text' => 'Problem Editing'}];
   
Line 1187  sub newproblem { Line 1214  sub newproblem {
  my $errormsg;   my $errormsg;
  my $instructions;   my $instructions;
         my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),          my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                        'text' => 'Construction Space'},                         'text' => 'Authoring Space'},
                       {'href' => '',                        {'href' => '',
                        'text' => "Create New $extension"}];                         'text' => "Create New $extension"}];
  my $start_page =    my $start_page = 

Removed from v.1.335  
changed lines
  Added in v.1.338


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>