[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm
raeburn
raeburn at source.lon-capa.org
Mon Nov 4 14:36:46 EST 2019
raeburn Mon Nov 4 19:36:46 2019 EDT
Modified files:
/loncom/homework structuretags.pm
Log:
- Bug 6917 Headers for problem or problem parts in Authoring Space, or
when browsing resource not in a course, where questiontype = randomizetry.
- "New Problem Variation ... " header, if no parts.
- "New Question Variation ... " header for each part, if parts.
- "No Question Variation ... " header for each part with questiontype=
not randomizetry, if multiple parts and >= 1 has questiontype=randomizetry.
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.565 loncom/homework/structuretags.pm:1.566
--- loncom/homework/structuretags.pm:1.565 Mon Nov 4 13:21:25 2019
+++ loncom/homework/structuretags.pm Mon Nov 4 19:36:46 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.565 2019/11/04 13:21:25 raeburn Exp $
+# $Id: structuretags.pm,v 1.566 2019/11/04 19:36:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -681,10 +681,17 @@
if (ref($probpartlist) eq 'ARRAY') {
if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $Apache::inputtags::part)) {
$partfortries = $probpartlist->[0];
+ if (&Apache::lonnet::EXT("resource.$partfortries.questiontype") eq 'randomizetry') {
+ $partfortries = $probpartlist->[0];
+ } else {
+ $partfortries = '';
+ }
}
}
- $numtries = $Apache::lonhomework::history{"resource.$partfortries.tries"};
- $reqtries = &Apache::lonnet::EXT("resource.$partfortries.randomizeontries");
+ if ($partfortries ne '') {
+ $numtries = $Apache::lonhomework::history{"resource.$partfortries.tries"};
+ $reqtries = &Apache::lonnet::EXT("resource.$partfortries.randomizeontries");
+ }
}
if (($env{'request.state'} eq "construct")
|| ($symb eq '')
@@ -1666,6 +1673,7 @@
@Apache::structuretags::whilebody=();
@Apache::structuretags::whileline=();
$Apache::lonhomework::scantronmode=0;
+ $Apache::lonhomework::randomizetrypart=0;
undef($Apache::lonhomework::name);
undef($Apache::lonhomework::default_type);
undef($Apache::lonhomework::type);
@@ -1689,6 +1697,7 @@
undef($Apache::lonhomework::default_type);
undef($Apache::lonhomework::type);
undef($Apache::lonhomework::scantronmode);
+ undef($Apache::inputtags::randomizetrypart);
undef($Apache::lonhomework::ignore_response_errors);
undef(@Apache::functionplotresponse::callscripts);
&Apache::lonhomework::reset_show_problem_status();
@@ -1882,9 +1891,15 @@
($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.
- my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
- my $problemstatus = &get_problem_status($Apache::inputtags::part);
- $form_tag_start.=&randomizetry_problem_header($problemstatus,$reqtries);
+ my @parts;
+ if (ref($probpartlist) eq 'ARRAY') {
+ @parts = @{$probpartlist};
+ }
+ unless (@parts) {
+ my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
+ my $problemstatus = &get_problem_status($Apache::inputtags::part);
+ $form_tag_start.=&randomizetry_problem_header($problemstatus,$reqtries,$symb);
+ }
}
my $expression='$external::datestatus="'.$status.'";';
@@ -2177,7 +2192,24 @@
}
}
if ($target eq 'web') {
- $result.=&Apache::functionplotresponse::init_script();
+ $result.=&Apache::functionplotresponse::init_script();
+ if ($Apache::lonhomework::default_type eq 'randomizetry') {
+ my ($symb) = &Apache::lonnet::whichuser();
+ if ((($env{'request.state'} eq 'construct') || ($symb eq '')) &&
+ ($status eq 'CAN_ANSWER')) {
+ unless (@Apache::inputtags::partlist > 1) {
+ $result.= <<"ENDJS";
+<script type="text/javascript">
+// <![CDATA[
+ \$(document).ready(function() {
+ \$('#LC_randomizetry_header').css('display','block');
+ });
+// ]]>
+</script>
+ENDJS
+ }
+ }
+ }
}
if ($target eq 'grade') {
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
@@ -2980,17 +3012,12 @@
my $probrandomize = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].type");
my $probrandtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].randomizeontries");
my $num = scalar(@Apache::inputtags::partlist)-1;
- if ($probrandomize eq 'randomizetry') {
- if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.type") ne 'randomizetry') {
- $result .= &randomizetry_part_header($problemstatus,'none',$num);
- } else {
- my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
- if ($probrandtries ne $reqtries) {
- $result .= &randomizetry_part_header($problemstatus,$reqtries,$num);
- }
- }
- } elsif (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.type") eq 'randomizetry') {
- my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
+ if ((($probrandomize eq 'randomizetry') || ($Apache::lonhomework::randomizetrypart)) &&
+ ($Apache::lonhomework::type ne 'randomizetry')) {
+ $result .= &randomizetry_part_header($problemstatus,'none',$num);
+ } elsif ($Apache::lonhomework::type eq 'randomizetry') {
+ $Apache::lonhomework::randomizetrypart = 1;
+ my $reqtries = &Apache::lonnet::EXT("resource.$id.randomizeontries");
$result .= &randomizetry_part_header($problemstatus,$reqtries,$num);
}
}
@@ -3310,7 +3337,7 @@
}
sub randomizetry_problem_header {
- my ($problemstatus,$reqtries) = @_;
+ my ($problemstatus,$reqtries,$symb) = @_;
my ($header,$text);
if ($reqtries > 1) {
$header = &mt('New Problem Variation After Every [quant,_1,Try,Tries]',$reqtries);
@@ -3330,8 +3357,13 @@
$text = &mt('A new variation will be generated after each try until correct or tries limit is reached.');
}
}
- return '<h3 class="LC_info">'.$header.'</h3>'.
- '<span class="LC_info">'.$text.'</span><hr />';
+ if (($env{'request.state'} eq "construct") || ($symb eq '')) {
+ return '<div class="LC_info" id="LC_randomizetry_header" style="display:none">'.
+ '<h3>'.$header.'</h3><span class="LC_info">'.$text.'</span><hr /></div>';
+ } else {
+ return '<h3 class="LC_info">'.$header.'</h3>'.
+ '<span class="LC_info">'.$text.'</span><hr />';
+ }
}
sub randomizetry_part_header {
More information about the LON-CAPA-cvs
mailing list