version 1.465.2.7, 2010/12/20 05:51:35
|
version 1.510, 2013/01/03 21:04:44
|
Line 61 use Apache::lonlocal;
|
Line 61 use Apache::lonlocal;
|
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::londefdef; |
use Apache::londefdef; |
use Apache::lonenc(); |
use Apache::lonenc(); |
|
use Apache::loncommon(); |
use Time::HiRes qw( gettimeofday tv_interval ); |
use Time::HiRes qw( gettimeofday tv_interval ); |
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA; |
use LONCAPA; |
Line 69 BEGIN {
|
Line 70 BEGIN {
|
&Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startpartmarker','startouttext','endpartmarker','endouttext','simpleeditbutton','definetag')); |
&Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startpartmarker','startouttext','endpartmarker','endouttext','simpleeditbutton','definetag')); |
} |
} |
|
|
|
|
|
#--------------------------------------------------------------------------------- |
|
# |
|
# This section of code deals with hyphenation management. |
|
# We must do three things: |
|
# - keep track fo the desired languages to alter the header. |
|
# - provide hyphenation selection as needed by each language that appears in the |
|
# text. |
|
# - Provide the header text needed to make available the desired hyphenations. |
|
# |
|
# |
|
|
|
# Hash whose keys are the languages encountered in the document/resource. |
|
# |
|
|
|
my %languages_required; |
|
## |
|
# Given a language selection as input returns a chunk of LaTeX that |
|
# selects the required hyphenator. |
|
# |
|
# @param language - the language being selected. |
|
# @return string |
|
# @retval The LaTeX needed to select the hyphenation appropriate to the language. |
|
# |
|
sub select_hyphenation { |
|
my $language = shift; |
|
|
|
$language = &Apache::loncommon::latexlanguage($language); # Translate -> latex language. |
|
|
|
# If there is no latex language there's not much we can do: |
|
|
|
if ($language) { |
|
&require_language($language); |
|
my $babel_hyphenation = "\\selectlanguage{$language}"; |
|
|
|
return $babel_hyphenation; |
|
} else { |
|
return ''; |
|
} |
|
} |
|
## |
|
# Selects hyphenation based on the current problem metadata. |
|
# This requires that |
|
# - There is a language metadata item set for the problem. |
|
# - The language has a latex/babel hyphenation. |
|
# |
|
# @note: Uses &Apache::lonxml::request to locate the Uri associated with |
|
# this problem. |
|
# @return string (possibly empty). |
|
# @retval If not empty an appropriate \selectlanguage{} directive. |
|
# |
|
sub select_metadata_hyphenation { |
|
my $uri = $Apache::lonxml::request->uri; |
|
my $language = &Apache::lonnet::metadata($uri, 'language'); |
|
my $latex_language = &Apache::loncommon::latexhyphenation($language); |
|
if ($latex_language) { |
|
return '\selectlanguage{'.$latex_language."}\n"; |
|
} |
|
return ''; # no latex hyphenation or no lang metadata. |
|
} |
|
|
|
|
|
## |
|
# Clears the set of languages required by the document being rendered. |
|
# |
|
sub clear_required_languages { |
|
%languages_required = (); |
|
} |
|
## |
|
# Allows an external client of this module to register a need for a language: |
|
# |
|
# @param LaTeX language required: |
|
# |
|
sub require_language { |
|
my $language = shift; |
|
$languages_required{$language} = 1; |
|
} |
|
|
|
## |
|
# Provides the header for babel that indicates the languages |
|
# the document requires. |
|
# @return string |
|
# @retval \usepackage[lang1,lang2...]{babel} |
|
# @retval '' if there are no languages_required. |
|
sub languages_header { |
|
my $header =''; |
|
my @languages = (keys(%languages_required)); |
|
|
|
# Only generate the header if there are languages: |
|
|
|
if (scalar @languages) { |
|
my $language_list = join(',', (@languages)); |
|
$header = '\usepackage['.$language_list."]{babel}\n"; |
|
} |
|
return $header; |
|
} |
|
|
|
#---------------------------------------------------------------------------------- |
|
|
sub start_web { |
sub start_web { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if ($target ne 'edit' && $target ne 'modified') { |
if ($target ne 'edit' && $target ne 'modified') { |
Line 128 sub homework_js {
|
Line 228 sub homework_js {
|
&setmode_javascript(). |
&setmode_javascript(). |
<<'JS'; |
<<'JS'; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function setSubmittedPart (part) { |
// <![CDATA[ |
this.document.lonhomework.submitted.value="part_"+part; |
function setSubmittedPart (part,prefix) { |
|
if (typeof(prefix) == 'undefined') { |
|
this.document.lonhomework.submitted.value="part_"+part; |
|
} else { |
|
for (var i=0;i<this.document.lonhomework.elements.length;i++) { |
|
if (this.document.lonhomework.elements[i].name == prefix+'submitted') { |
|
this.document.lonhomework.elements[i].value="part_"+part; |
|
} |
|
} |
|
} |
} |
} |
|
|
function image_response_click (which, e) { |
function image_response_click (which, e) { |
Line 145 function image_response_click (which, e)
|
Line 254 function image_response_click (which, e)
|
input_element.value = click; |
input_element.value = click; |
img_element.src = '/adm/randomlabel.png?token='+token+'&clickdata='+click; |
img_element.src = '/adm/randomlabel.png?token='+token+'&clickdata='+click; |
} |
} |
|
// ]]> |
</script> |
</script> |
JS |
JS |
} |
} |
Line 153 JS
|
Line 262 JS
|
sub setmode_javascript { |
sub setmode_javascript { |
return <<"ENDSCRIPT"; |
return <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
|
// <![CDATA[ |
function setmode(form,probmode) { |
function setmode(form,probmode) { |
form.problemmode.value = probmode; |
form.problemmode.value = probmode; |
form.submit(); |
form.submit(); |
} |
} |
</script> |
// ]]> |
ENDSCRIPT |
|
} |
|
|
|
sub file_delchk_js { |
|
my $delfilewarn = &mt('You have indicated you wish to delete some files previously included for submission.').'\\n'. |
|
&mt('Deleted files will not be graded.').' '. |
|
&mt('Submit Answer?'); |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
function file_deletion_check(formname) { |
|
var str = new RegExp("^HWFILE.+_delete\$"); |
|
var delfilecount = 0; |
|
var elemnum = formname.elements.length; |
|
if (elemnum == 0) { |
|
return true; |
|
} |
|
for (i=0; i<formname.elements.length; i++) { |
|
var id = formname.elements[i].id; |
|
if (id != '') { |
|
if (str.test(id)) { |
|
if (formname.elements[i].type == 'checkbox') { |
|
if (formname.elements[i].checked) { |
|
delfilecount ++; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (delfilecount > 0) { |
|
if (confirm("$delfilewarn")) { |
|
return true; |
|
} else { |
|
return false; |
|
} |
|
} else { |
|
return true; |
|
} |
|
} |
|
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
} |
} |
Line 225 sub page_start {
|
Line 297 sub page_start {
|
$extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); |
$extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); |
} |
} |
my $is_task = ($env{'request.uri'} =~ /\.task$/); |
my $is_task = ($env{'request.uri'} =~ /\.task$/); |
|
my $needs_upload; |
|
my ($symb)= &Apache::lonnet::whichuser(); |
|
my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb); |
if ($is_task) { |
if ($is_task) { |
$extra_head .= &file_delchk_js(); |
$extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js(); |
|
} else { |
|
if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.uploadedfiletypes") ne '') { |
|
unless ($env{'request.state'} eq 'construct') { |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
my $mapres = $navmap->getResourceByUrl($map); |
|
my $is_page; |
|
if (ref($mapres)) { |
|
$is_page = $mapres->is_page(); |
|
} |
|
unless ($is_page) { |
|
$needs_upload = 1; |
|
} |
|
} |
|
} |
|
} else { |
|
unless ($env{'request.state'} eq 'construct') { |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
my $mapres = $navmap->getResourceByUrl($map); |
|
my $is_page; |
|
if (ref($mapres)) { |
|
$is_page = $mapres->is_page(); |
|
} |
|
unless ($is_page) { |
|
my $res = $navmap->getBySymb($symb); |
|
if (ref($res)) { |
|
my $partlist = $res->parts(); |
|
if (ref($partlist) eq 'ARRAY') { |
|
foreach my $part (@{$partlist}) { |
|
my @types = $res->responseType($part); |
|
my @ids = $res->responseIds($part); |
|
for (my $i=0; $i < scalar(@ids); $i++) { |
|
if ($types[$i] eq 'essay') { |
|
my $partid = $part.'_'.$ids[$i]; |
|
if (&Apache::lonnet::EXT("resource.$partid.uploadedfiletypes") ne '') { |
|
$needs_upload = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($needs_upload) { |
|
$extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js(); |
|
} |
} |
} |
|
|
my %body_args; |
my %body_args; |
Line 253 sub page_start {
|
Line 379 sub page_start {
|
} elsif (!defined($found{'body'}) |
} elsif (!defined($found{'body'}) |
&& $env{'request.state'} eq 'construct') { |
&& $env{'request.state'} eq 'construct') { |
if ($target eq 'web' || $target eq 'edit') { |
if ($target eq 'web' || $target eq 'edit') { |
if ($env{'environment.remote'} ne 'off') { |
|
$body_args{'only_body'} = 1; |
|
} |
|
# Breadcrumbs for Construction Space |
# Breadcrumbs for Construction Space |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Construction Space', |
'text' => 'Construction Space', |
'href' => &Apache::loncommon::authorspace(), |
'href' => &Apache::loncommon::authorspace($env{'request.uri'}), |
}); |
}); |
# breadcrumbs (and tools) will be created |
# breadcrumbs (and tools) will be created |
# in start_page->bodytag->innerregister |
# in start_page->bodytag->innerregister |
Line 289 sub page_start {
|
Line 412 sub page_start {
|
# $body_args{'no_title'} = 1; |
# $body_args{'no_title'} = 1; |
$body_args{'force_register'} = 1; |
$body_args{'force_register'} = 1; |
$body_args{'add_entries'} = \%add_entries; |
$body_args{'add_entries'} = \%add_entries; |
if ($env{'environment.remote'} eq 'off' |
if ( $env{'request.state'} eq 'construct') { |
&& $env{'request.state'} eq 'construct') { |
|
$body_args{'only_body'} = 1; |
$body_args{'only_body'} = 1; |
} |
} |
} |
} |
Line 313 sub page_start {
|
Line 435 sub page_start {
|
if (!defined($found{'body'}) && $env{'request.state'} ne 'construct') { |
if (!defined($found{'body'}) && $env{'request.state'} ne 'construct') { |
$page_start .= &Apache::lonxml::message_location(); |
$page_start .= &Apache::lonxml::message_location(); |
} |
} |
|
|
my $form_tag_start; |
my $form_tag_start; |
if (!defined($found{'form'})) { |
if (!defined($found{'form'})) { |
$form_tag_start='<form name="lonhomework" enctype="multipart/form-data" method="post" action="'; |
$form_tag_start='<form name="lonhomework" enctype="multipart/form-data" method="post" action="'; |
Line 324 sub page_start {
|
Line 445 sub page_start {
|
if ($target eq 'edit') { |
if ($target eq 'edit') { |
$form_tag_start.=&Apache::edit::form_change_detection(); |
$form_tag_start.=&Apache::edit::form_change_detection(); |
} |
} |
if ($is_task) { |
my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser(); |
$form_tag_start .= ' onsubmit="return file_deletion_check(this);"'; |
my ($path,$multiresp) = |
|
&Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom); |
|
if (($is_task) || ($needs_upload)) { |
|
$form_tag_start .= ' onsubmit="return file_submission_check(this,'."'$path','$multiresp'".');"'; |
} |
} |
$form_tag_start.='>'."\n"; |
$form_tag_start.='>'."\n"; |
|
|
my $symb=&Apache::lonnet::symbread(); |
|
if ($symb =~ /\S/) { |
if ($symb =~ /\S/) { |
$symb= |
$symb= |
&HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb)); |
&HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb)); |
Line 391 sub setup_rndseed {
|
Line 514 sub setup_rndseed {
|
} |
} |
$env{'form.rndseed'}=$rndseed; |
$env{'form.rndseed'}=$rndseed; |
} |
} |
if (($env{'request.state'} eq "construct") && |
if (($env{'request.state'} eq "construct") && |
($Apache::lonhomework::type eq 'randomizetry')) { |
($Apache::lonhomework::type eq 'randomizetry')) { |
my $tries = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"}; |
my $tries = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.tries"}; |
if ($tries) { |
if ($tries) { |
Line 408 sub setup_rndseed {
|
Line 531 sub setup_rndseed {
|
delete($env{'form.resetdata'}); |
delete($env{'form.resetdata'}); |
delete($env{'form.newrandomization'}); |
delete($env{'form.newrandomization'}); |
} |
} |
if (defined($rndseed) && $rndseed ne int($rndseed)) { |
$rndseed=~s/\,/\:/g; |
$rndseed=join(':',&Apache::lonnet::digest($rndseed)); |
$rndseed=~s/[^\w\d\:\-]//g; |
|
if (defined($rndseed)) { |
|
my ($c1,$c2)=split(/\:/,$rndseed); |
|
unless ($c2) { $c2=0; } |
|
unless (($c1==int($c1)) && ($c2==int($c2))) { |
|
$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 461 sub remember_problem_state {
|
Line 590 sub remember_problem_state {
|
<input type="hidden" name="problemstatus" value="'.$env{'form.problemstatus'}.'" />'; |
<input type="hidden" name="problemstatus" value="'.$env{'form.problemstatus'}.'" />'; |
} |
} |
|
|
|
sub problem_edit_action_button { |
|
my ($name,$action,$accesskey,$text,$flag)=@_; |
|
my $actionscript="setmode(this.form,'$action')"; |
|
return "\n<input type='button' name='$name' accesskey='$accesskey' value='".&mt($text)."'". |
|
($flag?&Apache::edit::submit_ask_anyway($actionscript):&Apache::edit::submit_dont_ask($actionscript))." />"; |
|
} |
|
|
sub problem_edit_buttons { |
sub problem_edit_buttons { |
return ' |
my ($mode)=@_; |
<div class="LC_edit_problem_discards"> |
# Buttons that do not save |
<input type="button" name="submitmode" accesskey="d" value="'.&mt('Discard Edits and View').'" '. |
my $result='<div class="LC_edit_problem_discards">'. |
' onclick="javscript:setmode(this.form,'."'discard'".')" /> |
&problem_edit_action_button('subdiscview','discard','d','Discard Edits and View',1); |
<input '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'editxml'".')').' type="button" name="submitmode" accesskey="x" value="'.&mt('EditXML').'" /> |
if ($mode eq 'editxml') { |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
$result.=&problem_edit_action_button('subedit','edit','e','Edit',1); |
</div> |
$result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1); |
<div class="LC_edit_problem_saves"> |
$result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); |
<input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save and Edit').'" /> |
} else { |
<input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" /> |
$result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); |
</div>'; |
$result.=&problem_edit_action_button('subundo','undo','u','Undo',1); |
|
} |
|
$result.="\n</div>"; |
|
# Buttons that save |
|
$result.='<div class="LC_edit_problem_saves">'; |
|
if ($mode eq 'editxml') { |
|
$result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML'); |
|
$result.=&problem_edit_action_button('subsaveview','saveviewxml','v','Save and View'); |
|
} else { |
|
$result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit'); |
|
$result.=&problem_edit_action_button('subsaveview','saveview','v','Save and View'); |
|
} |
|
$result.="\n</div>\n"; |
|
return $result; |
} |
} |
|
|
sub problem_edit_header { |
sub problem_edit_header { |
return '<input type="hidden" name="submitted" value="edit" /><input type="hidden" name="problemmode" value="edit" />'. |
return '<input type="hidden" name="submitted" value="edit" />'. |
&Apache::structuretags::remember_problem_state().' |
&remember_problem_state('edit').' |
<div class="LC_edit_problem_header"> |
<div class="LC_edit_problem_header"> |
<div class="LC_edit_problem_header_title"> |
<div class="LC_edit_problem_header_title"> |
'.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').' |
'.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').' |
</div>'. |
</div>'. |
|
'<input type="hidden" name="problemmode" value="saveedit" />'. |
&problem_edit_buttons().' |
&problem_edit_buttons().' |
<hr style="clear:both;" /> |
<hr style="clear:both;" /> |
'.&Apache::lonxml::message_location().' |
'.&Apache::lonxml::message_location().' |
Line 560 sub problem_web_to_edit_header {
|
Line 710 sub problem_web_to_edit_header {
|
".&mt("Problem Type:")." |
".&mt("Problem Type:")." |
<select name='problemtype'> |
<select name='problemtype'> |
<option value=''></option> |
<option value=''></option> |
".&option('exam' ,'problemtype').&mt("Exam Problem")."</option> |
".&option('exam' ,'problemtype').&mt("Bubblesheet Exam Problem")."</option> |
".&option('problem','problemtype').&mt("Homework Problem")."</option> |
".&option('problem','problemtype').&mt("Homework Problem")."</option> |
".&option('survey' ,'problemtype').&mt("Survey Question")."</option> |
".&option('survey' ,'problemtype').&mt("Survey Question")."</option> |
".&option('surveycred' ,'problemtype').&mt("Survey Question (with credit)")."</option> |
".&option('surveycred' ,'problemtype').&mt("Survey Question (with credit)")."</option> |
Line 618 $show_all
|
Line 768 $show_all
|
<div class="LC_edit_problem_header_randomize_row"> |
<div class="LC_edit_problem_header_randomize_row"> |
<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="changerandseed" value="'.&mt('Change Random Seed To:').'" /> |
<input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" /> |
<input type="text" name="rndseed" size="10" value="'. |
<input type="text" name="rndseed" size="24" value="'. |
$rndseed.'" |
$rndseed.'" |
onchange="javascript:document.lonhomework.changerandseed.click()" />'; |
onchange="javascript:document.lonhomework.changerandseed.click()" />'; |
|
|
Line 757 sub store_aggregates {
|
Line 907 sub store_aggregates {
|
foreach my $part (@parts) { |
foreach my $part (@parts) { |
if ($env{'request.role'} =~/^st/) { |
if ($env{'request.role'} =~/^st/) { |
if ($Apache::lonhomework::results{'resource.'.$part.'.award'} |
if ($Apache::lonhomework::results{'resource.'.$part.'.award'} |
eq 'APPROX_ANS' || |
eq 'APPROX_ANS' || |
$Apache::lonhomework::results{'resource.'.$part.'.award'} |
$Apache::lonhomework::results{'resource.'.$part.'.award'} |
eq 'EXACT_ANS') { |
eq 'EXACT_ANS') { |
$aggregate{$symb."\0".$part."\0correct"} = 1; |
$aggregate{$symb."\0".$part."\0correct"} = 1; |
} |
} |
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 { |
} else { |
my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); |
my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); |
if ($last_reset) { |
if ($last_reset) { |
if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) { |
if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) { |
$aggregate{$symb."\0".$part."\0users"} = 1; |
$aggregate{$symb."\0".$part."\0users"} = 1; |
Line 774 sub store_aggregates {
|
Line 924 sub store_aggregates {
|
} |
} |
$aggregate{$symb."\0".$part."\0attempts"} = 1; |
$aggregate{$symb."\0".$part."\0attempts"} = 1; |
} |
} |
if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || |
if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred') || |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred') || |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry')) { |
($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry')) { |
if ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry') { |
if ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry') { |
Line 782 sub store_aggregates {
|
Line 932 sub store_aggregates {
|
} else { |
} else { |
$anoncounter{$symb."\0".$part} = 1; |
$anoncounter{$symb."\0".$part} = 1; |
} |
} |
$anoncounter{$symb."\0".$part} = 1; |
|
my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}}; |
my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}}; |
if ($needsrelease) { |
if ($needsrelease) { |
my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; |
my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; |
if ($curr_required eq '') { |
if ($curr_required eq '') { |
&Apache::lonnet::update_released_required($needsrelease); |
&Apache::lonnet::update_released_required($needsrelease); |
Line 803 sub store_aggregates {
|
Line 952 sub store_aggregates {
|
$cdomain,$cname); |
$cdomain,$cname); |
} |
} |
if (keys(%anoncounter) > 0) { |
if (keys(%anoncounter) > 0) { |
&Apache::lonnet::cinc('nohist_anonsurveys',\%anoncounter, |
&Apache::lonnet::cput('nohist_anonsurveys',\%anoncounter, |
$cdomain,$cname); |
$cdomain,$cname); |
} |
} |
if (keys(%randtrycounter) > 0) { |
if (keys(%randtrycounter) > 0) { |
&Apache::lonnet::cinc('nohist_randomizetry',\%randtrycounter, |
&Apache::lonnet::cput('nohist_randomizetry',\%randtrycounter, |
$cdomain,$cname); |
$cdomain,$cname); |
} |
} |
} |
} |
|
|
Line 817 sub checkout_msg {
|
Line 966 sub checkout_msg {
|
'resource'=>'The resource needs to be checked out', |
'resource'=>'The resource needs to be checked out', |
'id_expln'=>'As a resource gets checked out, a unique timestamped ID is given to it, and a permanent record is left in the system.', |
'id_expln'=>'As a resource gets checked out, a unique timestamped ID is given to it, and a permanent record is left in the system.', |
'warning'=>'Checking out resources is subject to course policies, and may exclude future credit even if done erroneously.', |
'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 Bubblesheet Exam for Viewing', |
'checkout?'=>'Check out Exam?'); |
'checkout?'=>'Check out Bubblesheet Exam?'); |
my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); |
my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); |
return (<<ENDCHECKOUT); |
return (<<ENDCHECKOUT); |
<h2>$lt{'resource'}</h2> |
<h2>$lt{'resource'}</h2> |
Line 840 sub firstaccess_msg {
|
Line 989 sub firstaccess_msg {
|
my $foldertitle=&Apache::lonnet::gettitle($map); |
my $foldertitle=&Apache::lonnet::gettitle($map); |
|
|
&Apache::lonxml::debug("map is $map title is $foldertitle"); |
&Apache::lonxml::debug("map is $map title is $foldertitle"); |
$result .= "<h2>".&mt('The resources in "[_1]" are open for a limited time.' |
$result .= "<h2>".&mt('The resources in "[_1]" are open for a limited time.',$foldertitle)."</h2>" |
.' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' |
.'<p>'.&mt('Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' |
,$foldertitle,$time)."</h2>"; |
,$foldertitle,$time)."</p>"; |
} elsif ($interval[1] eq 'course') { |
} elsif ($interval[1] eq 'course') { |
my $course = $env{'course.'.$env{'request.course.id'}.'.description'}; |
my $course = $env{'course.'.$env{'request.course.id'}.'.description'}; |
$result .= "<h2>".&mt('The resources in "[_1]" are open for a limited time.' |
$result .= "<h2>".&mt('The resources in "[_1]" are open for a limited time.',$course)."</h2>" |
.' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' |
.'<p>'.&mt('Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' |
,$course,$time)."</h2>"; |
,$course,$time)."</p>"; |
} else { |
} else { |
my $title=&Apache::lonnet::gettitle($symb); |
my $title=&Apache::lonnet::gettitle($symb); |
$result .= "<h2>".&mt('This resource "[_1]" is open for a limited time.' |
$result .= "<h2>".&mt('This resource "[_1]" is open for a limited time.',$title)."</h2>" |
.' Once you click the "Show Resource" button below you have [_2] to complete this resource "[_1]".' |
.'<p>'.&mt('Once you click the "Show Resource" button below you have [_2] to complete this resource "[_1]".' |
,$title,$time)."</h2>"; |
,$title,$time)."</p>"; |
} |
} |
my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); |
my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); |
my $buttontext = &mt('Show Resource'); |
my $buttontext = &mt('Show Resource'); |
Line 890 sub init_problem_globals {
|
Line 1039 sub init_problem_globals {
|
&Apache::lonhomework::reset_show_problem_status(); |
&Apache::lonhomework::reset_show_problem_status(); |
$Apache::lonhomework::ignore_response_errors=1; |
$Apache::lonhomework::ignore_response_errors=1; |
} |
} |
|
@Apache::functionplotresponse::callscripts=(); |
@Apache::inputtags::responselist = (); |
@Apache::inputtags::responselist = (); |
@Apache::inputtags::importlist = (); |
@Apache::inputtags::importlist = (); |
@Apache::inputtags::previous=(); |
@Apache::inputtags::previous=(); |
Line 909 sub reset_problem_globals {
|
Line 1059 sub reset_problem_globals {
|
undef(%Apache::lonhomework::history); |
undef(%Apache::lonhomework::history); |
undef(%Apache::lonhomework::results); |
undef(%Apache::lonhomework::results); |
undef($Apache::inputtags::part); |
undef($Apache::inputtags::part); |
|
if ($type eq 'Task') { |
|
undef($Apache::inputtags::slot_name); |
|
} |
#don't undef this, lonhomework.pm takes care of this, we use this to |
#don't undef this, lonhomework.pm takes care of this, we use this to |
#detect if we try to do 2 problems in one file |
#detect if we try to do 2 problems in one file |
# undef($Apache::lonhomework::parsing_a_problem); |
# undef($Apache::lonhomework::parsing_a_problem); |
Line 917 sub reset_problem_globals {
|
Line 1070 sub reset_problem_globals {
|
undef($Apache::lonhomework::type); |
undef($Apache::lonhomework::type); |
undef($Apache::lonhomework::scantronmode); |
undef($Apache::lonhomework::scantronmode); |
undef($Apache::lonhomework::ignore_response_errors); |
undef($Apache::lonhomework::ignore_response_errors); |
|
undef(@Apache::functionplotresponse::callscripts); |
&Apache::lonhomework::reset_show_problem_status(); |
&Apache::lonhomework::reset_show_problem_status(); |
} |
} |
|
|
Line 1005 sub start_problem {
|
Line 1159 sub start_problem {
|
&Apache::run::run($expression,$safeeval); |
&Apache::run::run($expression,$safeeval); |
my $status; |
my $status; |
my $accessmsg; |
my $accessmsg; |
|
my $resource_due; |
|
|
my $name= &get_resource_name($parstack,$safeeval); |
my $name= &get_resource_name($parstack,$safeeval); |
my ($result,$form_tag_start); |
my ($result,$form_tag_start,$slot_name,$slot); |
|
|
|
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
|
$target eq 'tex') { |
|
if ($env{'form.markaccess'}) { |
|
my @interval=&Apache::lonnet::EXT("resource.0.interval"); |
|
&Apache::lonnet::set_first_access($interval[1]); |
|
} |
|
|
|
($status,$accessmsg,$slot_name,$slot) = |
|
&Apache::lonhomework::check_slot_access('0','problem'); |
|
push (@Apache::inputtags::status,$status); |
|
} |
|
|
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex' |
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex' |
|| $target eq 'edit') { |
|| $target eq 'edit') { |
($result,$form_tag_start) = |
($result,$form_tag_start) = |
Line 1020 sub start_problem {
|
Line 1188 sub start_problem {
|
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval,$target); } |
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval,$target); } |
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 'tex') { |
#handle exam checkout |
|
if ($Apache::lonhomework::type eq 'exam') { |
|
my $token= |
|
$Apache::lonhomework::history{"resource.0.outtoken"}; |
|
if (($env{'form.doescheckout'}) && (!$token)) { |
|
$token=&Apache::lonxml::maketoken(); |
|
$Apache::lonhomework::history{"resource.0.outtoken"}= |
|
$token; |
|
} |
|
$result.=&Apache::lonxml::printtokenheader($target,$token); |
|
} |
|
if ($env{'form.markaccess'}) { |
|
my @interval=&Apache::lonnet::EXT("resource.0.interval"); |
|
&Apache::lonnet::set_first_access($interval[1]); |
|
} |
|
|
|
($status,$accessmsg,my $slot_name,my $slot) = |
|
&Apache::lonhomework::check_slot_access('0','problem'); |
|
push (@Apache::inputtags::status,$status); |
|
|
|
#handle rand seed in construction space |
#handle rand seed in construction space |
my $rndseed=&setup_rndseed($safeeval,$target); |
my $rndseed=&setup_rndseed($safeeval,$target); |
Line 1088 sub start_problem {
|
Line 1237 sub start_problem {
|
( $status eq 'BANNED') || |
( $status eq 'BANNED') || |
( $status eq 'UNAVAILABLE') || |
( $status eq 'UNAVAILABLE') || |
( $status eq 'NOT_IN_A_SLOT') || |
( $status eq 'NOT_IN_A_SLOT') || |
|
( $status eq 'NOTRESERVABLE') || |
|
( $status eq 'RESERVABLE') || |
|
( $status eq 'RESERVABLE_LATER') || |
( $status eq 'INVALID_ACCESS')) { |
( $status eq 'INVALID_ACCESS')) { |
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" ) { |
my $msg; |
my $msg; |
if ($status eq 'UNAVAILABLE') { |
if ($status eq 'UNAVAILABLE') { |
$msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>'; |
$msg.='<p class="LC_error">'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</p>'; |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
$msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>'; |
$msg.='<p class="LC_warning">'.&mt('You are not currently signed up to work at this time and/or place.').'</p>'; |
|
} elsif (($status eq 'RESERVABLE') || ($status eq 'RESERVABLE_LATER') || |
|
($status eq 'NOTRESERVABLE')) { |
|
$msg.='<p class="LC_warning">'.&mt('Access requires reservation to work at specific time/place.').'</p>'; |
} elsif ($status ne 'NOT_YET_VIEWED') { |
} elsif ($status ne 'NOT_YET_VIEWED') { |
$msg.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
$msg.='<p class="LC_warning">'.&mt('Not open to be viewed').'</p>'; |
} |
} |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
$msg.=&mt('The problem ').$accessmsg; |
$msg.=&mt('The problem ').$accessmsg; |
} elsif ($status eq 'UNCHECKEDOUT') { |
} elsif ($status eq 'UNCHECKEDOUT') { |
Line 1108 sub start_problem {
|
Line 1263 sub start_problem {
|
$msg.=&firstaccess_msg($accessmsg,$symb); |
$msg.=&firstaccess_msg($accessmsg,$symb); |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
} elsif ($status eq 'NOT_IN_A_SLOT') { |
$msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work"); |
$msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work"); |
|
} elsif ($status eq 'RESERVABLE') { |
|
$msg.=&mt('Available to make a reservation.').' '.&mt('Reservation window closes [_1].', |
|
&Apache::lonnavmaps::timeToHumanString($accessmsg,'end')). |
|
'<br />'. |
|
&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work"); |
|
} elsif ($status eq 'RESERVABLE_LATER') { |
|
$msg.=&mt('Window to make a reservation will open [_1].', |
|
&Apache::lonnavmaps::timeToHumanString($accessmsg,'start')); |
|
} elsif ($status eq 'NOTRESERVABLE') { |
|
$msg.=&mt('Not available to make a reservation.'); |
} |
} |
$result.=$msg.'<br />'; |
$result.=$msg.'<br />'; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
Line 1132 sub start_problem {
|
Line 1297 sub start_problem {
|
'problem'); |
'problem'); |
} |
} |
} elsif ($target eq 'web') { |
} elsif ($target eq 'web') { |
if ($status eq 'CAN_ANSWER' |
if ($status eq 'CAN_ANSWER') { |
&& $slot_name ne '' |
$resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'}); |
&& $Apache::lonhomework::history{'resource.0.checkedin'} eq '') { |
if ($slot_name ne '') { |
# unproctored slot access, self checkin |
my $checked_in = |
&Apache::bridgetask::check_in('problem',undef,undef, |
$Apache::lonhomework::history{'resource.0.checkedin'}; |
$slot_name); |
if ($checked_in eq '') { |
} |
# unproctored slot access, self checkin |
|
&Apache::bridgetask::check_in('problem',undef,undef, |
|
$slot_name); |
|
$checked_in = |
|
$Apache::lonhomework::results{"resource.0.checkedin"}; |
|
} |
|
if ((ref($slot) eq 'HASH') && ($checked_in ne '')) { |
|
if ($slot->{'starttime'} < time()) { |
|
if (!$resource_due) { |
|
$resource_due = $slot->{'endtime'}; |
|
} elsif ($slot->{'endtime'} < $resource_due) { |
|
$resource_due = $slot->{'endtime'}; |
|
} |
|
} |
|
} |
|
} |
|
if ($resource_due) { |
|
my $time_left = $resource_due - time(); |
|
if ($resource_due && ($time_left > 0) && ($target eq 'web')) { |
|
$result .= &Apache::lonhtmlcommon::set_due_date($resource_due); |
|
} |
|
} |
|
} |
$result.="\n $form_tag_start \t". |
$result.="\n $form_tag_start \t". |
'<input type="hidden" name="submitted" value="yes" />'; |
'<input type="hidden" name="submitted" value="yes" />'; |
# create a page header and exit |
# create a page header and exit |
Line 1156 sub start_problem {
|
Line 1343 sub start_problem {
|
$result .= '<input type="hidden" name="grade_'.$field. |
$result .= '<input type="hidden" name="grade_'.$field. |
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
} |
} |
foreach my $field ('questiontype','rndseed') { |
foreach my $field ('trial','questiontype') { |
if ($env{"form.grade_$field"} ne '') { |
if ($env{"form.grade_$field"} ne '') { |
$result .= '<input type="hidden" name="grade_'.$field. |
$result .= '<input type="hidden" name="grade_'.$field. |
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
'" value="'.$env{"form.grade_$field"}.'" />'."\n"; |
} |
} |
} |
} |
|
|
} |
} |
|
if ($env{'form.grade_imsexport'}) { |
|
$result = ''; |
|
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result .= 'INSERTTEXFRONTMATTERHERE'; |
$result .= 'INSERTTEXFRONTMATTERHERE'; |
|
$result .= &select_metadata_hyphenation(); |
|
|
|
|
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
Line 1222 sub end_problem {
|
Line 1413 sub end_problem {
|
} |
} |
my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header'); |
my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header'); |
my $begin_doc=' \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent '; |
my $begin_doc=' \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent '; |
|
&clear_required_languages(); |
my $toc_line='\vskip 1 mm\noindent '.$startminipage. |
my $toc_line='\vskip 1 mm\noindent '.$startminipage. |
'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}'; |
'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}'; |
|
|
Line 1268 sub end_problem {
|
Line 1460 sub end_problem {
|
} else { |
} else { |
$frontmatter.= $begin_doc.$toc_line; |
$frontmatter.= $begin_doc.$toc_line; |
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { |
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { |
$frontmatter .= '\fbox{\textit{'.$weight.' pt}}'; |
$frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}'; |
} |
} |
} |
} |
} else { |
} else { |
Line 1278 sub end_problem {
|
Line 1470 sub end_problem {
|
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)) { |
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { |
$frontmatter .= '\fbox{\textit{'.$weight.' pt}}'; |
$frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}'; |
} |
} |
} else { |
} else { |
$frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage; |
$frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage; |
Line 1302 sub end_problem {
|
Line 1494 sub end_problem {
|
} |
} |
} elsif ( ($target eq 'web' || $target eq 'tex') && |
} elsif ( ($target eq 'web' || $target eq 'tex') && |
$Apache::inputtags::part eq '0' && |
$Apache::inputtags::part eq '0' && |
$status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') { |
$status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED' |
|
&& !$env{'form.grade_imsexport'}) { |
# if part is zero, no <part>s existed, so we need show the current |
# if part is zero, no <part>s existed, so we need show the current |
# grading status |
# grading status |
my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part,$target); |
my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part,$target); |
Line 1312 sub end_problem {
|
Line 1505 sub end_problem {
|
(($target eq 'web') && ($env{'request.state'} ne 'construct')) || |
(($target eq 'web') && ($env{'request.state'} ne 'construct')) || |
($target eq 'answer') || ($target eq 'tex') |
($target eq 'answer') || ($target eq 'tex') |
) { |
) { |
if ($target ne 'tex' && |
if (($target ne 'tex') && |
$env{'form.answer_output_mode'} ne 'tex') { |
($env{'form.answer_output_mode'} ne 'tex') && |
|
(!$env{'form.grade_imsexport'})) { |
$result.="</form>"; |
$result.="</form>"; |
} |
} |
if ($target eq 'web') { |
if ($target eq 'web') { |
$result.= &Apache::loncommon::end_page({'discussion' => 1}); |
# |
|
# Closing </body></html> not added by end_page(). |
|
# Added separately at end of this routine, after added |
|
# <script></script> so document will be valid xhtml. |
|
# |
|
$result.= &Apache::loncommon::end_page({'discussion' => 1, |
|
'notbody' => 1}); |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
my $endminipage = ''; |
my $endminipage = ''; |
if (not $env{'form.problem_split'}=~/yes/) { |
if (not $env{'form.problem_split'}=~/yes/) { |
Line 1335 sub end_problem {
|
Line 1535 sub end_problem {
|
} |
} |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$result.=&Apache::functionplotresponse::init_script(); |
|
} |
if ($target eq 'grade') { |
if ($target eq 'grade') { |
&Apache::lonhomework::showhash(%Apache::lonhomework::results); |
&Apache::lonhomework::showhash(%Apache::lonhomework::results); |
&finalize_storage(); |
&finalize_storage(); |
Line 1365 sub end_problem {
|
Line 1568 sub end_problem {
|
|
|
&reset_problem_globals('problem'); |
&reset_problem_globals('problem'); |
|
|
|
# |
|
# This shouild be just above the return so that the |
|
# time put in the javascript is as late as possible in the |
|
# computation: |
|
# |
|
if ($target eq 'web') { |
|
$result .= &Apache::lonhtmlcommon::set_compute_end_time(); |
|
# |
|
# Closing tags delayed so any <script></script> tags |
|
# not in head can appear inside body, for valid xhtml. |
|
# |
|
$result .= "</body>\n</html>"; |
|
} |
return $result; |
return $result; |
} |
} |
|
|
Line 1491 sub end_block {
|
Line 1707 sub end_block {
|
} |
} |
return $result; |
return $result; |
} |
} |
|
# |
|
# <languageblock [include='lang1,lang2...'] [exclude='lang1,lang2...']> |
|
# ... |
|
# </languageblock> |
|
# |
|
# This declares the intent to provide content that can be rendered in the |
|
# set of languages in the include specificatino but not in the exclude |
|
# specification. If a currently preferred language is in the include list |
|
# the content in the <languageblock>...</languageblock> is rendered |
|
# If the currently preferred language is in the exclude list, |
|
# the content in the <languageblock>..></languageblock is not rendered. |
|
# |
|
# Pathalogical case handling: |
|
# - Include specified, without the preferred language but exclude specified |
|
# also without the preferred langauge results in rendering the block. |
|
# - Exclude specified without include and excluden not containing a |
|
# preferred language renders the block. |
|
# - Include and exclude both specifying the preferred language does not |
|
# render the block. |
|
# - If neither include/exclude is specified, the block gets rendered. |
|
# |
|
# This tag has no effect when target is in {edit, modified} |
|
# |
sub start_languageblock { |
sub start_languageblock { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
my $result; |
my $result = ''; |
|
|
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 $include = $token->[2]->{'include'}; |
my $include = $token->[2]->{'include'}; |
my $exclude = $token->[2]->{'exclude'}; |
my $exclude = $token->[2]->{'exclude'}; |
my @preferred_languages=&Apache::lonlocal::preferred_languages(); |
my @preferred_languages=&Apache::lonlocal::preferred_languages(); |
# This should not even happen, since we should at least have the server language |
|
if (!$preferred_languages[0]) { $preferred_languages[0]='en'; } |
# This should not even happen, since we should at least have the server language |
# Now loop over all languages in order of preference |
|
|
if (!$preferred_languages[0]) { |
|
$preferred_languages[0]='en'; |
|
} |
|
|
|
# Now loop over all languages in order of preference |
|
|
|
my $render; |
foreach my $preferred_language (@preferred_languages) { |
foreach my $preferred_language (@preferred_languages) { |
# If the languageblock has no arguments, show the contents |
|
$result=1; |
# If neither include/nor exlude is present the block is going |
|
# to get rendered. |
|
|
my $found=0; |
my $found=0; |
# Do we have an include argument? |
$render=1; |
|
|
|
# If include is specified, don't render the block |
|
# unless the preferred language is included in the set. |
|
|
if ($include) { |
if ($include) { |
# If include is specified, by default, don't render the block |
$render=0; |
$result=0; |
|
foreach my $included_language (split(/\,/,$include)) { |
foreach my $included_language (split(/\,/,$include)) { |
# ... but if my preferred language is included, render it |
|
if ($included_language eq $preferred_language) { |
if ($included_language eq $preferred_language) { |
$result=1; |
$render=1; |
$found=1; |
$found=1; |
|
last; # Only need to find the first. |
} |
} |
} |
} |
} |
} |
# Do we have an exclude argument? |
# Do we have an exclude argument? |
|
# If so, and one of the languages matches a preferred language |
|
# inhibit rendering the block. Note that in the pathalogical case the |
|
# author has specified a preferred language in both the include and exclude |
|
# attribte exclude is preferred. |
|
|
if ($exclude) { |
if ($exclude) { |
$result=1; |
$render=1; |
foreach my $excluded_language (split(/\,/,$exclude)) { |
foreach my $excluded_language (split(/\,/,$exclude)) { |
if ($excluded_language eq $preferred_language) { |
if ($excluded_language eq $preferred_language) { |
$result=0; |
$render=0; |
$found=1; |
$found=1; |
|
last; # Only need to find the first. |
} |
} |
} |
} |
} |
} |
if ($found) { last; } |
if ($found) { |
|
last; # Done on any match of include or exclude. |
|
} |
} |
} |
if ( ! $result ) { |
# If $render not true skip the entire block until </languageblock> |
|
# |
|
|
|
if ( ! $render ) { |
my $skip=&Apache::lonxml::get_all_text("/languageblock",$parser, |
my $skip=&Apache::lonxml::get_all_text("/languageblock",$parser, |
$style); |
$style); |
&Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]"); |
&Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]"); |
} |
} |
$result=''; |
# If $render is true, we've not skipped the contents of the <languageglock> |
|
# and the normal loncapa processing flow will render it as a matter of course. |
|
|
} 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(&mt('Include Language:'),'include', |
$result .=&Apache::edit::text_arg(&mt('Include Language:'),'include', |
Line 1563 sub end_languageblock {
|
Line 1826 sub end_languageblock {
|
} |
} |
return $result; |
return $result; |
} |
} |
|
# languagblock specific tags: |
{ |
{ |
my %available_texts; |
# For chunks of a resource that has translations, this hash contains |
|
# the translations available indexed by language name. |
|
# |
|
|
|
my %available_texts; |
|
|
|
# <translated> starts a block of a resource that has multiple translations. |
|
# See the <lang> tag as well. |
|
# When </translated> is encountered if there is a translation for the |
|
# currently preferred language, that is rendered inthe web/tex/webgrade |
|
# targets. Otherwise, the default text is rendered. |
|
# |
|
# Note that <lang> is only registered for the duration of the |
|
# <translated>...</translated> block |
|
# |
|
# Pathalogical case handling: |
|
# - If there is no <lang> that specifies a 'default' and there is no |
|
# translation that matches a preferred language, nothing is rendered. |
|
# - Nested <translated>...</translated> might be linguistically supported by |
|
# XML due to the stack nature of tag registration(?) however the rendered |
|
# output will be incorrect because there is only one %available_texts |
|
# has and end_translated clears it. |
|
# - Material outside of a <lang>...</lang> block within the |
|
# <translated>...<translated> block won't render either e.g.: |
|
# <translated> |
|
# The following will be in your preferred langauge: |
|
# <lang which='en'> |
|
# This section in english |
|
# </lang> |
|
# <lang which='sgeiso'> |
|
# Hier es ist auf Deutsch. |
|
# </lang> |
|
# <lang which='sfriso'> |
|
# En Francais |
|
# </lang> |
|
# </translated> |
|
# |
|
# The introductory text prior to the first <lang> tag is not rendered. |
|
# |
sub start_translated { |
sub start_translated { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
&Apache::lonxml::register('Apache::structuretags',('lang')); |
&Apache::lonxml::register('Apache::structuretags',('lang')); |
Line 1584 sub end_languageblock {
|
Line 1885 sub end_languageblock {
|
my @possibilities = keys(%available_texts); |
my @possibilities = keys(%available_texts); |
my $which = |
my $which = |
&Apache::loncommon::languages(\@possibilities) || 'default'; |
&Apache::loncommon::languages(\@possibilities) || 'default'; |
$result = $available_texts{$which}; |
if ($target eq 'tex') { |
|
$result = &select_hyphenation($which); |
|
} |
|
$result .= $available_texts{$which}; |
|
if ($target eq 'tex') { |
|
$result .= &select_metadata_hyphenation(); # Restore original language. |
|
} |
} |
} |
undef(%available_texts); |
undef(%available_texts); |
&Apache::lonxml::deregister('Apache::structuretags',('lang')); |
&Apache::lonxml::deregister('Apache::structuretags',('lang')); |
return $result; |
return $result; |
} |
} |
|
|
|
# <lang [which='language-name'] [other='lang1,lang2...']> |
|
# Specifies that the block contained within it is a translation |
|
# for a specific language specified by the 'which' attribute. The |
|
# 'other' attribute can be used by itself or in conjunction with |
|
# which to specify this tag _may_ be used as a translation for some |
|
# list of languages. e.g.: <lang which='senisoUS' other='senisoCA,senisoAU,seniso'> |
|
# specifying that the block provides a translation for US (primary) |
|
# Canadian, Australian and UK Englush. |
|
# |
|
# Comment: this seems a bit silly why not just support a list of languages |
|
# e.g. <lang which='l1,l2...'> and ditch the other attribute? |
|
# |
|
# Effect: |
|
# The material within the <lang>..</lang> block is stored in the |
|
# specified set of $available_texts hash entries, the appropriate one |
|
# is selected at </translated> time. |
|
# |
|
# Pathalogical case handling: |
|
# If a language occurs multiple times within a <translated> block, |
|
# only the last one is rendered e.g.: |
|
# |
|
# <translated> |
|
# <lang which='senisoUS', other='senisoCA,senisoAU,seniso'> |
|
# Red green color blindness is quite common affecting about 7.8% of |
|
# the male population, but onloy about .65% of the female population. |
|
# </lang> |
|
# Red green colour blindness is quite common affecting about 7.8% of |
|
# the male population, but onloy about .65% of the female population. |
|
# <lang which='seniso', other='senisoCA,senisoAU'> |
|
# </translated> |
|
# |
|
# renders the correct spelling of color (colour) for people who have specified |
|
# a preferred language that is one of the British Commonwealth languages |
|
# even though those are also listed as valid selections for the US english |
|
# <lang> block. |
|
# |
sub start_lang { |
sub start_lang { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
Line 1622 sub end_languageblock {
|
Line 1964 sub end_languageblock {
|
} |
} |
return ''; |
return ''; |
} |
} |
} |
} # end langauge block specific tags. |
|
|
|
|
sub start_instructorcomment { |
sub start_instructorcomment { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
Line 1836 sub ordered_show_check {
|
Line 2179 sub ordered_show_check {
|
return $in_order_show; |
return $in_order_show; |
} |
} |
|
|
|
|
sub start_startpartmarker { |
sub start_startpartmarker { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $result=''; |
my $result=''; |
Line 1844 sub start_startpartmarker {
|
Line 2188 sub start_startpartmarker {
|
$result.=&mt('Marker for the start of a part. Place end marker below to wrap in-between tags into a new part.').'</td></tr>'; |
$result.=&mt('Marker for the start of a part. Place end marker below to wrap in-between tags into a new part.').'</td></tr>'; |
$result.=&Apache::edit::end_table(); |
$result.=&Apache::edit::end_table(); |
|
|
} |
} |
return $result; |
return $result; |
} |
} |
|
|
Line 1874 sub end_endpartmarker {
|
Line 2218 sub end_endpartmarker {
|
return @result; |
return @result; |
} |
} |
|
|
|
|
|
|
|
|
|
|
sub start_part { |
sub start_part { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if (!$Apache::lonxml::metamode) { |
if (!$Apache::lonxml::metamode) { |
Line 1959 sub start_part {
|
Line 2307 sub start_part {
|
$allow_print_points=0; |
$allow_print_points=0; |
} |
} |
if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { |
if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { |
$result .= '\vskip 10mm\fbox{\textit{'.$weight.' pt}}'; |
$result .= '\vskip 10mm\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}'; |
|
|
} |
} |
} elsif ($target eq 'web') { |
} elsif ($target eq 'web') { |
if ($status eq 'CAN_ANSWER') { |
if ($status eq 'CAN_ANSWER') { |
my $problemstatus = &get_problem_status($Apache::inputtags::part); |
my $problemstatus = &get_problem_status($Apache::inputtags::part); |
my $probrandomize = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].type"); |
my $probrandomize = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].type"); |
my $probrandtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].randomizeontries"); |
my $probrandtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].randomizeontries"); |
my $num = scalar(@Apache::inputtags::partlist)-1; |
my $num = scalar(@Apache::inputtags::partlist)-1; |
Line 1982 sub start_part {
|
Line 2330 sub start_part {
|
$result .= &randomizetry_part_header($problemstatus,$reqtries,$num); |
$result .= &randomizetry_part_header($problemstatus,$reqtries,$num); |
} |
} |
} |
} |
$result.='<a name="'.&escape($Apache::inputtags::part).'"></a>'; |
$result.='<a name="'.&escape($Apache::inputtags::part).'" ></a>'; |
} |
} |
} |
} |
} |
} |
Line 2028 sub end_part {
|
Line 2376 sub end_part {
|
!$hidden && $in_order_show) { |
!$hidden && $in_order_show) { |
my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part, |
my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part, |
$target); |
$target); |
if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') { |
if (($Apache::lonhomework::type eq 'exam' && $target eq 'tex') || |
|
($env{'form.grade_imsexport'})) { |
$gradestatus=''; |
$gradestatus=''; |
} |
} |
$result.=$gradestatus; |
$result.=$gradestatus; |
Line 2196 sub end_startouttext {
|
Line 2545 sub end_startouttext {
|
.'</span></td>' |
.'</span></td>' |
.'<td align="left"><span id="math_'.$areaid.'" />' |
.'<td align="left"><span id="math_'.$areaid.'" />' |
.&Apache::lonhtmlcommon::dragmath_button($areaid,1) |
.&Apache::lonhtmlcommon::dragmath_button($areaid,1) |
.'</td>' |
.'<span></td>' |
.'<td>' |
.'<td>' |
.&Apache::edit::insertlist($target,$token) |
.&Apache::edit::insertlist($target,$token) |
.'</td>' |
.'</td>' |
Line 2269 sub start_simpleeditbutton {
|
Line 2618 sub start_simpleeditbutton {
|
# .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.') |
# .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.') |
# .&Apache::loncommon::help_open_topic('Caching') |
# .&Apache::loncommon::help_open_topic('Caching') |
# .'</p>'; |
# .'</p>'; |
$result.=&Apache::lonhtmlcommon::start_funclist() |
$result.=&Apache::loncommon::head_subbox( |
|
&Apache::lonhtmlcommon::start_funclist() |
.&Apache::lonhtmlcommon::add_item_funclist( |
.&Apache::lonhtmlcommon::add_item_funclist( |
'<a href="'.$url.'/smpedit?symb='.&escape($symb).'">' |
'<a href="'.$url.'/smpedit?symb='.&escape($symb).'">' |
.&mt('Edit').'</a>') |
.&mt('Edit').'</a>') |
.&Apache::lonhtmlcommon::end_funclist(); |
.&Apache::lonhtmlcommon::end_funclist()); |
|
|
} |
} |
return $result; |
return $result; |