--- loncom/homework/structuretags.pm 2006/09/27 22:42:25 1.365
+++ loncom/homework/structuretags.pm 2007/04/06 21:22:24 1.375
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.365 2006/09/27 22:42:25 albertel Exp $
+# $Id: structuretags.pm,v 1.375 2007/04/06 21:22:24 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -88,6 +88,14 @@ sub page_start {
$parstack,$parser,$safeeval);
}
+ $extra_head.= '
+
+';
+
my %body_args;
if (defined($found{'html'})) {
$body_args{'skip_phases'}{'head'}=1;
@@ -142,7 +150,7 @@ sub page_start {
&& $env{'request.state'} ne 'construct'
&& ($target eq 'web' || $target eq 'webgrade')) {
- my ($symb,undef,undef,undef,$publicuser)= &Apache::lonxml::whichuser();
+ my ($symb,undef,undef,undef,$publicuser)= &Apache::lonnet::whichuser();
if ($symb eq '' && !$publicuser) {
my $help = &Apache::loncommon::help_open_topic("Ambiguous_Reference");
$help=&mt("Browsing resource, all submissions are temporary.")." ";
@@ -162,14 +170,14 @@ sub page_start {
if ($target eq 'edit') {
$form_tag_start.=&Apache::edit::form_change_detection();
}
- $form_tag_start.='>';
+ $form_tag_start.='>'."\n";
my $symb=&Apache::lonnet::symbread();
if ($symb =~ /\S/) {
$symb=
&HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb));
$form_tag_start.=
- '';
+ "\t".''."\n";
}
}
return ($page_start,$form_tag_start);
@@ -181,7 +189,7 @@ sub get_resource_name {
if (defined($Apache::lonhomework::name)) {
return $Apache::lonhomework::name;
}
- my ($symb)=&Apache::lonxml::whichuser();
+ my ($symb)=&Apache::lonnet::whichuser();
my $name=&Apache::lonnet::gettitle($symb);
if ($name eq '') {
$name=&Apache::lonnet::EXT('resource.title');
@@ -198,7 +206,7 @@ sub get_resource_name {
sub setup_rndseed {
my ($safeeval)=@_;
my $rndseed;
- my ($symb)=&Apache::lonxml::whichuser();
+ my ($symb)=&Apache::lonnet::whichuser();
if ($env{'request.state'} eq "construct"
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice'
@@ -213,7 +221,8 @@ sub setup_rndseed {
}
$env{'form.rndseed'}=$rndseed;
}
- if ($env{'form.resetdata'} eq &mt('New Problem Variation') ||
+ if ( ($env{'form.resetdata'} eq &mt('New Problem Variation')
+ && $env{'form.submitted'} eq 'yes') ||
$env{'form.newrandomization'} eq &mt('New Randomization')) {
srand(time);
$rndseed=int(rand(2100000000));
@@ -276,9 +285,7 @@ sub option {
sub problem_web_to_edit_header {
my ($rndseed)=@_;
my $result.='';
- if (!$Apache::lonhomework::parsing_a_task) {
- $result .= '';
- }
+ $result .= '';
$result .= '
@@ -293,9 +300,9 @@ sub problem_web_to_edit_header {
: &mt(' Show All Foils');
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; }
- $result.= ' />'.$show_all_foils_text.
+ $result.= ' />'.$show_all_foils_text.''.
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
- '
';
+ '';
if (!$Apache::lonhomework::parsing_a_task) {
$result.="
@@ -346,7 +353,7 @@ sub initialize_storage {
undef(%Apache::lonhomework::results);
undef(%Apache::lonhomework::history);
my ($symb,$courseid,$domain,$name) =
- &Apache::lonxml::whichuser($given_symb);
+ &Apache::lonnet::whichuser($given_symb);
# anonymous users (CODEd exams) have no data
if ($name eq 'anonymous'
@@ -360,7 +367,8 @@ sub initialize_storage {
my $namespace = $symb || $env{'request.uri'};
if ($env{'form.resetdata'} eq &mt('Reset Submissions') ||
- $env{'form.resetdata'} eq &mt('New Problem Variation') ||
+ ($env{'form.resetdata'} eq &mt('New Problem Variation')
+ && $env{'form.submitted'} eq 'yes') ||
$env{'form.newrandomization'} eq &mt('New Randomization')) {
&Apache::lonnet::tmpreset($namespace,'',$domain,$name);
&Apache::lonxml::debug("Attempt reset");
@@ -392,7 +400,7 @@ sub finalize_storage {
my @remove = grep(/^INTERNAL_/,keys(%Apache::lonhomework::results));
delete(@Apache::lonhomework::results{@remove});
my ($symb,$courseid,$domain,$name) =
- &Apache::lonxml::whichuser($given_symb);
+ &Apache::lonnet::whichuser($given_symb);
if ($env{'request.state'} eq 'construct'
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice') {
@@ -594,9 +602,6 @@ sub start_problem {
}
if ($target ne 'analyze') {
- if ($target eq 'web') {
- &Apache::lonhomework::showhash(%Apache::lonhomework::history);
- }
if ($env{'request.state'} eq 'construct') { &set_problem_state('0'); }
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
if (($env{'request.state'} eq 'construct') &&
@@ -618,6 +623,10 @@ sub start_problem {
$Apache::lonhomework::default_type = $Apache::lonhomework::type;
&initialize_storage();
+ if ($target eq 'web') {
+ &Apache::lonxml::debug(" grading history ");
+ &Apache::lonhomework::showhash(%Apache::lonhomework::history);
+ }
#added vars to the scripting enviroment
my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
@@ -656,7 +665,7 @@ sub start_problem {
}
#handle rand seed in construction space
my $rndseed=&setup_rndseed($safeeval);
- my ($symb)=&Apache::lonxml::whichuser();
+ my ($symb)=&Apache::lonnet::whichuser();
if ($env{'request.state'} ne "construct" &&
($symb eq '' || $Apache::lonhomework::type eq 'practice')) {
$form_tag_start.='';
# create a page header and exit
if ($env{'request.state'} eq "construct") {
@@ -786,7 +796,6 @@ sub end_problem {
}
if ($target eq 'tex') {
-
# Figure out the front matter and replace the
# INSERTTEXFRONTMATTERHERE in result with it. note that we do
# this in end_problem because whether or not we display due
@@ -962,7 +971,7 @@ sub end_problem {
sub start_library {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my ($result,$form_tag_start);
- if ($$tagstack[0] eq 'library') {
+ if ($#$tagstack eq 0 && $$tagstack[0] eq 'library') {
&init_problem_globals('library');
$Apache::lonhomework::type='problem';
}
@@ -977,7 +986,7 @@ sub start_library {
$result=$token->[4];
$result.=&Apache::edit::handle_insert();
} elsif (($target eq 'web' || $target eq 'webgrade')
- && $$tagstack[0] eq 'library'
+ && ($#$tagstack eq 0 && $$tagstack[0] eq 'library')
&& $env{'request.state'} eq "construct" ) {
my $name=&get_resource_name($parstack,$safeeval);
($result,$form_tag_start)=
@@ -996,11 +1005,14 @@ sub end_library {
my $result='';
if ($target eq 'edit') {
$result=&problem_edit_footer();
- } elsif ($target eq 'web' && $$tagstack[0] ne 'problem' &&
- $env{'request.state'} eq "construct") {
+ } elsif ($target eq 'web'
+ && ($#$tagstack eq 0 && $$tagstack[0] eq 'library')
+ && $env{'request.state'} eq "construct") {
$result.=''.&Apache::loncommon::end_page({'discussion' => 1});
}
- if ($$tagstack[0] eq 'library') { &reset_problem_globals('library') };
+ if ( $#$tagstack eq 0 && $$tagstack[0] eq 'library') {
+ &reset_problem_globals('library');
+ }
return $result;
}
@@ -1484,15 +1496,21 @@ sub end_preduedate {
return '';
}
+# In all the modes where text is
+# displayable, all we do is eat up the text between the start/stop
+# tags if the conditions are not right to display it.
sub start_postanswerdate {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- if ($target eq 'web' || $target eq 'grade' || $target eq 'webgrade') {
+ my $pav = &Apache::lonnet::allowed('pav', $env{'request.course.id'}) ||
+ &Apache::lonnet::allowed('pav',
+ $env{'request.course.id'}.'/'.$env{'request.course.sec'});
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'webgrade' ||
+ $target eq 'tex' ) {
if ($Apache::lonhomework::scantronmode ||
- $Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
+ $Apache::inputtags::status['-1'] ne 'SHOW_ANSWER' ||
+ (($target eq 'tex') && !$pav)) {
&Apache::lonxml::get_all_text("/postanswerdate",$parser,$style);
}
- } elsif ($target eq 'tex') {
- &Apache::lonxml::get_all_text("/postanswerdate",$parser,$style);
}
return '';
}
@@ -1653,7 +1671,7 @@ sub start_simpleeditbutton {
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
my $url=$env{'request.noversionuri'};
$url=~s/\?.*$//;
- my ($symb) = &Apache::lonxml::whichuser();
+ my ($symb) = &Apache::lonnet::whichuser();
$result='
'.
''.&mt('Edit').' - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
&Apache::loncommon::help_open_topic('Caching').'