Diff for /loncom/homework/structuretags.pm between versions 1.512.2.21 and 1.512.2.23.2.2

version 1.512.2.21, 2019/11/04 20:50:57 version 1.512.2.23.2.2, 2020/09/29 18:03:03
Line 63  use Apache::londefdef; Line 63  use Apache::londefdef;
 use Apache::lonenc();  use Apache::lonenc();
 use Apache::loncommon();  use Apache::loncommon();
 use Time::HiRes qw( gettimeofday tv_interval );  use Time::HiRes qw( gettimeofday tv_interval );
   use HTML::Entities();
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA;
     
Line 652  sub setup_rndseed { Line 653  sub setup_rndseed {
     }      }
     if ($Apache::lonhomework::type eq 'randomizetry') {      if ($Apache::lonhomework::type eq 'randomizetry') {
         my $partfortries = $Apache::inputtags::part;          my $partfortries = $Apache::inputtags::part;
   #
   # Where question type is "randomizetry" for a problem containing
   # a single part (and unless type is explicitly set to not be
   # "randomizetry" for that part), the number of tries used to
   # determine randomization will be for that part, and randomization
   # from calls to &random() in a perl script block before the part tag,
   # will change based on the number of tries, and value of the
   # "randomizeontries" parameter in effect for the single part.
   #
         if (ref($probpartlist) eq 'ARRAY') {          if (ref($probpartlist) eq 'ARRAY') {
             if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $Apache::inputtags::part)) {              if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $partfortries)) {
                 $partfortries = $probpartlist->[0];                  if (&Apache::lonnet::EXT('resource.'.$probpartlist->[0].'.type') eq 'randomizetry') {
                 if (&Apache::lonnet::EXT("resource.$partfortries.questiontype") eq 'randomizetry') {  
                     $partfortries = $probpartlist->[0];                      $partfortries = $probpartlist->[0];
                 } else {                  } else {
                     $partfortries = '';                      $partfortries = '';
Line 1380  sub firstaccess_msg { Line 1389  sub firstaccess_msg {
     my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});      my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});
     my $buttontext = &mt('Show Resource');      my $buttontext = &mt('Show Resource');
     my $timertext = &mt('Start Timer?');      my $timertext = &mt('Start Timer?');
       my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb),'\'"<>&');
     $result .= (<<ENDCHECKOUT);      $result .= (<<ENDCHECKOUT);
 <form name="markaccess" method="post" action="$uri">  <form name="markaccess" method="post" action="$uri">
 <input type="hidden" name="markaccess" value="yes" />  <input type="hidden" name="markaccess" value="yes" />
   <input type="hidden" name="symb" value="$shownsymb" />
 <input type="button" name="accessbutton" value="$buttontext" onclick="javascript:if (confirm('$timertext')) { document.markaccess.submit(); }" />  <input type="button" name="accessbutton" value="$buttontext" onclick="javascript:if (confirm('$timertext')) { document.markaccess.submit(); }" />
 </form>  </form>
 ENDCHECKOUT  ENDCHECKOUT
Line 1548  sub start_problem { Line 1559  sub start_problem {
         $target eq 'tex') {          $target eq 'tex') {
         if ($env{'form.markaccess'}) {          if ($env{'form.markaccess'}) {
             my @interval=&Apache::lonnet::EXT("resource.0.interval");              my @interval=&Apache::lonnet::EXT("resource.0.interval");
             my $is_set = &Apache::lonnet::set_first_access($interval[1],$interval[0]);              my ($timelimit) = ($interval[0] =~ /^(\d+)/);
               my $is_set = &Apache::lonnet::set_first_access($interval[1],$timelimit);
             unless (($is_set eq 'ok') || ($is_set eq 'already_set')) {              unless (($is_set eq 'ok') || ($is_set eq 'already_set')) {
                 $firstaccres = $is_set;                  $firstaccres = $is_set;
             }              }
Line 1566  sub start_problem { Line 1578  sub start_problem {
  $name);   $name);
     } elsif (($target eq 'grade') && ($Apache::lonhomework::type eq 'randomizetry')) {      } elsif (($target eq 'grade') && ($Apache::lonhomework::type eq 'randomizetry')) {
         my ($symb)= &Apache::lonnet::whichuser();          my ($symb)= &Apache::lonnet::whichuser();
         my $navmap = Apache::lonnavmaps::navmap->new();          if ($symb ne '') {
         if (ref($navmap)) {              my $navmap = Apache::lonnavmaps::navmap->new();
             my $res = $navmap->getBySymb($symb);              if (ref($navmap)) {
             if (ref($res)) {                  my $res = $navmap->getBySymb($symb);
                 $probpartlist = $res->parts();                  if (ref($res)) {
                       $probpartlist = $res->parts();
                   }
             }              }
         }          }
     }      }
Line 1581  sub start_problem { Line 1595  sub start_problem {
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  $target eq 'tex') {   $target eq 'tex') {
   
           my ($symb) = &Apache::lonnet::whichuser();
  #handle rand seed in construction space   #handle rand seed in construction space
           if (($env{'request.state'} eq 'construct') || ($symb eq '')) {
               my $partorder=&Apache::lonnet::metadata($env{'request.uri'},'partorder');
               if ($partorder ne '') {
                   @{$probpartlist} = split(/,/,$partorder);
               }
           }
  my $rndseed=&setup_rndseed($safeeval,$target,$probpartlist);   my $rndseed=&setup_rndseed($safeeval,$target,$probpartlist);
         if (($target eq 'grade') && &Apache::response::submitted()) {          if (($target eq 'grade') && &Apache::response::submitted()) {
             if ($Apache::lonhomework::type eq 'randomizetry') {              if ($Apache::lonhomework::type eq 'randomizetry') {
Line 1596  sub start_problem { Line 1617  sub start_problem {
                 }                  }
             }              }
         }          }
  my ($symb)=&Apache::lonnet::whichuser();  
   
  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')) {
Line 3137  sub randomizetry_part_header { Line 3157  sub randomizetry_part_header {
     my ($header,$text);      my ($header,$text);
     if ($reqtries eq 'none') {      if ($reqtries eq 'none') {
         $header = &mt('No Question Variation');          $header = &mt('No Question Variation');
         $text = &mt('For this question there will no new variation after a try.');          $text = &mt('For this question there will be no new variation after a try.');
     } elsif ($reqtries > 1) {      } elsif ($reqtries > 1) {
         $header = &mt('New Question Variation After Every [quant,_1,Try,Tries]',$reqtries);          $header = &mt('New Question Variation After Every [quant,_1,Try,Tries]',$reqtries);
         if (($problemstatus eq 'no') ||          if (($problemstatus eq 'no') ||

Removed from v.1.512.2.21  
changed lines
  Added in v.1.512.2.23.2.2


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