version 1.369, 2006/11/20 11:52:10
|
version 1.385, 2007/07/24 18:03:54
|
Line 47 BEGIN {
|
Line 47 BEGIN {
|
|
|
sub start_web { |
sub start_web { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style); |
if ($target ne 'edit' && $target ne 'modified') { |
if ($target eq 'web' || $target eq 'webgrade') { |
my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style); |
return $bodytext; |
if ($target eq 'web' || $target eq 'webgrade') { |
|
return $bodytext; |
|
} |
|
} elsif ($target eq "edit" ) { |
|
my $bodytext = |
|
&Apache::lonxml::get_all_text_unbalanced("/web",$parser); |
|
my $result = &Apache::edit::tag_start($target,$token); |
|
$result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1); |
|
return $result; |
|
} elsif ( $target eq "modified" ) { |
|
return $token->[4].&Apache::edit::modifiedfield("/web",$parser); |
} |
} |
return ''; |
return ''; |
} |
} |
Line 61 sub end_web {
|
Line 71 sub end_web {
|
sub start_tex { |
sub start_tex { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |
my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style); |
if ($target ne 'edit' && $target ne 'modified') { |
if ($target eq 'tex') { |
my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style); |
return $bodytext.' '; |
if ($target eq 'tex') { |
|
return $bodytext.' '; |
|
} |
|
} elsif ($target eq "edit" ) { |
|
my $bodytext = |
|
&Apache::lonxml::get_all_text_unbalanced("/tex",$parser); |
|
my $result = &Apache::edit::tag_start($target,$token); |
|
$result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1); |
|
return $result; |
|
} elsif ( $target eq "modified" ) { |
|
return $token->[4].&Apache::edit::modifiedfield("/tex",$parser); |
} |
} |
return $result;; |
return $result;; |
} |
} |
Line 88 sub page_start {
|
Line 108 sub page_start {
|
$parstack,$parser,$safeeval); |
$parstack,$parser,$safeeval); |
} |
} |
|
|
|
$extra_head.= ' |
|
<script type="text/javascript"> |
|
function setSubmittedPart (part) { |
|
this.document.lonhomework.submitted.value="part_"+part; |
|
} |
|
</script> |
|
'; |
|
|
my %body_args; |
my %body_args; |
if (defined($found{'html'})) { |
if (defined($found{'html'})) { |
$body_args{'skip_phases'}{'head'}=1; |
$body_args{'skip_phases'}{'head'}=1; |
Line 95 sub page_start {
|
Line 123 sub page_start {
|
|
|
$extra_head .= &Apache::lonhtmlcommon::spellheader(); |
$extra_head .= &Apache::lonhtmlcommon::spellheader(); |
|
|
my $css_href = &Apache::lonnet::EXT('resource.0.cssfile'); |
$extra_head .= &Apache::londefdef::generate_css_links(); |
if ($css_href =~ /\S/) { |
|
&Apache::lonxml::extlink($css_href); |
if ($env{'request.state'} eq 'construct') { |
$extra_head .= |
|
'<link rel="stylesheet" type="text/css" href="'.$css_href.'" />'; |
|
} |
|
if ($target eq 'edit') { |
|
$extra_head.=&Apache::edit::js_change_detection(). |
$extra_head.=&Apache::edit::js_change_detection(). |
"<script type=\"text/javascript\">\n". |
"<script type=\"text/javascript\">\n". |
"if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". |
"if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". |
Line 213 sub setup_rndseed {
|
Line 237 sub setup_rndseed {
|
} |
} |
$env{'form.rndseed'}=$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')) { |
$env{'form.newrandomization'} eq &mt('New Randomization')) { |
srand(time); |
srand(time); |
$rndseed=int(rand(2100000000)); |
$rndseed=int(rand(2100000000)); |
Line 276 sub option {
|
Line 301 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').'" />'; |
if (!$Apache::lonhomework::parsing_a_task) { |
$result .= '<input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />'; |
$result .= '<input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />'; |
|
} |
|
$result .= '<input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" /> |
$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').'" /> |
Line 286 sub problem_web_to_edit_header {
|
Line 309 sub problem_web_to_edit_header {
|
<input type="text" name="rndseed" size="10" value="'. |
<input type="text" name="rndseed" size="10" value="'. |
$rndseed.'" |
$rndseed.'" |
onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr> |
onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr> |
<label><input type="checkbox" name="showallfoils" '; |
<span class="LC_nobreak"><label><input type="checkbox" name="showallfoils" '; |
my $show_all_foils_text = |
my $show_all_foils_text = |
($Apache::lonhomework::parsing_a_task) ? |
($Apache::lonhomework::parsing_a_task) ? |
&mt(' Show All Instances') |
&mt(' Show All Instances') |
: &mt(' Show All Foils'); |
: &mt(' Show All Foils'); |
|
|
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; } |
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; } |
$result.= ' />'.$show_all_foils_text. |
$result.= ' />'.$show_all_foils_text.'</label></span>'. |
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). |
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). |
'</label><hr />'; |
'<hr />'; |
|
$result.=&mt('Apply style file').' |
|
<input type="text" name="style_file" value="'.&HTML::Entities::encode($env{'construct.style'},'"<>&').'" /> |
|
<a href="javascript:openbrowser(\'lonhomework\',\'style_file\',\'sty\')">'.&mt('Select').'</a> |
|
<input type="submit" name="clear_style_file" value="'.&mt('Clear').'" /> |
|
<br />'; |
|
|
if (!$Apache::lonhomework::parsing_a_task) { |
if (!$Apache::lonhomework::parsing_a_task) { |
$result.=" |
$result.=" |
<nobr> |
<nobr> |
Line 337 Feedback Mode:
|
Line 366 Feedback Mode:
|
'.'.&Apache::loncommon::help_open_topic("Analyze_Problem", |
'.'.&Apache::loncommon::help_open_topic("Analyze_Problem", |
'',undef,undef,300). |
'',undef,undef,300). |
'<hr />'; |
'<hr />'; |
|
} elsif ($Apache::lonhomework::parsing_a_task) { |
|
$result.=" |
|
<nobr> |
|
Problem Status: |
|
<select name='problemstate'> |
|
<option value=''></option> |
|
".&option('CLOSED' ,'problemstate').&mt("Closed")."</option> |
|
".&option('CAN_ANSWER' ,'problemstate').&mt("Answerable")."</option> |
|
".&option('WEB_GRADE' ,'problemstate').&mt("Criteria Grading")."</option> |
|
".&option('SHOW_ANSWER' ,'problemstate').&mt("Show Feedback")."</option> |
|
</select> |
|
</nobr> |
|
<input type='submit' name='changeproblemmode' value='".&mt("Change")."' /> |
|
<hr />"; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 360 sub initialize_storage {
|
Line 403 sub initialize_storage {
|
|
|
my $namespace = $symb || $env{'request.uri'}; |
my $namespace = $symb || $env{'request.uri'}; |
if ($env{'form.resetdata'} eq &mt('Reset Submissions') || |
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')) { |
$env{'form.newrandomization'} eq &mt('New Randomization')) { |
&Apache::lonnet::tmpreset($namespace,'',$domain,$name); |
&Apache::lonnet::tmpreset($namespace,'',$domain,$name); |
&Apache::lonxml::debug("Attempt reset"); |
&Apache::lonxml::debug("Attempt reset"); |
Line 731 sub start_problem {
|
Line 775 sub start_problem {
|
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser, |
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser, |
$style); |
$style); |
if ($target eq 'web') { |
if ($target eq 'web') { |
$result .= &Apache::bridgetask::proctor_validation_screen(); |
$result .= |
|
&Apache::bridgetask::proctor_validation_screen($slot); |
} elsif ($target eq 'grade') { |
} elsif ($target eq 'grade') { |
&Apache::bridgetask::proctor_check_auth($slot_name,$slot, |
&Apache::bridgetask::proctor_check_auth($slot_name,$slot, |
'problem'); |
'problem'); |
Line 769 sub start_problem {
|
Line 814 sub start_problem {
|
$result.=$temp; |
$result.=$temp; |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
$result=$token->[4]; |
$result=$token->[4]; |
$result.=&Apache::edit::handle_insert(); |
|
} else { |
} else { |
# page_start returned a starting result, delete it if we don't need it |
# page_start returned a starting result, delete it if we don't need it |
$result = ''; |
$result = ''; |
Line 787 sub end_problem {
|
Line 831 sub end_problem {
|
} |
} |
|
|
if ($target eq 'tex') { |
if ($target eq 'tex') { |
|
|
# Figure out the front matter and replace the |
# Figure out the front matter and replace the |
# INSERTTEXFRONTMATTERHERE in result with it. note that we do |
# INSERTTEXFRONTMATTERHERE in result with it. note that we do |
# this in end_problem because whether or not we display due |
# this in end_problem because whether or not we display due |
Line 863 sub end_problem {
|
Line 906 sub end_problem {
|
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
} |
} |
} else { |
} else { |
$frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\'; |
$frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\'.$startminipage; |
} |
} |
} else { |
} else { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
$frontmatter .= $begin_doc.$toc_line; |
$frontmatter .= $begin_doc.$toc_line; |
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
} else { |
} else { |
$frontmatter .= '\vskip 1mm \\\\\\\\'; |
$frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage; |
} |
} |
} |
} |
$result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/; |
$result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/; |
Line 920 sub end_problem {
|
Line 963 sub end_problem {
|
if (not $env{'request.symb'} =~ m/\.page_/) { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
$result .= $endminipage.'\end{document} '; |
$result .= $endminipage.'\end{document} '; |
} else { |
} else { |
$result .= ''; |
$result .= $endminipage; |
} |
} |
} |
} |
} |
} |
Line 947 sub end_problem {
|
Line 990 sub end_problem {
|
$result .= &problem_edit_footer(); |
$result .= &problem_edit_footer(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
$result .= $token->[2]; |
$result .= $token->[2]; |
$result.=&Apache::edit::handle_insertafter($token->[1]); |
|
} |
} |
|
|
if ($env{'request.state'} eq 'construct' && $target eq 'web') { |
if ($env{'request.state'} eq 'construct' && $target eq 'web') { |
Line 963 sub end_problem {
|
Line 1005 sub end_problem {
|
sub start_library { |
sub start_library { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($result,$form_tag_start); |
my ($result,$form_tag_start); |
if ($$tagstack[0] eq 'library') { |
if ($#$tagstack eq 0 && $$tagstack[0] eq 'library') { |
&init_problem_globals('library'); |
&init_problem_globals('library'); |
$Apache::lonhomework::type='problem'; |
$Apache::lonhomework::type='problem'; |
} |
} |
Line 976 sub start_library {
|
Line 1018 sub start_library {
|
$result.=$temp; |
$result.=$temp; |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
$result=$token->[4]; |
$result=$token->[4]; |
$result.=&Apache::edit::handle_insert(); |
|
} elsif (($target eq 'web' || $target eq 'webgrade') |
} elsif (($target eq 'web' || $target eq 'webgrade') |
&& $$tagstack[0] eq 'library' |
&& ($#$tagstack eq 0 && $$tagstack[0] eq 'library') |
&& $env{'request.state'} eq "construct" ) { |
&& $env{'request.state'} eq "construct" ) { |
my $name=&get_resource_name($parstack,$safeeval); |
my $name=&get_resource_name($parstack,$safeeval); |
($result,$form_tag_start)= |
($result,$form_tag_start)= |
Line 997 sub end_library {
|
Line 1038 sub end_library {
|
my $result=''; |
my $result=''; |
if ($target eq 'edit') { |
if ($target eq 'edit') { |
$result=&problem_edit_footer(); |
$result=&problem_edit_footer(); |
} elsif ($target eq 'web' && $$tagstack[0] ne 'problem' && |
} elsif ($target eq 'web' |
$env{'request.state'} eq "construct") { |
&& ($#$tagstack eq 0 && $$tagstack[0] eq 'library') |
|
&& $env{'request.state'} eq "construct") { |
$result.='</form>'.&Apache::loncommon::end_page({'discussion' => 1}); |
$result.='</form>'.&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; |
return $result; |
} |
} |
|
|
Line 1037 sub start_block {
|
Line 1081 sub start_block {
|
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') { |
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') { |
my $code = $token->[2]->{'condition'}; |
my $code = $token->[2]->{'condition'}; |
if (defined($code)) { |
if (defined($code) && $code ne '') { |
if (!$Apache::lonxml::default_homework_loaded) { |
if (!$Apache::lonxml::default_homework_loaded) { |
&Apache::lonxml::default_homework_load($safeeval); |
&Apache::lonxml::default_homework_load($safeeval); |
} |
} |
Line 1204 sub end_while {
|
Line 1248 sub end_while {
|
while ($return) { |
while ($return) { |
if (time-$starttime > |
if (time-$starttime > |
$Apache::lonnet::perlvar{'lonScriptTimeout'}) { |
$Apache::lonnet::perlvar{'lonScriptTimeout'}) { |
#$return = 0; $error=1; next; |
$return = 0; $error=1; next; |
} |
} |
$result.=&Apache::scripttag::xmlparse($bodytext); |
$result.=&Apache::scripttag::xmlparse($bodytext); |
|
if ($target eq 'grade' || $target eq 'answer' || |
|
$target eq 'analyze') { |
|
# grade/answer/analyze should produce no output but if we |
|
# are redirecting, the redirecter should know what to do |
|
# with the output |
|
if (!$Apache::lonxml::redirection) { undef($result); } |
|
} |
$return = &Apache::run::run($code,$safeeval); |
$return = &Apache::run::run($code,$safeeval); |
} |
} |
if ($error) { |
if ($error) { |
Line 1420 sub start_part {
|
Line 1471 sub start_part {
|
#limiting ids to only letters numbers, and space |
#limiting ids to only letters numbers, and space |
$token->[2]->{'id'}=~s/[^A-Za-z0-9 ]//gs; |
$token->[2]->{'id'}=~s/[^A-Za-z0-9 ]//gs; |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
|
} |
} |
} |
} |
return $result; |
return $result; |
Line 1458 sub end_part {
|
Line 1508 sub end_part {
|
$result.=&Apache::edit::end_table(); |
$result.=&Apache::edit::end_table(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
$result .= $token->[2]; |
$result .= $token->[2]; |
$result.=&Apache::edit::handle_insertafter($token->[1]); |
|
} |
} |
pop @Apache::inputtags::status; |
pop @Apache::inputtags::status; |
$Apache::inputtags::part=''; |
$Apache::inputtags::part=''; |
Line 1490 sub end_preduedate {
|
Line 1539 sub end_preduedate {
|
# tags if the conditions are not right to display it. |
# tags if the conditions are not right to display it. |
sub start_postanswerdate { |
sub start_postanswerdate { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
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' || |
if ($target eq 'web' || $target eq 'grade' || $target eq 'webgrade' || |
$target eq 'tex') { |
$target eq 'tex' ) { |
if ($Apache::lonhomework::scantronmode || |
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); |
&Apache::lonxml::get_all_text("/postanswerdate",$parser,$style); |
} |
} |
} |
} |
Line 1623 sub start_endouttext {
|
Line 1676 sub start_endouttext {
|
if ($target eq "edit" ) { $result="</td></tr>".&Apache::edit::end_table()."\n"; } |
if ($target eq "edit" ) { $result="</td></tr>".&Apache::edit::end_table()."\n"; } |
if ($target eq "modified") { |
if ($target eq "modified") { |
$result='<endouttext />'. |
$result='<endouttext />'. |
&Apache::edit::handle_insertafter('startouttext'); } |
&Apache::edit::handle_insertafter('startouttext'); |
|
} |
return $result; |
return $result; |
} |
} |
|
|