version 1.486, 2011/01/18 21:45:32
|
version 1.497.2.1, 2011/12/12 11:19:53
|
Line 129 sub homework_js {
|
Line 129 sub homework_js {
|
<<'JS'; |
<<'JS'; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
function setSubmittedPart (part) { |
function setSubmittedPart (part,prefix) { |
this.document.lonhomework.submitted.value="part_"+part; |
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 164 function setmode(form,probmode) {
|
Line 172 function setmode(form,probmode) {
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
sub file_delchk_js { |
|
my $delfilewarn = &mt('You have indicated you wish to remove some files previously included in your submission.').'\\n'. |
|
&mt('Continue submission with these files removed?'); |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function file_deletion_check(formname) { |
|
var elemnum = formname.elements.length; |
|
if (elemnum == 0) { |
|
return true; |
|
} |
|
var str = new RegExp("^HWFILE.+_delete\$"); |
|
var delboxes = new Array(); |
|
for (var 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) { |
|
delboxes.push(id); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (delboxes.length > 0) { |
|
if (confirm("$delfilewarn")) { |
|
return true; |
|
} else { |
|
for (var j=0; j<delboxes.length; j++) { |
|
formname.elements[delboxes[j]].checked = false; |
|
} |
|
return false; |
|
} |
|
} else { |
|
return true; |
|
} |
|
} |
|
// ]]> |
|
</script> |
|
ENDSCRIPT |
|
} |
|
|
|
sub page_start { |
sub page_start { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, |
$extra_head)=@_; |
$extra_head)=@_; |
Line 232 sub page_start {
|
Line 197 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 264 sub page_start {
|
Line 283 sub page_start {
|
&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 316 sub page_start {
|
Line 335 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 327 sub page_start {
|
Line 345 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"; |
|
|
Line 411 sub setup_rndseed {
|
Line 432 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 464 sub remember_problem_state {
|
Line 491 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 621 $show_all
|
Line 669 $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 1156 sub start_problem {
|
Line 1204 sub start_problem {
|
} |
} |
} |
} |
} |
} |
|
if ($env{'form.grade_imsexport'}) { |
|
$result = ''; |
|
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result .= 'INSERTTEXFRONTMATTERHERE'; |
$result .= 'INSERTTEXFRONTMATTERHERE'; |
|
|
Line 1260 sub end_problem {
|
Line 1311 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 1270 sub end_problem {
|
Line 1321 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 1294 sub end_problem {
|
Line 1345 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 1304 sub end_problem {
|
Line 1356 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') { |
Line 1486 sub end_block {
|
Line 1539 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 |
|
|
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 $render=1; |
my $found=0; |
my $found=0; |
# Do we have an include argument? |
|
|
# 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 1959 sub start_part {
|
Line 2058 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') { |
Line 2028 sub end_part {
|
Line 2127 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; |