Diff for /loncom/homework/lonhomework.pm between versions 1.337 and 1.344.2.1

version 1.337, 2013/04/01 21:40:14 version 1.344.2.1, 2015/03/12 01:26:55
Line 163  sub get_target { Line 163  sub get_target {
     }      }
         }          }
 #  #
 # End of Construction Space  # End of Authoring Space
 #  #
     }      }
 #  #
Line 451  sub check_access { Line 451  sub check_access {
     $datemsg=$date;      $datemsg=$date;
  } elsif ($type eq 'opendate') {   } elsif ($type eq 'opendate') {
     $status='CLOSED';      $status='CLOSED';
     $datemsg = &mt("will open on")." $date";      $datemsg = &mt('will open on [_1]',$date);
  } elsif ($type eq 'duedate') {   } elsif ($type eq 'duedate') {
     $status='CAN_ANSWER';      $status='CAN_ANSWER';
     $datemsg = &mt("is due at")." $date";      $datemsg = &mt('is due at [_1]',$date);
  } elsif ($type eq 'answerdate') {   } elsif ($type eq 'answerdate') {
     $status='CLOSED';      $status='CLOSED';
     $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date";      $datemsg = &mt('was due on [_1], and answers will be available on [_2]',
                                  $lastdate,$date);
  }   }
     }      }
     if ($status eq 'CAN_ANSWER' ||      if ($status eq 'CAN_ANSWER' ||
Line 468  sub check_access { Line 469  sub check_access {
  if ( $tries eq '' ) { $tries = '0'; }   if ( $tries eq '' ) { $tries = '0'; }
  if ( $maxtries eq '' &&    if ( $maxtries eq '' && 
      $env{'request.state'} ne 'construct') { $maxtries = '2'; }        $env{'request.state'} ne 'construct') { $maxtries = '2'; } 
  $Apache::lonhomework::results{'resource.'.$id.'.maxtries'}=$maxtries;  
  if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }   if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }
  # if (correct and show prob status) or excused then CANNOT_ANSWER   # if (correct and show prob status) or excused then CANNOT_ANSWER
  if ( ($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/)   if ( ($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/)
Line 540  sub due_date { Line 540  sub due_date {
     } else {      } else {
  $date = $due_date;   $date = $due_date;
     }      }
     return $date      return $date;
 }  }
   
 sub seconds_to_human_length {  sub seconds_to_human_length {
Line 589  sub showarray { Line 589  sub showarray {
 sub showhashsubset {  sub showhashsubset {
     my ($hash,$keyre) = @_;      my ($hash,$keyre) = @_;
     my $resultkey;      my $resultkey;
     foreach $resultkey (sort keys %$hash) {      foreach $resultkey (sort(keys(%$hash))) {
  if ($resultkey !~ /$keyre/) { next; }   if ($resultkey !~ /$keyre/) { next; }
  if (ref($$hash{$resultkey})  eq 'ARRAY' ) {   if (ref($$hash{$resultkey})  eq 'ARRAY' ) {
     &Apache::lonxml::debug("$resultkey ---- ".      &Apache::lonxml::debug("$resultkey ---- ".
Line 669  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 712  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 730  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 964  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 1041  sub renderpage { Line 1065  sub renderpage {
     $problem='';      $problem='';
     my $filename=(split('/',$file))[-1];      my $filename=(split('/',$file))[-1];
     my $error =      my $error =
  '<p class="LC_error">'                  &mt('Unable to find [_1]',
                .&mt('Unable to find [_1]',     '<span class="LC_filename">'.$filename.'</span>');
    '<span class="LC_filename">'.$filename.'</span>')  
  ."</p>";  
     $result.=      $result.=
  &Apache::loncommon::simple_error_page($request,'Not available',   &Apache::loncommon::simple_error_page($request,'Not available',
       $error);        $error,{'no_auto_mt_msg' => 1});
     return;      return;
  }   }
   
Line 1108  sub get_template_list { Line 1130  sub get_template_list {
      '/templates/*.'.$glob_extension);       '/templates/*.'.$glob_extension);
     @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')),      @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')),
                       (&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')),                        (&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')),
                       &mt(&Apache::lonnet::metadata($_, 'help'))]} (@files);                        &Apache::lonnet::metadata($_, 'help')]} (@files);
     @files = sort {$a->[2].$a->[1] cmp $b->[2].$b->[1]} (@files);      @files = sort {$a->[2].$a->[1] cmp $b->[2].$b->[1]} (@files);
     my ($midpoint,$seconddiv,$numfiles);      my ($midpoint,$seconddiv,$numfiles);
       my @noexamplelink = ('blank.problem','blank.library','script.library');
     $numfiles = 0;      $numfiles = 0;
     foreach my $file (@files) {      foreach my $file (@files) {
         next if ($file->[1] !~ /\S/);          next if ($file->[1] !~ /\S/);
Line 1149  sub get_template_list { Line 1172  sub get_template_list {
         if ($file->[3]) {          if ($file->[3]) {
            $result.=&Apache::loncommon::help_open_topic($file->[3]);             $result.=&Apache::loncommon::help_open_topic($file->[3]);
         }          }
           # Provide example link
         my $filename=$file->[0];          my $filename=$file->[0];
         $filename=~s{^\Q$londocroot\E}{};          $filename=~s{^\Q$londocroot\E}{};
         $result.=' <span class="LC_fontsize_small">'          if (!(grep($filename =~ /\Q$_\E$/,@noexamplelink))) {
                 .&Apache::loncommon::modal_link($filename.'?inhibitmenu=yes',&mt('Example'),600,420,'sample')              $result .= ' <span class="LC_fontsize_small">'
                 .'</span><br />'."\n";                        .&Apache::loncommon::modal_link(
                              $filename.'?inhibitmenu=yes',&mt('Example'),600,420,'sample')
                         .'</span>';
           }
           $result .= '<br />'."\n";
         $count ++;          $count ++;
     }      }
     if ($numfiles > 0) {      if ($numfiles > 0) {
Line 1190  sub newproblem { Line 1218  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.337  
changed lines
  Added in v.1.344.2.1


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