[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework structuretags.pm
raeburn
raeburn at source.lon-capa.org
Thu Oct 31 12:14:09 EDT 2019
raeburn Thu Oct 31 16:14:09 2019 EDT
Modified files: (Branch: version_2_11_X)
/loncom/homework structuretags.pm
Log:
- For 2.11
Backport 1.564
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.512.2.18 loncom/homework/structuretags.pm:1.512.2.19
--- loncom/homework/structuretags.pm:1.512.2.18 Wed Oct 23 22:30:28 2019
+++ loncom/homework/structuretags.pm Thu Oct 31 16:14:09 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.512.2.18 2019/10/23 22:30:28 raeburn Exp $
+# $Id: structuretags.pm,v 1.512.2.19 2019/10/31 16:14:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -643,13 +643,23 @@
sub setup_rndseed {
my ($safeeval,$target,$probpartlist)=@_;
my ($symb)=&Apache::lonnet::whichuser();
- my ($questiontype,$set_safespace,$rndseed);
+ my ($questiontype,$set_safespace,$rndseed,$numtries,$reqtries);
if ($target eq 'analyze') {
$questiontype = $env{'form.grade_questiontype'};
}
unless (defined($questiontype)) {
$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")
|| ($symb eq '')
|| ($Apache::lonhomework::type eq 'practice')
@@ -669,9 +679,13 @@
}
if (($env{'request.state'} eq "construct") &&
($Apache::lonhomework::type eq 'randomizetry')) {
- my $tries = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"};
- if ($tries) {
- $rndseed += $tries;
+ if ($numtries) {
+ if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) {
+ my $inc = int($numtries/$reqtries);
+ $rndseed += $inc;
+ } else {
+ $rndseed += $numtries;
+ }
}
$env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed;
}
@@ -709,13 +723,7 @@
}
unless (($target eq 'analyze') && (defined($rndseed))) {
$rndseed=&Apache::lonnet::rndseed();
- my $partfortries = $Apache::inputtags::part;
- 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"};
+ my $curr_try = $numtries;
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
$curr_try ++;
}
@@ -723,7 +731,6 @@
$rndseed = $1;
}
if ($curr_try) {
- my $reqtries = &Apache::lonnet::EXT("resource.$partfortries.randomizeontries");
if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) {
my $inc = int(($curr_try-1)/$reqtries);
$rndseed += $inc;
@@ -1728,6 +1735,10 @@
$result.= '<input type="submit" name="resetdata" '.
'value="'.&mt('New Problem Variation').'" />'.
&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
More information about the LON-CAPA-cvs
mailing list