Diff for /loncom/homework/lonhomework.pm between versions 1.317.4.4 and 1.332

version 1.317.4.4, 2011/10/06 12:32:52 version 1.332, 2011/12/08 01:34:47
Line 112  sub get_target { Line 112  sub get_target {
  } elsif ( $env{'form.grade_target'} eq 'webgrade'   } elsif ( $env{'form.grade_target'} eq 'webgrade'
   && ($Apache::lonhomework::queuegrade eq 'F' )) {    && ($Apache::lonhomework::queuegrade eq 'F' )) {
     return ($env{'form.grade_target'});      return ($env{'form.grade_target'});
         } elsif ($env{'form.grade_target'} eq 'answer') {   } elsif ($env{'form.grade_target'} eq 'answer') {
             if ($env{'form.answer_output_mode'} eq 'tex') {              if ($env{'form.answer_output_mode'} eq 'tex') {
                 return ($env{'form.grade_target'});                  return ($env{'form.grade_target'});
             }              }
Line 146  sub get_target { Line 146  sub get_target {
     }      }
  } else {   } else {
     if ($env{'form.problemstate'} eq 'WEB_GRADE') {      if ($env{'form.problemstate'} eq 'WEB_GRADE') {
                 return ('grade','webgrade','answer');   return ('grade','webgrade','answer');
             } elsif ($env{'form.problemmode'} eq 'view') {              } elsif ($env{'form.problemmode'} eq 'view') {
                 return ('grade','web','answer');                  return ('grade','web','answer');
             } elsif ($env{'form.problemmode'} eq 'saveview') {      } elsif ($env{'form.problemmode'} eq 'saveview') {
                 return ('modified','web','answer');                  return ('modified','web','answer');
             } elsif ($env{'form.problemmode'} eq 'discard') {              } elsif ($env{'form.problemmode'} eq 'discard') {
                 return ('web','answer');                  return ('web','answer');
Line 157  sub get_target { Line 157  sub get_target {
                      ($env{'form.problemmode'} eq 'undo')) {                       ($env{'form.problemmode'} eq 'undo')) {
                 return ('modified','no_output_web','edit');                  return ('modified','no_output_web','edit');
             } elsif ($env{'form.problemmode'} eq 'edit') {              } elsif ($env{'form.problemmode'} eq 'edit') {
                 return ('no_output_web','edit');   return ('no_output_web','edit');
             } else {      } else {
                 return ('web');   return ('web');
             }      }
  }          }
 #  #
 # End of Construction Space  # End of Construction Space
 #  #
Line 178  sub setup_vars { Line 178  sub setup_vars {
 #  return ';$external::target='.$target.';';  #  return ';$external::target='.$target.';';
 }  }
   
 sub createmenu {  
     my ($which,$request)=@_;  
     if ($which eq 'grade') {  
  $request->print('<script type="text/javascript" language="JavaScript">   
           hwkmenu=window.open("/res/adm/pages/homeworkmenu.html","homeworkremote",  
                  "height=350,width=150,menubar=no");  
           </script>');  
     }  
 }  
   
 sub proctor_checked_in {  sub proctor_checked_in {
     my ($slot_name,$slot,$type)=@_;      my ($slot_name,$slot,$type)=@_;
     my @possible_proctors=split(",",$slot->{'proctor'});      my @possible_proctors=split(",",$slot->{'proctor'});
Line 386  sub check_access { Line 376  sub check_access {
     $date=&mt("can not be accessed from your location.");      $date=&mt("can not be accessed from your location.");
     return($status,$date);      return($status,$date);
  }   }
    if ($env{'form.grade_imsexport'}) {
               if (($env{'request.course.id'}) && 
                   (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
                   return ('SHOW_ANSWER');
               }
           }
  foreach my $temp ("opendate","duedate","answerdate") {   foreach my $temp ("opendate","duedate","answerdate") {
     $lastdate = $date;      $lastdate = $date;
     if ($temp eq 'duedate') {      if ($temp eq 'duedate') {
Line 444  sub check_access { Line 439  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/)
     &&        && (&show_problem_status()) ) {
     &show_problem_status())              if (&Apache::inputtags::grading_is_nonlenient($id) || 
    ||                  $Apache::lonhomework::history{"resource.$id.awarded"} == 1) {
    $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {          $status = 'CANNOT_ANSWER';
               }
           } elsif ($Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {
     $status = 'CANNOT_ANSWER';      $status = 'CANNOT_ANSWER';
  }   }
  if ($status eq 'CANNOT_ANSWER'   if ($status eq 'CANNOT_ANSWER'
Line 700  sub analyze_header { Line 698  sub analyze_header {
     my $js = &Apache::structuretags::setmode_javascript();      my $js = &Apache::structuretags::setmode_javascript();
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => &Apache::loncommon::authorspace(),      my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                    'text' => 'Construction Space'},                     'text' => 'Construction Space'},
                   {'href' => '',                    {'href' => '',
                    'text' => 'Problem Testing'},                     'text' => 'Problem Testing'},
Line 913  sub editxmlmode { Line 911  sub editxmlmode {
   
  $problem='';   $problem='';
     }      }
   
     if (($env{'form.problemmode'} eq 'saveeditxml') ||      if (($env{'form.problemmode'} eq 'saveeditxml') ||
         ($env{'form.problemmode'} eq 'saveviewxml') ||          ($env{'form.problemmode'} eq 'saveviewxml') || 
         ($env{'form.problemmode'} eq 'undoxml')) {          ($env{'form.problemmode'} eq 'undoxml')) {
  my $error=&handle_save_or_undo($request,\$problem,   my $error=&handle_save_or_undo($request,\$problem,
        \$env{'form.editxmltext'});         \$env{'form.editxmltext'});
Line 935  sub editxmlmode { Line 934  sub editxmlmode {
     &Apache::loncommon::resize_textarea_js().      &Apache::loncommon::resize_textarea_js().
             &Apache::structuretags::setmode_javascript().              &Apache::structuretags::setmode_javascript().
             &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");              &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
  my $only_body =  ($env{'environment.remote'} eq 'off')? 0 : 1;  
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => &Apache::loncommon::authorspace(),      my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                    'text' => 'Construction Space'},                     'text' => 'Construction Space'},
                   {'href' => '',                    {'href' => '',
                    'text' => 'Problem Editing'}];                     'text' => 'Problem Editing'}];
Line 946  sub editxmlmode { Line 944  sub editxmlmode {
  my $start_page =    my $start_page = 
     &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,      &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,
    {'no_auto_mt_title' => 1,     {'no_auto_mt_title' => 1,
     'only_body'        => $only_body,      'only_body'        => 0,
     'add_entries'      => {      'add_entries'      => {
  'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],   'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],
  'onload'   => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],   'onload'   => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],
                                     },                                                                    },
                                                 'bread_crumbs' => $brcrum,                                                  'bread_crumbs' => $brcrum,
                                            });                                               });
   
     $result=$start_page      $result=$start_page
            .&Apache::loncommon::head_subbox(             .&Apache::loncommon::head_subbox(
Line 971  sub editxmlmode { Line 969  sub editxmlmode {
   
          $result.='<input type="hidden" name="problemmode" value="saveedit" />'.           $result.='<input type="hidden" name="problemmode" value="saveedit" />'.
                   &Apache::structuretags::problem_edit_buttons('editxml');                    &Apache::structuretags::problem_edit_buttons('editxml');
            
          $result.='<hr style="clear:both;" />'.&Apache::lonxml::message_location().'</div>'.           $result.='<hr style="clear:both;" />'.&Apache::lonxml::message_location().'</div>'.  
                   '<textarea '.&Apache::edit::element_change_detection().                    '<textarea '.&Apache::edit::element_change_detection().
               ' rows="'.$rows.'" cols="'.$cols.'" style="width:100%" '.                ' rows="'.$rows.'" cols="'.$cols.'" style="width:100%" '.
       ' name="editxmltext" id="LC_editxmltext">'.        ' name="editxmltext" id="LC_editxmltext">'.
Line 1016  sub renderpage { Line 1014  sub renderpage {
     $problem='';      $problem='';
     my $filename=(split('/',$file))[-1];      my $filename=(split('/',$file))[-1];
     my $error =      my $error =
                 '<p class="LC_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>";   ."</p>";
     $result.=      $result.=
Line 1101  sub get_template_list { Line 1099  sub get_template_list {
     my $count = 0;      my $count = 0;
     my $currentcategory='';      my $currentcategory='';
     my $first = 1;      my $first = 1;
       my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
     foreach my $file (@files) {      foreach my $file (@files) {
  next if ($file->[1] !~ /\S/);   next if ($file->[1] !~ /\S/);
         if ($file->[2] ne $currentcategory) {          if ($file->[2] ne $currentcategory) {
Line 1124  sub get_template_list { Line 1123  sub get_template_list {
            $result.=&Apache::loncommon::help_open_topic($file->[3]);             $result.=&Apache::loncommon::help_open_topic($file->[3]);
         }          }
         my $filename=$file->[0];          my $filename=$file->[0];
         $filename=~s/^\/home\/httpd\/html//;          $filename=~s{^\Q$londocroot\E}{};
         $result.=' <span class="LC_fontsize_small">'          $result.=' <span class="LC_fontsize_small">'
                 .'<a href="'.$filename.'?inhibitmenu=yes" target="sample">'.&mt('Example').'</a>'                  .&Apache::loncommon::modal_link($filename.'?inhibitmenu=yes',&mt('Example'),600,420,'sample')
                 .'</span><br />'."\n";                  .'</span><br />'."\n";
         $count ++;          $count ++;
     }      }
Line 1160  sub newproblem { Line 1159  sub newproblem {
  &renderpage($request,$dest);   &renderpage($request,$dest);
     } else {      } else {
  my $url=&HTML::Entities::encode($request->uri,'<>&"');   my $url=&HTML::Entities::encode($request->uri,'<>&"');
  my $shownurl=$url;  
  $shownurl=~s-^/~-/priv/-;  
  my $dest = &Apache::lonnet::filelocation("",$request->uri);   my $dest = &Apache::lonnet::filelocation("",$request->uri);
  my $errormsg;   my $errormsg;
  my $instructions;   my $instructions;
         my $brcrum = [{'href' => &Apache::loncommon::authorspace(),          my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                        'text' => 'Construction Space'},                         'text' => 'Construction Space'},
                       {'href' => '',                        {'href' => '',
                        'text' => "Create New $extension"}];                         'text' => "Create New $extension"}];
Line 1180  sub newproblem { Line 1177  sub newproblem {
        .'<h1>'.&mt("Creating a new $extension resource.")."</h1>         .'<h1>'.&mt("Creating a new $extension resource.")."</h1>
 $errormsg  $errormsg
 ".&mt("The requested file [_1] currently does not exist.",  ".&mt("The requested file [_1] currently does not exist.",
       '<span class="LC_filename">'.$shownurl.'</span>').'        '<span class="LC_filename">'.$url.'</span>').'
 <p class="LC_info">  <p class="LC_info">
 '.&mt("To create a new $extension, select a template from the".  '.&mt("To create a new $extension, select a template from the".
       " list below. Then click on the \"Create $extension\" button.").'        " list below. Then click on the \"Create $extension\" button.").'
Line 1251  sub handler { Line 1248  sub handler {
  #first visit to problem in construction space   #first visit to problem in construction space
  $env{'form.problemmode'}= 'view';   $env{'form.problemmode'}= 'view';
  &renderpage($request,$file);   &renderpage($request,$file);
             } elsif (($env{'form.problemmode'} eq 'editxml') ||      } elsif (($env{'form.problemmode'} eq 'editxml') || 
                      ($env{'form.problemmode'} eq 'saveeditxml') ||                       ($env{'form.problemmode'} eq 'saveeditxml') ||
                      ($env{'form.problemmode'} eq 'saveviewxml') ||                       ($env{'form.problemmode'} eq 'saveviewxml') ||
                      ($env{'form.problemmode'} eq 'undoxml')) {                       ($env{'form.problemmode'} eq 'undoxml')) {
                 &editxmlmode($request,$file);   &editxmlmode($request,$file);
     } elsif ($env{'form.problemmode'} eq 'calcanswers') {      } elsif ($env{'form.problemmode'} eq 'calcanswers') {
  &analyze($request,$file);   &analyze($request,$file);
     } else {      } else {

Removed from v.1.317.4.4  
changed lines
  Added in v.1.332


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