--- loncom/homework/structuretags.pm 2005/07/10 22:56:26 1.298
+++ loncom/homework/structuretags.pm 2005/10/17 16:06:32 1.305
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.298 2005/07/10 22:56:26 albertel Exp $
+# $Id: structuretags.pm,v 1.305 2005/10/17 16:06:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -127,7 +127,7 @@ sub page_start {
$safeeval);
my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack,
$safeeval);
- $body_tag_start=&body_tag_start($background,$bgcolor);
+ $body_tag_start=&body_tag_start($target,$background,$bgcolor);
if ( ($target eq 'web' || $target eq 'webgrade')
&& $env{'request.state'} ne 'construct') {
my ($symb,undef,undef,undef,$publicuser)=
@@ -436,6 +436,11 @@ sub init_problem_globals {
@Apache::inputtags::partlist=();
$Apache::lonhomework::problemstatus='';
$Apache::lonhomework::ignore_response_errors=1;
+ } elsif ($type eq 'Task') {
+ $Apache::inputtags::part='0';
+ @Apache::inputtags::partlist=('0');
+ $Apache::lonhomework::problemstatus='';
+ $Apache::lonhomework::ignore_response_errors=1;
}
@Apache::inputtags::responselist = ();
@Apache::inputtags::importlist = ();
@@ -511,7 +516,6 @@ sub start_problem {
defined($env{'form.problemtype'})) {
$Apache::lonhomework::type=$env{'form.problemtype'};
}
- $Apache::lonhomework::default_type = $Apache::lonhomework::type;
&Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:");
}
if ($Apache::lonhomework::type eq '' ) {
@@ -524,6 +528,7 @@ sub start_problem {
&Apache::lonxml::debug("Using default type, problem, :$uri:");
}
}
+ $Apache::lonhomework::default_type = $Apache::lonhomework::type;
#added vars to the scripting enviroment
my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
@@ -566,11 +571,12 @@ sub start_problem {
value="'.$env{'form.username'}.'" />';
if ($env{'user.adv'}) {
$form_tag_start.=
- ' '.&mt(' Show All Foils');
+ $form_tag_start.= ' />'.&mt(' Show All Foils').
+ '';
}
$form_tag_start.='
';
}
@@ -644,6 +650,10 @@ sub start_problem {
}
my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }
+ if (lc($env{'course.'.$env{'request.course.id'}.
+ '.disableexampointprint'}) eq 'yes') {
+ $allow_print_points=0;
+ }
my $duedate = &Apache::lonnet::EXT("resource.$id.duedate");
$duedate = POSIX::strftime("%c",localtime($duedate));
my $temp_file;
@@ -657,14 +667,18 @@ sub start_problem {
my $due_file_content = $due_file_content[$#due_file_content];
chomp $due_file_content;
my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
+ my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource "'.$name_of_resourse.'"
located in
'.$env{'request.uri'}.'
STAMPOFPASSEDRESOURCEEND} \noindent ';
+ my $toc_line='\vskip 1 mm\noindent '.$startminipage.
+ '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
if ($due_file_content ne $duedate) {
$temp_file = Apache::File->new('>'.$filename);
print $temp_file "$duedate\n";
if (not $env{'request.symb'} =~ m/\.page_/) {
if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
- $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource "'.$name_of_resourse.'"
located in
'.$env{'request.uri'}.'
STAMPOFPASSEDRESOURCEEND} \noindent\textit{Due date: '.$duedate.'} \vskip 1 mm\noindent '.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
+ $result .= $begin_doc.
+ '\textit{Due date: '.$duedate.'} '.$toc_line;
} else {
- $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource "'.$name_of_resourse.'"
located in
'.$env{'request.uri'}.'
STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm \noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
+ $result .= $begin_doc.$toc_line;
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
}
} else {
@@ -672,7 +686,7 @@ sub start_problem {
}
} else {
if (not $env{'request.symb'} =~ m/\.page_/) {
- $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource "'.$name_of_resourse.'"
located in
'.$env{'request.uri'}.'
STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm\noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
+ $result .= $begin_doc.$toc_line;
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
} else {
$result .= '\vskip 1mm \\\\\\\\';
@@ -1049,7 +1063,9 @@ sub start_randomlist {
if ($target eq 'answer' || $target eq 'grade' || $target eq 'web' ||
$target eq 'tex' || $target eq 'analyze') {
my $body= &Apache::lonxml::get_all_text("/randomlist",$parser);
- my $b_parser= HTML::TokeParser->new(\$body);
+ my $b_parser= HTML::LCParser->new(\$body);
+ $b_parser->xml_mode(1);
+ $b_parser->marked_sections(1);
my $b_tok;
my @randomlist;
my $list_item;
@@ -1073,17 +1089,19 @@ sub start_randomlist {
# print "END-TAG $b_tok->[1]
";
# }
}
- my @idx_arr = (0 .. $#randomlist);
- &Apache::structuretags::shuffle(\@idx_arr);
- my $bodytext = '';
- my $show=$#randomlist;
- my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
- $showarg--;
- if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; }
- for(0 .. $show) {
- $bodytext .= "$randomlist[ $idx_arr[$_] ]";
+ if (@randomlist) {
+ my @idx_arr = (0 .. $#randomlist);
+ &Apache::structuretags::shuffle(\@idx_arr);
+ my $bodytext = '';
+ my $show=$#randomlist;
+ my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
+ $showarg--;
+ if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; }
+ for(0 .. $show) {
+ $bodytext .= "$randomlist[ $idx_arr[$_] ]";
+ }
+ &Apache::lonxml::newparser($parser,\$bodytext);
}
- &Apache::lonxml::newparser($parser,\$bodytext);
} elsif ($target eq 'edit' ) {
$result .=&Apache::edit::tag_start($target,$token);
$result .=&Apache::edit::text_arg('Maximum Tags to Show:','show',
@@ -1100,7 +1118,7 @@ sub start_randomlist {
sub shuffle {
my $a=shift;
my $i;
- if (defined(@$a)) {
+ if (ref($a) eq 'ARRAY' && @$a) {
&Apache::response::pushrandomnumber();
for($i=@$a;--$i;) {
my $j=int(&Math::Random::random_uniform() * ($i+1));
@@ -1206,6 +1224,10 @@ sub start_part {
if (defined($maxtries) && $maxtries < 0) {
$allow_print_points=0;
}
+ if (lc($env{'course.'.$env{'request.course.id'}.
+ '.disableexampointprint'}) eq 'yes') {
+ $allow_print_points=0;
+ }
if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
} elsif ($target eq 'web') {
$result.='';
@@ -1271,7 +1293,8 @@ sub start_preduedate {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
&Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']);
- if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
+ if (!$Apache::lonhomework::scantronmode &&
+ $Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
&Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER'));
&Apache::lonxml::get_all_text("/preduedate",$parser);
@@ -1287,7 +1310,8 @@ sub end_preduedate {
sub start_postanswerdate {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
if ($target eq 'web' || $target eq 'grade') {
- if ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
+ if ($Apache::lonhomework::scantronmode ||
+ $Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
&Apache::lonxml::get_all_text("/postanswerdate",$parser);
}
} elsif ($target eq 'tex') {