--- loncom/homework/inputtags.pm 2006/06/05 18:53:03 1.194 +++ loncom/homework/inputtags.pm 2011/06/06 18:55:54 1.287 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.194 2006/06/05 18:53:03 banghart Exp $ +# $Id: inputtags.pm,v 1.287 2011/06/06 18:55:54 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,51 +25,85 @@ # # http://www.lon-capa.org/ +=pod + +=head1 NAME + +Apache::inputtags + +=head1 SYNOPSIS + + + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + + +=head1 NOTABLE SUBROUTINES + +=over + +=item + +=back + +=cut + package Apache::inputtags; use HTML::Entities(); use strict; use Apache::loncommon; +use Apache::lonhtmlcommon; use Apache::lonlocal; use Apache::lonnet; -use lib '/home/httpd/lib/perl/'; use LONCAPA; BEGIN { - &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline')); + &Apache::lonxml::register('Apache::inputtags',('hiddensubmission','hiddenline','textfield','textline')); } -# Initializes a set of global variables used during the parse of the problem. -# -# @Apache::inputtags::input - List of current input ids. -# @Apache::inputtags::inputlist - List of all input ids seen this problem. -# @Apache::inputtags::response - List of all current resopnse ids. -# @Apache::inputtags::responselist - List of all response ids seen this -# problem. -# @Apache::inputtags::hint - List of all hint ids. -# @Apache::inputtags::hintlist - List of all hint ids seen this problem. -# @Apache::inputtags::previous - List describing if specific responseds -# have been used -# @Apache::inputtags::previous_version - Submission responses were used in. -# $Apache::inputtags::part - Current part id (valid only in -# ) -# 0 if not in a part. -# @Apache::inputtags::partlist - List of part ids seen in the current -# -# @Apache::inputtags::status - List of problem statuses. First -# element is the status of the -# the remainder are for individual s. -# %Apache::inputtags::params - Hash of defined parameters for the -# current response. -# @Apache::inputtags::import - List of all ids for thes get -# join()ed and prepended. -# @Apache::inputtags::importlist - List of all import ids seen. -# $Apache::inputtags::response_with_no_part -# - Flag set true if we have seen a response -# that is not inside a -# %Apache::inputtags::answertxt - <*response> tags store correct -# answer strings for display by -# in this hash. +=pod + +=item initialize_inputtags() + +Initializes a set of global variables used during the parse of the problem. + +@Apache::inputtags::input - List of current input ids. +@Apache::inputtags::inputlist - List of all input ids seen this problem. +@Apache::inputtags::response - List of all current resopnse ids. +@Apache::inputtags::responselist - List of all response ids seen this + problem. +@Apache::inputtags::hint - List of all hint ids. +@Apache::inputtags::hintlist - List of all hint ids seen this problem. +@Apache::inputtags::previous - List describing if specific responseds + have been used +@Apache::inputtags::previous_version - Submission responses were used in. +$Apache::inputtags::part - Current part id (valid only in + ) + 0 if not in a part. +@Apache::inputtags::partlist - List of part ids seen in the current + +@Apache::inputtags::status - List of problem statuses. First + element is the status of the + the remainder are for individual s. +%Apache::inputtags::params - Hash of defined parameters for the + current response. +@Apache::inputtags::import - List of all ids for thes get + join()ed and prepended. +@Apache::inputtags::importlist - List of all import ids seen. +$Apache::inputtags::response_with_no_part + - Flag set true if we have seen a response + that is not inside a +%Apache::inputtags::answertxt - <*response> tags store correct + answer strings for display by + in this hash. +%Apache::inputtags::submission_display + - <*response> tags store improved display + of submission strings for display by part + end. + +=cut sub initialize_inputtags { @Apache::inputtags::input=(); @@ -88,6 +122,7 @@ sub initialize_inputtags { @Apache::inputtags::importlist=(); $Apache::inputtags::response_with_no_part=0; %Apache::inputtags::answertxt=(); + %Apache::inputtags::submission_display=(); } sub check_for_duplicate_ids { @@ -111,8 +146,7 @@ sub check_for_duplicate_ids { sub start_input { my ($parstack,$safeeval)=@_; - my $id = &Apache::lonxml::get_param('id',$parstack,$safeeval); - if ($id eq '') { $id = $Apache::lonxml::curdepth; } + my $id = &Apache::lonxml::get_id($parstack,$safeeval); push (@Apache::inputtags::input,$id); push (@Apache::inputtags::inputlist,$id); return $id; @@ -140,9 +174,20 @@ sub start_textfield { my $resid=$Apache::inputtags::response[-1]; if ($target eq 'web') { $Apache::lonxml::evaluate--; + my $partid=$Apache::inputtags::part; + my ($oldresponse,$newvariation); + if ((($Apache::lonhomework::history{"resource.$partid.type"} eq 'randomizetry') || + ($Apache::lonhomework::type eq 'randomizetry')) && + ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) { + if ($env{'form.'.$partid.'.rndseed'} ne + $Apache::lonhomework::history{"resource.$partid.rndseed"}) { + $newvariation = 1; + } + } + unless ($newvariation) { + $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); + } if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { - my $partid=$Apache::inputtags::part; - my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval); if ( $cols eq '') { $cols = 80; } my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval); @@ -152,18 +197,23 @@ sub start_textfield { if ($addchars) { $result.=&addchars('HWVAL_'.$resid,$addchars); } - &Apache::lonhtmlcommon::add_htmlareafields('HWVAL_'.$resid); + my $textareaclass = 'class="LC_richDetectHtml"'; $result.= '