--- loncom/homework/structuretags.pm 2007/09/11 23:53:05 1.397 +++ loncom/homework/structuretags.pm 2007/10/30 00:17:09 1.407 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.397 2007/09/11 23:53:05 albertel Exp $ +# $Id: structuretags.pm,v 1.407 2007/10/30 00:17:09 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,6 +92,31 @@ sub end_tex { return ''; } +sub homework_js { + return &Apache::loncommon::resize_textarea_js(). + <<'JS'; + +JS +} + sub page_start { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, $extra_head)=@_; @@ -108,13 +133,7 @@ sub page_start { $parstack,$parser,$safeeval); } - $extra_head.= ' - -'; + $extra_head .= &homework_js(); my %body_args; if (defined($found{'html'})) { @@ -139,7 +158,9 @@ function setSubmittedPart (part) { } elsif (!defined($found{'body'}) && $env{'request.state'} eq 'construct') { if ($target eq 'web' || $target eq 'edit') { - # no extra args to bodytag + if ($env{'environment.remote'} ne 'off') { + $body_args{'only_body'} = 1; + } } } elsif (!defined($found{'body'})) { my %add_entries; @@ -284,11 +305,13 @@ sub problem_edit_header { -
'.
+
+ '.
&Apache::loncommon::help_open_menu('Problem Editing Help','Problem_Editor_XML_Index',5,'Authoring',undef,undef,undef,'Problem Editing Help')
- .' |
';
}
@@ -311,35 +334,44 @@ sub option {
sub problem_web_to_edit_header {
my ($rndseed)=@_;
- my $result.='';
+ my $result .= ' ';
+
+ $result.=' ';
+ $result.='';
$result .= '';
- $result .= '
-
-
- ';
+
+ if (!$Apache::lonhomework::parsing_a_task) {
+ $result .=
+ ''.
+ &mt('Problem Testing').
+ &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area').
+ ' ';
+ } else {
+ $result .=
+ ''.
+ &mt('Task Testing').
+ ' ';
+ }
+
my $show_all_foils_text =
($Apache::lonhomework::parsing_a_task) ?
&mt(' Show All Instances')
: &mt(' Show All Foils');
- if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; }
- $result.= ' />'.$show_all_foils_text.''.
- &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
- ''; - $result.=&mt('Apply style file: ').' -&').'" /> - '.&mt('Select').' - - '; + my $show_all= ''; + + + $result .= ' ';
if (!$Apache::lonhomework::parsing_a_task) {
$result.="
- ';
return $result;
}
@@ -555,19 +618,19 @@ sub init_problem_globals {
if ($type eq 'problem') {
$Apache::inputtags::part='0';
@Apache::inputtags::partlist=('0');
- $Apache::lonhomework::problemstatus=&get_problem_status('0');
+ &Apache::lonhomework::set_show_problem_status(&get_problem_status('0'));
$Apache::lonhomework::ignore_response_errors=0;
} elsif ($type eq 'library') {
$Apache::inputtags::part='';
@Apache::inputtags::partlist=();
- $Apache::lonhomework::problemstatus='';
+ &Apache::lonhomework::reset_show_problem_status();
$Apache::lonhomework::ignore_response_errors=1;
} elsif ($type eq 'Task') {
$Apache::inputtags::part='0';
@Apache::inputtags::partlist=('0');
- $Apache::lonhomework::problemstatus='';
+ &Apache::lonhomework::reset_show_problem_status();
$Apache::lonhomework::ignore_response_errors=1;
}
@Apache::inputtags::responselist = ();
@@ -596,8 +659,8 @@ sub reset_problem_globals {
undef($Apache::lonhomework::default_type);
undef($Apache::lonhomework::type);
undef($Apache::lonhomework::scantronmode);
- undef($Apache::lonhomework::problemstatus);
undef($Apache::lonhomework::ignore_response_errors);
+ &Apache::lonhomework::reset_show_problem_status();
}
sub set_problem_state {
@@ -1143,27 +1206,38 @@ sub start_languageblock {
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
my $include = $token->[2]->{'include'};
my $exclude = $token->[2]->{'exclude'};
- my $preferred_language=(&Apache::loncommon::preferred_languages)[0];
+ my @preferred_languages=&Apache::loncommon::preferred_languages();
# This should not even happen, since we should at least have the server language
- if (!$preferred_language) { $preferred_language='en'; }
+ if (!$preferred_languages[0]) { $preferred_languages[0]='en'; }
+# Now loop over all languages in order of preference
+ foreach my $preferred_language (@preferred_languages) {
# If the languageblock has no arguments, show the contents
- $result='1';
+ $result=1;
+ my $found=0;
# Do we have an include argument?
- if ($include) {
+ if ($include) {
# If include is specified, by default, don't render the block
- $result='';
- foreach my $included_language (split(/\,/,$include)) {
+ $result=0;
+ foreach my $included_language (split(/\,/,$include)) {
# ... but if my preferred language is included, render it
- if ($included_language eq $preferred_language) { $result='1'; }
- }
- }
+ if ($included_language eq $preferred_language) {
+ $result=1;
+ $found=1;
+ }
+ }
+ }
# Do we have an exclude argument?
- if ($exclude) {
- $result='1';
- foreach my $excluded_language (split(/\,/,$exclude)) {
- if ($excluded_language eq $preferred_language) { $result='0'; }
- }
- }
+ if ($exclude) {
+ $result=1;
+ foreach my $excluded_language (split(/\,/,$exclude)) {
+ if ($excluded_language eq $preferred_language) {
+ $result=0;
+ $found=1;
+ }
+ }
+ }
+ if ($found) { last; }
+ }
if ( ! $result ) {
my $skip=&Apache::lonxml::get_all_text("/languageblock",$parser,
$style);
@@ -1456,7 +1530,9 @@ sub start_part {
@Apache::inputtags::response=();
@Apache::inputtags::previous=();
@Apache::inputtags::previous_version=();
- $Apache::lonhomework::problemstatus=&get_problem_status($id);
+ &Apache::lonhomework::set_show_problem_status(&get_problem_status($id));
+ &Apache::response::reset_params();
+
my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
my $newtype=&Apache::lonnet::EXT("resource.$id.type");
if ($newtype) { $Apache::lonhomework::type=$newtype; }
@@ -1713,6 +1789,13 @@ sub start_startouttext {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my @result=(''.'');
if ($target eq 'edit' || $target eq 'modified' ) { @result=('','no'); }
+
+ my $nesting =
+ &Apache::lonxml::set_state('outtext',
+ &Apache::lonxml::get_state('outtext')+1);
+ if ($nesting > 1 && $env{'request.state'} eq 'construct') {
+ &Apache::lonxml::error("Nesting of <startouttext /> not allowed, on line ".$token->[5]);
+ }
return (@result);
}
@@ -1752,6 +1835,14 @@ sub start_endouttext {
$result='
+
+".&mt("Problem Status:")."
-
-
+
+
+".&mt("Feedback Mode:")."
-
-
-
+ "; - my $numtoanalyze=$env{'form.numtoanalyze'}; - if (!$numtoanalyze) { $numtoanalyze=20; } - $result.= ' for - '.&mt('versions of this problem'). - '.'.&Apache::loncommon::help_open_topic("Analyze_Problem", - '',undef,undef,300). - ' '; + +"; + } elsif ($Apache::lonhomework::parsing_a_task) { $result.=" -
+
+".&mt("Problem Status:")."
-
-
-
+
+
+
+ "; + +$show_all +"; + } + + $result.=' + + '.&mt('Apply style file: ').' + &').'" /> + '.&mt('Select').' + + +
+
+
+ ';
+
+ if (!$Apache::lonhomework::parsing_a_task) {
+ my $numtoanalyze=$env{'form.numtoanalyze'};
+ if (!$numtoanalyze) { $numtoanalyze=20; }
+ $result .= &mt('[_1] for [_2] versions of this problem.',
+ '',
+ '').
+ &Apache::loncommon::help_open_topic("Analyze_Problem",
+ '',undef,undef,300);
}
+
+ $result.='
+
+ + |