Diff for /loncom/homework/structuretags.pm between versions 1.562 and 1.565

version 1.562, 2018/12/26 19:40:04 version 1.565, 2019/11/04 13:21:25
Line 366  var postsubmit = '$postsubmit'; Line 366  var postsubmit = '$postsubmit';
                 submithandled = 1;                  submithandled = 1;
                 \$( "#msg_"+buttonId ).css({"display": "inline","background-color": "#87cefa",                  \$( "#msg_"+buttonId ).css({"display": "inline","background-color": "#87cefa",
                                            "color": "black","padding": "2px"}) ;                                             "color": "black","padding": "2px"}) ;
                 if (( \$(this.form).id == "LC_page" ) && (\$('input[name="all_submit"]').length )) {                  if (( \$(this.form).attr("id") == "LC_page" ) && (\$('input[name="all_submit"]').length )) {
                     if (buttonId != "all_submit") {                      if (buttonId != "all_submit") {
                         \$( ".LC_status_"+buttonId ).hide();                          \$( ".LC_status_"+buttonId ).hide();
                         if (( "#"+buttonId+"_pressed" ).length) {                      }
                             \$( "#"+buttonId+"_pressed" ).val( "1" );                      if (( "#"+buttonId+"_pressed" ).length) {
                         }                          \$( "#"+buttonId+"_pressed" ).val( "1" );
                     }                      }
                 } else {                  } else {
                     \$( ".LC_status_"+buttonId ).hide();                      \$( ".LC_status_"+buttonId ).hide();
Line 384  var postsubmit = '$postsubmit'; Line 384  var postsubmit = '$postsubmit';
                 if (timeout > 0) {                  if (timeout > 0) {
                     setTimeout(function(){                      setTimeout(function(){
                                        \$( "#msg_"+buttonId ).css({"display": "none"});                                         \$( "#msg_"+buttonId ).css({"display": "none"});
                                        if (( \$(this.form).id == "LC_page" ) && (\$('input[name="all_submit"]').length )) {                                         if (( \$(this.form).attr("id") == "LC_page" ) && (\$('input[name="all_submit"]').length )) {
                                            if (buttonId != "all_submit") {                                             if (( "#"+buttonId+"_pressed" ).length) {
                                                if (( "#"+buttonId+"_pressed" ).length) {                                                 \$( "#"+buttonId+"_pressed" ).val( "" );
                                                    \$( "#"+buttonId+"_pressed" ).val( "" );  
                                                }  
                                            }                                             }
                                        }                                         }
                                        \$( ".LC_hwk_submit" ).prop( "disabled", false);                                         \$( ".LC_hwk_submit" ).prop( "disabled", false);
Line 671  sub get_resource_name { Line 669  sub get_resource_name {
 sub setup_rndseed {  sub setup_rndseed {
     my ($safeeval,$target,$probpartlist)=@_;      my ($safeeval,$target,$probpartlist)=@_;
     my ($symb)=&Apache::lonnet::whichuser();      my ($symb)=&Apache::lonnet::whichuser();
     my ($questiontype,$set_safespace,$rndseed);      my ($questiontype,$set_safespace,$rndseed,$numtries,$reqtries);
     if ($target eq 'analyze') {      if ($target eq 'analyze') {
         $questiontype = $env{'form.grade_questiontype'};          $questiontype = $env{'form.grade_questiontype'};
     }      }
     unless (defined($questiontype)) {      unless (defined($questiontype)) {
         $questiontype = $Apache::lonhomework::type;          $questiontype = $Apache::lonhomework::type;
     }      }
       if ($Apache::lonhomework::type eq 'randomizetry') {
           my $partfortries = $Apache::inputtags::part;
           if (ref($probpartlist) eq 'ARRAY') {
               if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $Apache::inputtags::part)) {
                   $partfortries = $probpartlist->[0];
               }
           }
           $numtries = $Apache::lonhomework::history{"resource.$partfortries.tries"};
           $reqtries = &Apache::lonnet::EXT("resource.$partfortries.randomizeontries");
       }
     if (($env{'request.state'} eq "construct")      if (($env{'request.state'} eq "construct")
         || ($symb eq '')          || ($symb eq '')
         || ($Apache::lonhomework::type eq 'practice')          || ($Apache::lonhomework::type eq 'practice')
Line 695  sub setup_rndseed { Line 703  sub setup_rndseed {
                 $env{'form.rndseed'}=$rndseed;                  $env{'form.rndseed'}=$rndseed;
             }              }
  }   }
         if (($env{'request.state'} eq "construct") &&           if ((($env{'request.state'} eq "construct") || ($symb eq '')) && 
             ($Apache::lonhomework::type eq 'randomizetry')) {              ($Apache::lonhomework::type eq 'randomizetry')) {
             my $tries = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"};              if ($numtries) {
             if ($tries) {                  if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) {
                 $rndseed += $tries;                      my $inc = int($numtries/$reqtries);
                       $rndseed += $inc;
                   } else {
                       $rndseed += $numtries;
                   }
             }              }
             $env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed;              $env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed;
         }          }
Line 737  sub setup_rndseed { Line 749  sub setup_rndseed {
         }          }
         unless (($target eq 'analyze') && (defined($rndseed))) {          unless (($target eq 'analyze') && (defined($rndseed))) {
             $rndseed=&Apache::lonnet::rndseed();              $rndseed=&Apache::lonnet::rndseed();
             my $partfortries = $Apache::inputtags::part;              my $curr_try = $numtries;
             if (ref($probpartlist) eq 'ARRAY') {  
                 if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $Apache::inputtags::part)) {  
                     $partfortries = $probpartlist->[0];  
                 }  
             }  
             my $curr_try = $Apache::lonhomework::history{"resource.$partfortries.tries"};  
             if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {              if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
                 $curr_try ++;                  $curr_try ++;
             }              }
Line 751  sub setup_rndseed { Line 757  sub setup_rndseed {
                 $rndseed = $1;                  $rndseed = $1;
             }              }
             if ($curr_try) {              if ($curr_try) {
                 my $reqtries = &Apache::lonnet::EXT("resource.$partfortries.randomizeontries");  
                 if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) {                  if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) {
                     my $inc = int(($curr_try-1)/$reqtries);                      my $inc = int(($curr_try-1)/$reqtries);
                     $rndseed += $inc;                      $rndseed += $inc;
Line 1843  sub start_problem { Line 1848  sub start_problem {
   
  if ($env{'request.state'} ne "construct" &&    if ($env{'request.state'} ne "construct" && 
     ($symb eq '' || $Apache::lonhomework::type eq 'practice')) {      ($symb eq '' || $Apache::lonhomework::type eq 'practice')) {
               my $rndseedval = $rndseed;
               if (($symb eq '') && ($Apache::lonhomework::type eq 'randomizetry')) {
                   $rndseedval = $env{'form.rndseed'};
               }
     $form_tag_start.='<input type="hidden" name="rndseed" value="'.      $form_tag_start.='<input type="hidden" name="rndseed" value="'.
  $rndseed.'" />'.   $rndseedval.'" />'.
     '<button type="submit" name="resetdata"      '<button type="submit" name="resetdata"
                         value="new_problem_variation">'.&mt('New Problem Variation').'</button>';                          value="new_problem_variation">'.&mt('New Problem Variation').'</button>';
     if (exists($env{'form.username'})) {      if (exists($env{'form.username'})) {
Line 1866  sub start_problem { Line 1875  sub start_problem {
                 $form_tag_start.=&practice_problem_header();                  $form_tag_start.=&practice_problem_header();
             }              }
     $form_tag_start.='<hr />';      $form_tag_start.='<hr />';
         } elsif (($env{'request.state'} ne "construct") &&          } 
                  ($Apache::lonhomework::type eq 'randomizetry') &&          if (($env{'request.state'} ne "construct") &&
                  ($status eq 'CAN_ANSWER') &&              ($Apache::lonhomework::type eq 'randomizetry') &&
                  ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement') &&              ($status eq 'CAN_ANSWER') &&
                  (!$env{'request.role.adv'})) {              ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement') &&
               (!$env{'request.role.adv'})) {
 # "New Problem Variation Each Try" header suppressed for Placement Tests, unless course personnel.   # "New Problem Variation Each Try" header suppressed for Placement Tests, unless course personnel. 
             my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");              my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
             my $problemstatus = &get_problem_status($Apache::inputtags::part);              my $problemstatus = &get_problem_status($Apache::inputtags::part);
Line 1932  sub start_problem { Line 1942  sub start_problem {
                     $result.= '<button type="submit" name="resetdata" '.                      $result.= '<button type="submit" name="resetdata" '.
                         'value="new_problem_variation">'.&mt('New Problem Variation').'</button>'.                          'value="new_problem_variation">'.&mt('New Problem Variation').'</button>'.
                         &practice_problem_header().'<hr />';                          &practice_problem_header().'<hr />';
                   } elsif ($Apache::lonhomework::type eq 'randomizetry') {
                       my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
                       my $problemstatus = &get_problem_status($Apache::inputtags::part);
                       $result.=&randomizetry_problem_header($problemstatus,$reqtries);
                 }                  }
     }      }
     # if we are viewing someone else preserve that info      # if we are viewing someone else preserve that info

Removed from v.1.562  
changed lines
  Added in v.1.565


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