--- loncom/homework/structuretags.pm 2006/04/14 21:09:54 1.344
+++ loncom/homework/structuretags.pm 2006/09/27 22:42:25 1.365
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.344 2006/04/14 21:09:54 albertel Exp $
+# $Id: structuretags.pm,v 1.365 2006/09/27 22:42:25 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,6 +38,9 @@ use Apache::lonlocal;
use Apache::lonxml;
use Apache::lonenc();
use Time::HiRes qw( gettimeofday tv_interval );
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
BEGIN {
&Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
}
@@ -70,7 +73,8 @@ sub end_tex {
}
sub page_start {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name,
+ $extra_head)=@_;
my %found;
foreach my $taginside (@$tagstack) {
foreach my $taglookedfor ('html','body','form') {
@@ -78,7 +82,6 @@ sub page_start {
}
}
-
if ($target eq 'tex') {
return
&Apache::londefdef::start_html($target,$token,$tagstack,
@@ -86,12 +89,11 @@ sub page_start {
}
my %body_args;
- my $extra_head;
if (defined($found{'html'})) {
$body_args{'skip_phases'}{'head'}=1;
} else {
- $extra_head = &Apache::lonhtmlcommon::spellheader();
+ $extra_head .= &Apache::lonhtmlcommon::spellheader();
my $css_href = &Apache::lonnet::EXT('resource.0.cssfile');
if ($css_href =~ /\S/) {
@@ -132,7 +134,7 @@ sub page_start {
$body_args{'force_register'} = 1;
$body_args{'add_entries'} = \%add_entries;
}
-
+ $body_args{'no_auto_mt_title'} = 1;
my $page_start = &Apache::loncommon::start_page($name,$extra_head,
\%body_args);
@@ -161,8 +163,15 @@ sub page_start {
$form_tag_start.=&Apache::edit::form_change_detection();
}
$form_tag_start.='>';
- }
+ my $symb=&Apache::lonnet::symbread();
+ if ($symb =~ /\S/) {
+ $symb=
+ &HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb));
+ $form_tag_start.=
+ '';
+ }
+ }
return ($page_start,$form_tag_start);
}
@@ -242,7 +251,7 @@ sub problem_edit_header {
'.
- &Apache::loncommon::help_open_menu('','Problem Editing Help','Problem_Editor_XML_Index','',5,'Authoring',undef,undef,undef,'Problem Editing Help')
+ &Apache::loncommon::help_open_menu('Problem Editing Help','Problem_Editor_XML_Index',5,'Authoring',undef,undef,undef,'Problem Editing Help')
.' |
'.
'';
}
@@ -250,7 +259,7 @@ sub problem_edit_header {
sub problem_edit_footer {
return ' |
'.
- &Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields).
+ &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields()).
"\n\n".&Apache::loncommon::end_page();
}
@@ -333,9 +342,18 @@ Feedback Mode:
}
sub initialize_storage {
- %Apache::lonhomework::results=();
- %Apache::lonhomework::history=();
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ my ($given_symb) = @_;
+ undef(%Apache::lonhomework::results);
+ undef(%Apache::lonhomework::history);
+ my ($symb,$courseid,$domain,$name) =
+ &Apache::lonxml::whichuser($given_symb);
+
+ # anonymous users (CODEd exams) have no data
+ if ($name eq 'anonymous'
+ && !defined($domain)) {
+ return;
+ }
+
if ($env{'request.state'} eq 'construct'
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice') {
@@ -355,6 +373,7 @@ sub initialize_storage {
%Apache::lonhomework::history=
&Apache::lonnet::restore($symb,$courseid,$domain,$name);
}
+
#ignore error conditions
my ($temp)=keys %Apache::lonhomework::history ;
if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); }
@@ -367,11 +386,13 @@ sub initialize_storage {
# Will increment totals for attempts, students, and corrects
# if running user has student role.
sub finalize_storage {
+ my ($given_symb) = @_;
my $result;
if (%Apache::lonhomework::results) {
my @remove = grep(/^INTERNAL_/,keys(%Apache::lonhomework::results));
delete(@Apache::lonhomework::results{@remove});
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ my ($symb,$courseid,$domain,$name) =
+ &Apache::lonxml::whichuser($given_symb);
if ($env{'request.state'} eq 'construct'
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice') {
@@ -442,13 +463,14 @@ sub checkout_msg {
'warning'=>'Checking out resources is subject to course policies, and may exclude future credit even if done erroneously.',
'checkout'=>'Check out Exam for Viewing',
'checkout?'=>'Check out Exam?');
+ my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});
return (<$lt{'resource'}
$lt{'id_expln'}
$lt{'warning'}
-
@@ -460,9 +482,10 @@ sub firstaccess_msg {
my ($map)=&Apache::lonnet::decode_symb($symb);
my $foldertitle=&Apache::lonnet::gettitle($map);
&Apache::lonxml::debug("map is $map title is $foldertitle");
+ my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});
return (<The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".
-
@@ -503,7 +526,8 @@ sub init_problem_globals {
@Apache::structuretags::whileline=();
$Apache::lonhomework::scantronmode=0;
undef($Apache::lonhomework::name);
-
+ undef($Apache::lonhomework::default_type);
+ undef($Apache::lonhomework::type);
}
sub reset_problem_globals {
@@ -515,6 +539,11 @@ sub reset_problem_globals {
#detect if we try to do 2 problems in one file
# undef($Apache::lonhomework::parsing_a_problem);
undef($Apache::lonhomework::name);
+ undef($Apache::lonhomework::default_type);
+ undef($Apache::lonhomework::type);
+ undef($Apache::lonhomework::scantronmode);
+ undef($Apache::lonhomework::problemstatus);
+ undef($Apache::lonhomework::ignore_response_errors);
}
sub set_problem_state {
@@ -564,7 +593,6 @@ sub start_problem {
$Apache::lonhomework::scantronmode=1;
}
- &initialize_storage();
if ($target ne 'analyze') {
if ($target eq 'web') {
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
@@ -589,6 +617,8 @@ sub start_problem {
}
$Apache::lonhomework::default_type = $Apache::lonhomework::type;
+ &initialize_storage();
+
#added vars to the scripting enviroment
my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
$expression.='$external::type=\''.$Apache::lonhomework::type.'\';';
@@ -596,11 +626,15 @@ sub start_problem {
my $status;
my $accessmsg;
- #should get back a or the neccesary stuff to start XML/MathML
my $name= &get_resource_name($parstack,$safeeval);
- my ($result,$form_tag_start)=
- &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval,
- $name);
+ my ($result,$form_tag_start);
+ if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex'
+ || $target eq 'edit') {
+ ($result,$form_tag_start) =
+ &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval,
+ $name);
+ }
+
if ($target eq 'tex' and $env{'request.symb'} =~ m/\.page_/) {$result='';}
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
@@ -702,6 +736,13 @@ sub start_problem {
'problem');
}
} elsif ($target eq 'web') {
+ if ($status eq 'CAN_ANSWER'
+ && $slot_name ne ''
+ && $Apache::lonhomework::history{'resource.0.checkedin'} eq '') {
+ # unproctored slot access, self checkin
+ &Apache::bridgetask::check_in('problem',undef,undef,
+ $slot_name);
+ }
$result.="\n $form_tag_start".
'';
# create a page header and exit
@@ -862,10 +903,10 @@ sub end_problem {
if ($target ne 'tex' &&
$env{'form.answer_output_mode'} ne 'tex') {
$result.="";
- $result.=&Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields);
+ $result.= &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields());
}
if ($target eq 'web') {
- $result.=&Apache::lonxml::xmlend().'';
+ $result.= &Apache::loncommon::end_page({'discussion' => 1});
} elsif ($target eq 'tex') {
my $endminipage = '';
if (not $env{'form.problem_split'}=~/yes/) {
@@ -873,7 +914,6 @@ sub end_problem {
}
if ($env{'form.print_discussions'} eq 'yes') {
$result.=&Apache::lonxml::xmlend($target,$parser);
- $result=~s/<\/html>//;
} else {
$result .= '\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
if (not $env{'request.symb'} =~ m/\.page_/) {
@@ -890,7 +930,7 @@ sub end_problem {
}
if ($target eq 'answer' && ($env{'request.state'} eq 'construct')
&& $env{'form.answer_output_mode'} ne 'tex') {
- $result.=&Apache::lonxml::xmlend().'