--- loncom/homework/structuretags.pm 2024/02/27 19:46:23 1.512.2.24.2.10
+++ loncom/homework/structuretags.pm 2015/12/03 20:40:27 1.541
@@ -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.24.2.10 2024/02/27 19:46:23 raeburn Exp $
+# $Id: structuretags.pm,v 1.541 2015/12/03 20:40:27 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,9 +62,7 @@ use Apache::lonxml;
use Apache::londefdef;
use Apache::lonenc();
use Apache::loncommon();
-use Apache::lonnavmaps;
use Time::HiRes qw( gettimeofday tv_interval );
-use HTML::Entities();
use lib '/home/httpd/lib/perl/';
use LONCAPA;
@@ -272,8 +270,8 @@ sub homework_js {
$jstimeout = 1000 * $timeout;
}
return &Apache::loncommon::resize_textarea_js().
- &Apache::loncommon::colorfuleditor_js().
- &Apache::lonxml::setmode_javascript().
+ &Apache::loncommon::colorfuleditor_js().
+ &setmode_javascript().
<<"JS";
+ENDSCRIPT
+}
+
sub page_start {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name,
$extra_head)=@_;
@@ -404,13 +417,9 @@ sub page_start {
$extra_head .= &homework_js().
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
if (&Apache::lonhtmlcommon::htmlareabrowser()) {
- my %textarea_args;
- if (($env{'request.state'} ne 'construct') ||
- ($env{'environment.nocodemirror'})) {
- %textarea_args = (
+ my %textarea_args = (
dragmath => 'math',
);
- }
$extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
}
my $is_task = ($env{'request.uri'} =~ /\.task$/);
@@ -481,9 +490,9 @@ sub page_start {
}
}
if ($needs_upload) {
- $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js().
- '';
+ $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js()
+ .'';
}
}
@@ -585,9 +594,7 @@ sub page_start {
my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
my ($path,$multiresp) =
&Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom);
- if ($env{'request.user_in_effect'}) {
- $form_tag_start .= ' onsubmit="preventDefault();"';
- } elsif (($is_task) || ($needs_upload)) {
+ if (($is_task) || ($needs_upload)) {
$form_tag_start .= ' onsubmit="return file_submission_check(this,'."'$path','$multiresp'".');"';
}
$form_tag_start.='>'."\n";
@@ -632,43 +639,17 @@ sub get_resource_name {
sub setup_rndseed {
my ($safeeval,$target,$probpartlist)=@_;
my ($symb)=&Apache::lonnet::whichuser();
- my ($questiontype,$set_safespace,$rndseed,$numtries,$reqtries);
+ my ($questiontype,$set_safespace,$rndseed);
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;
-#
-# 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 ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $partfortries)) {
- if (&Apache::lonnet::EXT('resource.'.$probpartlist->[0].'.type') eq 'randomizetry') {
- $partfortries = $probpartlist->[0];
- } else {
- $partfortries = '';
- }
- }
- }
- 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 '')
- || ($Apache::lonhomework::type eq 'practice')
- || ($Apache::lonhomework::history{'resource.CODE'})
- || (($env{'form.code_for_randomlist'}) && ($target eq 'analyze'))) {
+ if ($env{'request.state'} eq "construct"
+ || $symb eq ''
+ || $Apache::lonhomework::type eq 'practice'
+ || $Apache::lonhomework::history{'resource.CODE'}) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['rndseed']);
$rndseed=$env{'form.rndseed'};
@@ -677,19 +658,13 @@ sub setup_rndseed {
if (!$rndseed) {
$rndseed=time;
}
- unless ($env{'form.code_for_randomlist'}) {
- $env{'form.rndseed'}=$rndseed;
- }
+ $env{'form.rndseed'}=$rndseed;
}
- if ((($env{'request.state'} eq "construct") || ($symb eq '')) &&
+ if (($env{'request.state'} eq "construct") &&
($Apache::lonhomework::type eq 'randomizetry')) {
- if ($numtries) {
- if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) {
- my $inc = int($numtries/$reqtries);
- $rndseed += $inc;
- } else {
- $rndseed += $numtries;
- }
+ my $tries = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"};
+ if ($tries) {
+ $rndseed += $tries;
}
$env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed;
}
@@ -711,11 +686,7 @@ sub setup_rndseed {
$rndseed=join(':',&Apache::lonnet::digest($rndseed));
}
}
- if (($env{'form.code_for_randomlist'}) && ($target eq 'analyze')) {
- $env{'form.CODE'} = $env{'form.code_for_randomlist'};
- $rndseed=&Apache::lonnet::rndseed();
- undef($env{'form.CODE'});
- } elsif ($Apache::lonhomework::history{'resource.CODE'}) {
+ if ($Apache::lonhomework::history{'resource.CODE'}) {
$rndseed=&Apache::lonnet::rndseed();
}
$set_safespace = 1;
@@ -727,7 +698,13 @@ sub setup_rndseed {
}
unless (($target eq 'analyze') && (defined($rndseed))) {
$rndseed=&Apache::lonnet::rndseed();
- my $curr_try = $numtries;
+ 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"};
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
$curr_try ++;
}
@@ -735,6 +712,7 @@ sub setup_rndseed {
$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;
@@ -792,9 +770,7 @@ sub problem_edit_buttons {
if ($mode eq 'editxml') {
$result.=&problem_edit_action_button('subedit','edit','e','Edit',1);
$result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1);
- if ($env{'environment.nocodemirror'}) {
- $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
- }
+ $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
} else {
$result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1);
$result.=&problem_edit_action_button('subundo','undo','u','Undo',1);
@@ -810,9 +786,9 @@ sub problem_edit_header {
' . &Apache::lonxml::message_location();
$return .= '
@@ -840,7 +816,6 @@ sub problem_edit_header {
return $return;
}
-
sub problem_edit_footer {
my $resource = $env{'request.ambiguous'};
return '
@@ -916,7 +891,7 @@ sub problem_web_to_edit_header {
".&mt("Problem Type:")."