Diff for /loncom/homework/lonhomework.pm between versions 1.376 and 1.381

version 1.376, 2023/06/02 01:20:27 version 1.381, 2023/11/27 22:44:20
Line 163  sub get_target { Line 163  sub get_target {
                 return ('web','answer');                  return ('web','answer');
             } elsif (($env{'form.problemmode'} eq 'saveedit') ||              } elsif (($env{'form.problemmode'} eq 'saveedit') ||
                      ($env{'form.problemmode'} eq 'undo')) {                       ($env{'form.problemmode'} eq 'undo')) {
                 return ('modified','no_output_web','edit');                  my %editors = &Apache::loncommon::permitted_editors();
                   if ($editors{'edit'}) {
                       return ('modified','no_output_web','edit');
                   } else {
                       return ('web');
                   }
             } elsif ($env{'form.problemmode'} eq 'edit') {              } elsif ($env{'form.problemmode'} eq 'edit') {
  return ('no_output_web','edit');                  my %editors = &Apache::loncommon::permitted_editors();
                   if ($editors{'edit'}) {
       return ('no_output_web','edit');
                   } else {
                       return ('web');
                   }
     } else {      } else {
  return ('web');   return ('web');
     }      }
Line 371  sub check_slot_access { Line 381  sub check_slot_access {
                 my $probstatus = &Apache::structuretags::get_problem_status($part);                  my $probstatus = &Apache::structuretags::get_problem_status($part);
                 my $earlyout;                  my $earlyout;
                 unless (($probstatus eq 'no') ||                  unless (($probstatus eq 'no') ||
                         ($probstatus eq 'no_feedback_ever')) {                           ($probstatus eq 'no_feedback_ever')) {
                     if ($Apache::lonhomework::history{"resource.$part.solved"} =~/^correct_/) {                      if ($Apache::lonhomework::history{"resource.$part.solved"} =~/^correct_/) {
                         $numcorrect ++;                          $numcorrect ++;
                     } else {                      } else {
Line 380  sub check_slot_access { Line 390  sub check_slot_access {
                 }                  }
                 if ($currtries == $maxtries) {                  if ($currtries == $maxtries) {
                     $earlyout = 1;                      $earlyout = 1;
                 } else {                   } else {
                     $numgraded ++;                      $numgraded ++;
                 }                  }
                 last if ($earlyout);                  last if ($earlyout);
Line 939  STATE Line 949  STATE
   
 sub analyze_header {  sub analyze_header {
     my ($request) = @_;      my ($request) = @_;
     my $js = &Apache::structuretags::setmode_javascript();      my $js = &Apache::lonxml::setmode_javascript();
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),      my $text = 'Authoring Space';
                    'text' => 'Authoring Space'},      my $href = &Apache::loncommon::authorspace($request->uri);
       if ($env{'request.course.id'}) {
           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           if ($href eq "/priv/$cdom/$cnum/") {
               $text = 'Course Authoring Space';
           }
       }
       my $brcrum = [{'href' => $href,
                      'text' => $text},
                   {'href' => '',                    {'href' => '',
                    'text' => 'Problem Testing'},                     'text' => 'Problem Testing'},
                   {'href' => '',                    {'href' => '',
Line 955  sub analyze_header { Line 974  sub analyze_header {
                                        {'bread_crumbs' => $brcrum,})                                         {'bread_crumbs' => $brcrum,})
        .&Apache::loncommon::head_subbox(         .&Apache::loncommon::head_subbox(
                 &Apache::loncommon::CSTR_pageheader());                  &Apache::loncommon::CSTR_pageheader());
       my %lt = &Apache::lonlocal::texthash(
                    edit => 'Edit',
                    editxml => 'EditXML',
                );
     $result .=       $result .= 
     '<form name="lonhomework" method="post" action="'.      '<form name="lonhomework" method="post" action="'.
     &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.      &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.
             '<input type="hidden" name="problemmode" value="'.              '<input type="hidden" name="problemmode" value="'.
             $env{'form.problemmode'}.'" />'.              $env{'form.problemmode'}.'" />'.
     &Apache::structuretags::remember_problem_state().'      &Apache::structuretags::remember_problem_state().'
             <div class="LC_edit_problem_analyze_header">              <div class="LC_edit_problem_analyze_header">';
             <input type="button" name="submitmode" value="'.&mt("EditXML").'" '.       my %editors = &Apache::loncommon::permitted_editors();
             'onclick="javascript:setmode(this.form,'."'editxml'".')" />       foreach my $item ('editxml','edit') {
             <input type="button" name="submitmode" value="'.&mt('Edit').'" '.           next unless ($editors{$item});
             'onclick="javascript:setmode(this.form,'."'edit'".')" />           $result .= '<input type="button" name="submitmode" value="'.$lt{$item}.'" '.
             <hr />                      'onclick="javascript:setmode(this.form,'."'$item'".')" />'.
                       "\n";
        }
        $result .=
               '<hr />
             <input type="button" name="submitmode" value="'.&mt("View").'" '.              <input type="button" name="submitmode" value="'.&mt("View").'" '.
             'onclick="javascript:setmode(this.form,'."'view'".')" />              'onclick="javascript:setmode(this.form,'."'view'".')" />
             <hr />              <hr />
Line 1171  sub editxmlmode { Line 1198  sub editxmlmode {
  my $js =   my $js =
     &Apache::edit::js_change_detection().       &Apache::edit::js_change_detection(). 
     &Apache::loncommon::resize_textarea_js().      &Apache::loncommon::resize_textarea_js().
             &Apache::structuretags::setmode_javascript().              &Apache::lonxml::setmode_javascript().
             &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");              &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
   
     # Breadcrumbs      # Breadcrumbs
     my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),      my $text = 'Authoring Space';
                    'text' => 'Authoring Space'},      my $href = &Apache::loncommon::authorspace($request->uri);
       if ($env{'request.course.id'}) {
           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           if ($href eq "/priv/$cdom/$cnum/") {
               $text = 'Course Authoring Space';
           }
       }
       my $brcrum = [{'href' => $href,
                      'text' => $text},
                   {'href' => '',                    {'href' => '',
                    'text' => 'Problem Editing'}];                     'text' => 'Problem Editing'}];
   
Line 1209  sub editxmlmode { Line 1245  sub editxmlmode {
   
     $result .= '<ol class="LC_primary_menu" style="display:inline-block;font-size:90%;vertical-align:middle;">';      $result .= '<ol class="LC_primary_menu" style="display:inline-block;font-size:90%;vertical-align:middle;">';
   
     unless ($env{'environment.nocodemirror'}) {      my $nocodemirror = &Apache::loncommon::nocodemirror();
       unless ($nocodemirror) {
         # dropdown menus          # dropdown menus
         $result .= Apache::lonmenu::create_submenu("#", "",           $result .= Apache::lonmenu::create_submenu("#", "",
             &mt("Problem Templates"), template_dropdown_datastructure());              &mt("Problem Templates"), template_dropdown_datastructure());
   
         $result .= Apache::lonmenu::create_submenu("#", "",           $result .= Apache::lonmenu::create_submenu("#", "",
             &mt("Response Types"), responseblock_dropdown_datastructure());              &mt("Response Types"), responseblock_dropdown_datastructure());
   
         $result .= Apache::lonmenu::create_submenu("#", "",           $result .= Apache::lonmenu::create_submenu("#", "",
             &mt("Conditional Blocks"), conditional_scripting_datastructure());              &mt("Conditional Blocks"), conditional_scripting_datastructure());
   
         $result .= Apache::lonmenu::create_submenu("#", "",           $result .= Apache::lonmenu::create_submenu("#", "",
             &mt("Miscellaneous"), misc_datastructure());              &mt("Miscellaneous"), misc_datastructure());
     }      }
   
     $result .= Apache::lonmenu::create_submenu("#", "",       $result .= Apache::lonmenu::create_submenu("#", "",
         &mt("Help") . ' <img src="/adm/help/help.png" alt="' . &mt("Help") .          &mt("Help") . ' <img src="/adm/help/help.png" alt="' . &mt("Help") .
         '" style="vertical-align:text-bottom; height: auto; margin:0; "/>',           '" style="vertical-align:text-bottom; height: auto; margin:0; "/>',
         helpmenu_datastructure(),"");          helpmenu_datastructure(),"");
   
     $result.="</ol></div>";      $result.="</ol></div>";
            
     $result .= '</div></div>' .       $result .= '</div></div>' .
         &Apache::lonxml::message_location() .          &Apache::lonxml::message_location() .
         &Apache::loncommon::xmleditor_js() .          &Apache::loncommon::xmleditor_js() .
         '<textarea ' . &Apache::edit::element_change_detection() .          '<textarea ' . &Apache::edit::element_change_detection() .
Line 1241  sub editxmlmode { Line 1278  sub editxmlmode {
         '</textarea> <div id="LC_aftertextarea"> </div> </form>';          '</textarea> <div id="LC_aftertextarea"> </div> </form>';
   
     my $resource = $env{'request.ambiguous'};      my $resource = $env{'request.ambiguous'};
     unless($env{'environment.nocodemirror'}){      unless ($nocodemirror) {
         $result .= '<link rel="stylesheet" href="/adm/codemirror/codemirror-combined-xml.css">          $result .= '<link rel="stylesheet" href="/adm/codemirror/codemirror-combined-xml.css">
         <script src="/adm/codemirror/codemirror-compressed-xml.js"></script>          <script src="/adm/codemirror/codemirror-compressed-xml.js"></script>
         <script>          <script>
Line 1267  sub editxmlmode { Line 1304  sub editxmlmode {
                 autoCloseBrackets: true,                  autoCloseBrackets: true,
                 height: "auto",                  height: "auto",
                 styleActiveLine: true,                  styleActiveLine: true,
                   
                 extraKeys: {                  extraKeys: {
                     "Tab": "indentMore",                      "Tab": "indentMore",
                     "Shift-Tab": "indentLess",                      "Shift-Tab": "indentLess",
Line 1393  sub finished_parsing { Line 1430  sub finished_parsing {
 # value 3: name of help topic ???  # value 3: name of help topic ???
 sub get_template_list{  sub get_template_list{
     my ($extension) = @_;      my ($extension) = @_;
       
     my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}.      my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}.
                      '/templates/*.'.$extension);                       '/templates/*.'.$extension);
     @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')),      @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')),
Line 1524  sub newproblem { Line 1561  sub newproblem {
  my $url=&HTML::Entities::encode($request->uri,'<>&"');   my $url=&HTML::Entities::encode($request->uri,'<>&"');
  my $dest = &Apache::lonnet::filelocation("",$request->uri);   my $dest = &Apache::lonnet::filelocation("",$request->uri);
  my $instructions;   my $instructions;
         my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),          my $text = 'Authoring Space';
                        'text' => 'Authoring Space'},          my $href = &Apache::loncommon::authorspace($request->uri);
           if ($env{'request.course.id'}) {
               my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
               my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
               if ($href eq "/priv/$cdom/$cnum/") {
                   $text = 'Course Authoring Space';
               }
           }
           my $brcrum = [{'href' => $href,
                          'text' => $text},
                       {'href' => '',                        {'href' => '',
                        'text' => "Create New $extension"}];                         'text' => "Create New $extension"}];
  my $start_page =    my $start_page = 
Line 1573  sub update_construct_style { Line 1619  sub update_construct_style {
 }  }
   
 #  #
 # Sets interval for current user so time left will be zero, either for the entire folder   # Sets interval for current user so time left will be zero, either for the entire folder
 # containing the current resource, or just the resource, depending on value of first item  # containing the current resource, or just the resource, depending on value of first item
 # in interval array retrieved from EXT("resource.0.interval");  # in interval array retrieved from EXT("resource.0.interval");
 #  #
Line 1597  sub zero_timer { Line 1643  sub zero_timer {
                         $key =~ s/\s+$//;                          $key =~ s/\s+$//;
                         if ($env{'form.LC_interval_done_proctorpass'} ne $secret) {                          if ($env{'form.LC_interval_done_proctorpass'} ne $secret) {
                             return ('fail',                              return ('fail',
                                    &mt('Incorrect key entered by proctor'));                                      &mt('Incorrect key entered by proctor'));
                         }                          }
                     }                      }
                     if ($first_access+$timelimit > $now) {                      if ($first_access+$timelimit > $now) {
Line 1620  sub zero_timer { Line 1666  sub zero_timer {
                             return ('ok');                              return ('ok');
                         } else {                          } else {
                             return ('fail',&mt('Error ending timed event: [_1]',$result));                              return ('fail',&mt('Error ending timed event: [_1]',$result));
                         }                           }
                     } else {                      } else {
                         return ('fail',&mt('Timed event already ended'));                          return ('fail',&mt('Timed event already ended'));
                     }                      }
Line 1651  sub handler { Line 1697  sub handler {
     #check if we know where we are      #check if we know where we are
     if ($env{'request.course.fn'} && !&Apache::lonnet::symbread('','',1,1)) {      if ($env{'request.course.fn'} && !&Apache::lonnet::symbread('','',1,1)) {
  # if we are browsing we might not be able to know where we are   # if we are browsing we might not be able to know where we are
  if ($Apache::lonhomework::browse ne 'F' &&    if ($Apache::lonhomework::browse ne 'F' &&
     $env{'request.state'} ne "construct") {      $env{'request.state'} ne "construct") {
     #should know where we are, so ask      #should know where we are, so ask
     &unset_permissions();      &unset_permissions();
Line 1680  sub handler { Line 1726  sub handler {
                      ($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);                  my %editors = &Apache::loncommon::permitted_editors();
                   if (($editors{'xml'}) || ($env{'form.problemmode'} eq 'saveviewxml') || ($env{'form.problemmode'} eq 'undoxml')) {
       &editxmlmode($request,$file);
                   } else {
                       &update_construct_style();
                       &renderpage($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.376  
changed lines
  Added in v.1.381


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