version 1.287, 2005/04/18 22:35:52
|
version 1.315, 2005/11/04 15:34:32
|
Line 68 sub end_tex {
|
Line 68 sub end_tex {
|
return ''; |
return ''; |
} |
} |
|
|
|
sub body_tag_start { |
|
my ($target,$background,$bgcolor)=@_; |
|
my $body_tag_start='<body onload="'.&Apache::lonmenu::loadevents().'" '. |
|
'onunload="'.&Apache::lonmenu::unloadevents().'" '; |
|
if ($env{'browser.imagesuppress'} eq 'on') { $background=''; } |
|
if ($background) { |
|
&Apache::lonxml::extlink($background); |
|
$body_tag_start.='background="'.$background.'" '; |
|
} else { |
|
if (($bgcolor) && ($env{'browser.blackwhite'} ne 'on')) { |
|
$body_tag_start.='bgcolor="'.$bgcolor.'" '; |
|
} else { |
|
$body_tag_start.='bgcolor="#ffffff"'; |
|
} |
|
} |
|
if ($env{'browser.fontenhance'} eq 'on') { |
|
$body_tag_start.=' style="font-size: x-large;" '; |
|
} |
|
$body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1); |
|
|
|
&Apache::lontexconvert::jsMath_reset(); |
|
if ($env{'environment.texengine'} eq 'jsMath') { |
|
$body_tag_start.=&Apache::lontexconvert::jsMath_header(); |
|
} |
|
return $body_tag_start; |
|
} |
|
|
sub page_start { |
sub page_start { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my %found; |
my %found; |
Line 90 sub page_start {
|
Line 117 sub page_start {
|
my $body_tag_start; |
my $body_tag_start; |
if (!defined($found{'body'}) && $env{'request.state'} eq 'construct' |
if (!defined($found{'body'}) && $env{'request.state'} eq 'construct' |
&& $env{'environment.remote'} eq 'off') { |
&& $env{'environment.remote'} eq 'off') { |
$body_tag_start=&Apache::loncommon::bodytag(); |
if ($target eq 'web' || $target eq 'edit') { |
$body_tag_start.=&Apache::lonxml::message_location(); |
$body_tag_start=&Apache::loncommon::bodytag(); |
|
$body_tag_start.=&Apache::lonxml::message_location(); |
|
} |
} elsif (!defined($found{'body'})) { |
} elsif (!defined($found{'body'})) { |
$body_tag_start='<body onload="'.&Apache::lonmenu::loadevents().'" '. |
|
'onunload="'.&Apache::lonmenu::unloadevents().'" '; |
|
my $background=&Apache::lonxml::get_param('background',$parstack, |
my $background=&Apache::lonxml::get_param('background',$parstack, |
$safeeval); |
$safeeval); |
if ($env{'browser.imagesuppress'} eq 'on') { $background=''; } |
my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack, |
if ($background) { |
$safeeval); |
$Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]= |
$body_tag_start=&body_tag_start($target,$background,$bgcolor); |
$background; |
if ( ($target eq 'web' || $target eq 'webgrade') |
$body_tag_start.='background="'.$background.'" '; |
&& $env{'request.state'} ne 'construct') { |
} else { |
|
my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack, |
|
$safeeval); |
|
if (($bgcolor) && ($env{'browser.blackwhite'} ne 'on')) { |
|
$body_tag_start.='bgcolor="'.$bgcolor.'" '; |
|
} else { |
|
$body_tag_start.='bgcolor="#ffffff"'; |
|
} |
|
} |
|
if ($env{'browser.fontenhance'} eq 'on') { |
|
$body_tag_start.=' style="font-size: x-large;" '; |
|
} |
|
$body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1); |
|
if ($env{'environment.texengine'} eq 'jsMath') { |
|
$body_tag_start.='<script type="text/javascript"> |
|
function NoFontMessage () {} |
|
</script>'."\n". |
|
'<script src="/adm/jsMath/jsMath.js"></script>'."\n"; |
|
} |
|
if ($target eq 'web' && $env{'request.state'} ne 'construct') { |
|
my ($symb,undef,undef,undef,$publicuser)= |
my ($symb,undef,undef,undef,$publicuser)= |
&Apache::lonxml::whichuser(); |
&Apache::lonxml::whichuser(); |
if ($symb eq '' && !$publicuser) { |
if ($symb eq '' && !$publicuser) { |
Line 185 sub setup_rndseed {
|
Line 192 sub setup_rndseed {
|
delete($env{'form.newrandomization'}); |
delete($env{'form.newrandomization'}); |
} |
} |
if (defined($rndseed) && $rndseed ne int($rndseed)) { |
if (defined($rndseed) && $rndseed ne int($rndseed)) { |
$rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed)); |
$rndseed=join(':',&Apache::lonnet::digest($rndseed)); |
} |
} |
if ($Apache::lonhomework::history{'resource.CODE'}) { |
if ($Apache::lonhomework::history{'resource.CODE'}) { |
$rndseed=&Apache::lonnet::rndseed(); |
$rndseed=&Apache::lonnet::rndseed(); |
Line 238 sub option {
|
Line 245 sub option {
|
|
|
sub problem_web_to_edit_header { |
sub problem_web_to_edit_header { |
my ($rndseed)=@_; |
my ($rndseed)=@_; |
my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" /> |
my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />'; |
<input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" /> |
if (!$Apache::lonhomework::parsing_a_task) { |
<input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" /> |
$result .= '<input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />'; |
|
} |
|
$result .= '<input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" /> |
<input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" /> |
<input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" /> |
<input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" /> |
<input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" /> |
<nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" /> |
<nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" /> |
Line 248 sub problem_web_to_edit_header {
|
Line 257 sub problem_web_to_edit_header {
|
$rndseed.'" |
$rndseed.'" |
onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr> |
onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr> |
<label><input type="checkbox" name="showallfoils" '; |
<label><input type="checkbox" name="showallfoils" '; |
|
my $show_all_foils_text = |
|
($Apache::lonhomework::parsing_a_task) ? |
|
&mt(' Show All Instances') |
|
: &mt(' Show All Foils'); |
|
|
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; } |
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; } |
$result.= ' />'.&mt(' Show All Foils'). |
$result.= ' />'.$show_all_foils_text. |
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). |
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). |
'</label><hr />'; |
'</label><hr />'; |
$result.=" |
if (!$Apache::lonhomework::parsing_a_task) { |
|
$result.=" |
<nobr> |
<nobr> |
Problem Status: |
Problem Status: |
<select name='problemstate'> |
<select name='problemstate'> |
Line 283 Feedback Mode:
|
Line 298 Feedback Mode:
|
</nobr> |
</nobr> |
<input type='submit' name='changeproblemmode' value='".&mt("Change")."' /> |
<input type='submit' name='changeproblemmode' value='".&mt("Change")."' /> |
<hr />"; |
<hr />"; |
my $numtoanalyze=$env{'form.numtoanalyze'}; |
my $numtoanalyze=$env{'form.numtoanalyze'}; |
if (!$numtoanalyze) { $numtoanalyze=20; } |
if (!$numtoanalyze) { $numtoanalyze=20; } |
$result.= '<input type="submit" name="problemmode" value='. |
$result.= '<input type="submit" name="problemmode" value='. |
&mt('"Calculate answers').'" /> for |
&mt('"Calculate answers').'" /> for |
<input type="text" name="numtoanalyze" value="'. |
<input type="text" name="numtoanalyze" value="'. |
$numtoanalyze.'" size="5" /> '.&mt('versions of this problem'). |
$numtoanalyze.'" size="5" /> '.&mt('versions of this problem'). |
'.'.&Apache::loncommon::help_open_topic("Analyze_Problem", |
'.'.&Apache::loncommon::help_open_topic("Analyze_Problem", |
'',undef,undef,300). |
'',undef,undef,300). |
'<hr />'; |
'<hr />'; |
|
} |
return $result; |
return $result; |
} |
} |
|
|
Line 321 sub initialize_storage {
|
Line 337 sub initialize_storage {
|
# if running user has student role. |
# if running user has student role. |
sub finalize_storage { |
sub finalize_storage { |
my $result; |
my $result; |
my ($temp) = keys %Apache::lonhomework::results; |
if (%Apache::lonhomework::results) { |
if ( $temp ne '' ) { |
|
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
if ($env{'request.state'} eq 'construct' || $symb eq '') { |
if ($env{'request.state'} eq 'construct' || $symb eq '') { |
$Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'}; |
$Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'}; |
Line 340 sub finalize_storage {
|
Line 355 sub finalize_storage {
|
} |
} |
return $result; |
return $result; |
} |
} |
|
use Data::Dumper; |
|
|
# -------------------------------------------------------------store_aggregates |
# -------------------------------------------------------------store_aggregates |
# Sends hash of values to be incremented in nohist_resourcetracker.db |
# Sends hash of values to be incremented in nohist_resourcetracker.db |
Line 349 sub store_aggregates {
|
Line 365 sub store_aggregates {
|
my ($symb,$courseid) = @_; |
my ($symb,$courseid) = @_; |
my %aggregate; |
my %aggregate; |
my @parts; |
my @parts; |
my ($cdomain,$cname) = split(/_/,$courseid); |
my $cdomain = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
foreach my $key (keys(%Apache::lonhomework::results)) { |
foreach my $key (keys(%Apache::lonhomework::results)) { |
if ($key =~ /resource\.([^\.]+)\.tries/) { |
if ($key =~ /resource\.([^\.]+)\.tries/) { |
push(@parts, $1); |
push(@parts, $1); |
Line 364 sub store_aggregates {
|
Line 381 sub store_aggregates {
|
} |
} |
if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) { |
if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) { |
$aggregate{$symb."\0".$part."\0users"} = 1; |
$aggregate{$symb."\0".$part."\0users"} = 1; |
|
} else { |
|
my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); |
|
if ($last_reset) { |
|
if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) { |
|
$aggregate{$symb."\0".$part."\0users"} = 1; |
|
} |
|
} |
} |
} |
$aggregate{$symb."\0".$part."\0attempts"} = 1; |
$aggregate{$symb."\0".$part."\0attempts"} = 1; |
} |
} |
&Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate, |
if (keys (%aggregate) > 0) { |
$cdomain,$cname); |
&Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate, |
|
$cdomain,$cname); |
|
} |
} |
} |
|
|
sub checkout_msg { |
sub checkout_msg { |
Line 408 ENDCHECKOUT
|
Line 434 ENDCHECKOUT
|
sub init_problem_globals { |
sub init_problem_globals { |
my ($type)=@_; |
my ($type)=@_; |
#initialize globals |
#initialize globals |
|
# For problems, we start out in part 0 (outside a <part> tag). |
|
# and part 0 is used to describe the main body of the <problem> |
|
# |
if ($type eq 'problem') { |
if ($type eq 'problem') { |
$Apache::inputtags::part='0'; |
$Apache::inputtags::part='0'; |
@Apache::inputtags::partlist=('0'); |
@Apache::inputtags::partlist=('0'); |
$Apache::lonhomework::problemstatus=&get_problem_status('0'); |
$Apache::lonhomework::problemstatus=&get_problem_status('0'); |
$Apache::lonhomework::ignore_response_errors=0; |
$Apache::lonhomework::ignore_response_errors=0; |
|
|
} elsif ($type eq 'library') { |
} elsif ($type eq 'library') { |
$Apache::inputtags::part=''; |
$Apache::inputtags::part=''; |
@Apache::inputtags::partlist=(); |
@Apache::inputtags::partlist=(); |
$Apache::lonhomework::problemstatus=''; |
$Apache::lonhomework::problemstatus=''; |
$Apache::lonhomework::ignore_response_errors=1; |
$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::responselist = (); |
@Apache::inputtags::importlist = (); |
@Apache::inputtags::importlist = (); |
Line 468 sub get_problem_status {
|
Line 504 sub get_problem_status {
|
sub start_problem { |
sub start_problem { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
|
|
|
# We'll use the redirection to fix up printing of duedates. |
|
&Apache::lonxml::startredirection(); |
|
|
|
# Problems don't nest and we don't allow more than one <problem> in |
|
# a .problem file. |
|
# |
if ( $Apache::inputtags::part ne '' || |
if ( $Apache::inputtags::part ne '' || |
$Apache::lonhomework::parsing_a_problem) { |
$Apache::lonhomework::parsing_a_problem) { |
&Apache::lonxml::error('Only one <problem> allowed in a .problem file'); |
&Apache::lonxml::error('Only one <problem> allowed in a .problem file'); |
Line 505 sub start_problem {
|
Line 547 sub start_problem {
|
&Apache::lonxml::debug("Using default type, problem, :$uri:"); |
&Apache::lonxml::debug("Using default type, problem, :$uri:"); |
} |
} |
} |
} |
|
$Apache::lonhomework::default_type = $Apache::lonhomework::type; |
|
|
#added vars to the scripting enviroment |
#added vars to the scripting enviroment |
my $expression='$external::part=\''.$Apache::inputtags::part.'\';'; |
my $expression='$external::part=\''.$Apache::inputtags::part.'\';'; |
Line 547 sub start_problem {
|
Line 590 sub start_problem {
|
value="'.$env{'form.username'}.'" />'; |
value="'.$env{'form.username'}.'" />'; |
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
$form_tag_start.= |
$form_tag_start.= |
' <input type="checkbox" name="showallfoils" '; |
' <label><input type="checkbox" name="showallfoils" '; |
if (defined($env{'form.showallfoils'})) { |
if (defined($env{'form.showallfoils'})) { |
$form_tag_start.='checked="on"'; |
$form_tag_start.='checked="on"'; |
} |
} |
$form_tag_start.= ' />'.&mt(' Show All Foils'); |
$form_tag_start.= ' />'.&mt(' Show All Foils'). |
|
'</label>'; |
} |
} |
$form_tag_start.='<hr />'; |
$form_tag_start.='<hr />'; |
} |
} |
Line 625 sub start_problem {
|
Line 669 sub start_problem {
|
} |
} |
my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); |
my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); |
if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; } |
if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; } |
my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); |
if (lc($env{'course.'.$env{'request.course.id'}. |
$duedate = POSIX::strftime("%c",localtime($duedate)); |
'.disableexampointprint'}) eq 'yes') { |
|
$allow_print_points=0; |
|
} |
|
my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header'); |
|
my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent '; |
|
my $toc_line='\vskip 1 mm\noindent '.$startminipage. |
|
'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}'; |
|
|
|
# Figure out what the due date is and if we need to print |
|
# it in the problem header. We have been logging the |
|
# last due date written to file. |
|
|
|
my $duetime = &Apache::lonnet::EXT("resource.$id.duedate"); |
|
my $duedate = POSIX::strftime("%c",localtime($duetime)); |
my $temp_file; |
my $temp_file; |
my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due"; |
my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due"; |
|
|
|
# Figure out what the last printed due date is or set it |
|
# to the epoch if no duedates have been printed. |
|
|
|
my $due_file_content = 0; # If the file does not yet exist, time is the epoch. |
if (-e $filename) { |
if (-e $filename) { |
$temp_file = Apache::File->new($filename); |
$temp_file = Apache::File->new($filename); |
} else { |
my @due_file = <$temp_file>; |
$temp_file = Apache::File->new('>>'.$filename); |
$due_file_content = $due_file[$#due_file]; |
} |
chomp $due_file_content; |
my @due_file_content = <$temp_file>; |
} |
my $due_file_content = $due_file_content[$#due_file_content]; |
|
chomp $due_file_content; |
# comparisons of the absolute times |
my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header'); |
if ($due_file_content != $duetime) { |
if ($due_file_content ne $duedate) { |
|
$temp_file = Apache::File->new('>'.$filename); |
$temp_file = Apache::File->new('>'.$filename); |
print $temp_file "$duedate\n"; |
print $temp_file "$duetime\n"; |
if (not $env{'request.symb'} =~ m/\.page_/) { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') { |
if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') { |
$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> 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 { |
} else { |
$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> 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}}';} |
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';} |
} |
} |
} else { |
} else { |
Line 653 sub start_problem {
|
Line 715 sub start_problem {
|
} |
} |
} else { |
} else { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
$result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> 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}}';} |
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';} |
} else { |
} else { |
$result .= '\vskip 1mm \\\\\\\\'; |
$result .= '\vskip 1mm \\\\\\\\'; |
Line 679 sub start_problem {
|
Line 741 sub start_problem {
|
|
|
sub end_problem { |
sub end_problem { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $result=''; |
my $result= &Apache::lonxml::endredirection(); # started in &start_problem |
|
|
my $status=$Apache::inputtags::status['-1']; |
my $status=$Apache::inputtags::status['-1']; |
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || |
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || |
$target eq 'tex') { |
$target eq 'tex') { |
Line 734 sub end_problem {
|
Line 797 sub end_problem {
|
} |
} |
if ($target eq 'answer' && ($env{'request.state'} eq 'construct') |
if ($target eq 'answer' && ($env{'request.state'} eq 'construct') |
&& $env{'form.answer_output_mode'} ne 'tex') { |
&& $env{'form.answer_output_mode'} ne 'tex') { |
$result.='</html>'; # normally we get it from xmlend, but in CSTR |
$result.=&Apache::lonxml::xmlend().'</html>'; |
|
# normally we get it from above, but in CSTR |
# we always show answer mode too. |
# we always show answer mode too. |
} |
} |
} elsif ($target eq 'meta') { |
} elsif ($target eq 'meta') { |
Line 746 sub end_problem {
|
Line 810 sub end_problem {
|
$result.=&Apache::response::meta_response_order(); |
$result.=&Apache::response::meta_response_order(); |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
&Apache::lonxml::debug("in end_problem with $target, edit"); |
&Apache::lonxml::debug("in end_problem with $target, edit"); |
$result = &problem_edit_footer(); |
$result .= &problem_edit_footer(); |
} |
} |
|
|
if ($env{'request.state'} eq 'construct' && $target eq 'web') { |
if ($env{'request.state'} eq 'construct' && $target eq 'web') { |
Line 1029 sub start_randomlist {
|
Line 1093 sub start_randomlist {
|
if ($target eq 'answer' || $target eq 'grade' || $target eq 'web' || |
if ($target eq 'answer' || $target eq 'grade' || $target eq 'web' || |
$target eq 'tex' || $target eq 'analyze') { |
$target eq 'tex' || $target eq 'analyze') { |
my $body= &Apache::lonxml::get_all_text("/randomlist",$parser); |
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 $b_tok; |
my @randomlist; |
my @randomlist; |
my $list_item; |
my $list_item; |
Line 1053 sub start_randomlist {
|
Line 1119 sub start_randomlist {
|
# print "<b>END-TAG $b_tok->[1]</b><br />"; |
# print "<b>END-TAG $b_tok->[1]</b><br />"; |
# } |
# } |
} |
} |
my @idx_arr = (0 .. $#randomlist); |
if (@randomlist) { |
&Apache::structuretags::shuffle(\@idx_arr); |
my @idx_arr = (0 .. $#randomlist); |
my $bodytext = ''; |
&Apache::structuretags::shuffle(\@idx_arr); |
my $show=$#randomlist; |
my $bodytext = ''; |
my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval); |
my $show=$#randomlist; |
$showarg--; |
my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval); |
if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; } |
$showarg--; |
for(0 .. $show) { |
if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; } |
$bodytext .= "$randomlist[ $idx_arr[$_] ]"; |
for(0 .. $show) { |
|
$bodytext .= "$randomlist[ $idx_arr[$_] ]"; |
|
} |
|
&Apache::lonxml::newparser($parser,\$bodytext); |
} |
} |
&Apache::lonxml::newparser($parser,\$bodytext); |
|
} elsif ($target eq 'edit' ) { |
} elsif ($target eq 'edit' ) { |
$result .=&Apache::edit::tag_start($target,$token); |
$result .=&Apache::edit::tag_start($target,$token); |
$result .=&Apache::edit::text_arg('Maximum Tags to Show:','show', |
$result .=&Apache::edit::text_arg('Maximum Tags to Show:','show', |
Line 1080 sub start_randomlist {
|
Line 1148 sub start_randomlist {
|
sub shuffle { |
sub shuffle { |
my $a=shift; |
my $a=shift; |
my $i; |
my $i; |
if (defined(@$a)) { |
if (ref($a) eq 'ARRAY' && @$a) { |
&Apache::response::pushrandomnumber(); |
&Apache::response::pushrandomnumber(); |
for($i=@$a;--$i;) { |
for($i=@$a;--$i;) { |
my $j=int(&Math::Random::random_uniform() * ($i+1)); |
my $j=int(&Math::Random::random_uniform() * ($i+1)); |
Line 1114 sub ordered_show_check {
|
Line 1182 sub ordered_show_check {
|
|
|
sub start_part { |
sub start_part { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
|
&Apache::lonxml::startredirection(); # we'll use redirection to fix up |
|
# duedates. |
my $result=''; |
my $result=''; |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; } |
$Apache::inputtags::part=$id; |
$Apache::inputtags::part=$id; |
push(@Apache::inputtags::partlist,$id); |
push(@Apache::inputtags::partlist,$id); |
@Apache::inputtags::response=(); |
@Apache::inputtags::response=(); |
Line 1186 sub start_part {
|
Line 1256 sub start_part {
|
if (defined($maxtries) && $maxtries < 0) { |
if (defined($maxtries) && $maxtries < 0) { |
$allow_print_points=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}}';} |
if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';} |
} elsif ($target eq 'web') { |
} elsif ($target eq 'web') { |
$result.='<a name="'.&Apache::lonnet::escape($Apache::inputtags::part).'" />'; |
$result.='<a name="'.&Apache::lonnet::escape($Apache::inputtags::part).'" />'; |
Line 1218 sub end_part {
|
Line 1292 sub end_part {
|
my $status=$Apache::inputtags::status['-1']; |
my $status=$Apache::inputtags::status['-1']; |
my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part); |
my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part); |
my $in_order_show=&ordered_show_check(); |
my $in_order_show=&ordered_show_check(); |
my $result=''; |
my $result= &Apache::lonxml::endredirection(); # started in &start_part |
if ( $target eq 'meta' ) { |
if ($target eq 'grade') { |
$result=''; |
|
} elsif ($target eq 'grade') { |
|
if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) && |
if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) && |
!$hidden && $in_order_show) { |
!$hidden && $in_order_show) { |
$result=&Apache::inputtags::grade; |
$result.=&Apache::inputtags::grade; |
} else { |
} else { |
# move any submission data to .hidden |
# move any submission data to .hidden |
&Apache::inputtags::hidealldata($Apache::inputtags::part); |
&Apache::inputtags::hidealldata($Apache::inputtags::part); |
Line 1236 sub end_part {
|
Line 1308 sub end_part {
|
if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') { |
if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') { |
$gradestatus=''; |
$gradestatus=''; |
} |
} |
$result=$gradestatus; |
$result.=$gradestatus; |
if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';} |
if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result=&Apache::edit::end_table(); |
$result.=&Apache::edit::end_table(); |
} |
} |
pop @Apache::inputtags::status; |
pop @Apache::inputtags::status; |
$Apache::inputtags::part=''; |
$Apache::inputtags::part=''; |
|
$Apache::lonhomework::type = $Apache::lonhomework::default_type; |
return $result; |
return $result; |
} |
} |
|
|
Line 1250 sub start_preduedate {
|
Line 1323 sub start_preduedate {
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') { |
&Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']); |
&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::inputtags::status['-1'] ne 'CANNOT_ANSWER') { |
&Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER')); |
&Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER')); |
&Apache::lonxml::get_all_text("/preduedate",$parser); |
&Apache::lonxml::get_all_text("/preduedate",$parser); |
Line 1266 sub end_preduedate {
|
Line 1340 sub end_preduedate {
|
sub start_postanswerdate { |
sub start_postanswerdate { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
if ($target eq 'web' || $target eq 'grade') { |
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); |
&Apache::lonxml::get_all_text("/postanswerdate",$parser); |
} |
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |