';
return $result;
}
@@ -455,12 +574,19 @@ sub initialize_storage {
if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); }
}
-# -------------------------------------------------------------finalize_storage
-# Stores away the result has to a student's environment
-# checks form.grade_ for specific values, other wises stores
-# to the running users environment
-# Will increment totals for attempts, students, and corrects
-# if running user has student role.
+=pod
+
+=item finalize_storage()
+
+ Stores away the result has to a student's environment
+ checks form.grade_ for specific values, other wises stores
+ to the running users environment
+ Will increment totals for attempts, students, and corrects
+ if running user has student role.
+
+=cut
+
+
sub finalize_storage {
my ($given_symb) = @_;
my $result;
@@ -491,10 +617,16 @@ sub finalize_storage {
return $result;
}
-# -------------------------------------------------------------store_aggregates
-# Sends hash of values to be incremented in nohist_resourcetracker.db
-# for the course. Increments total number of attempts, unique students
-# and corrects for each part for an instance of a problem, as appropriate.
+=pod
+
+item store_aggregates()
+
+ Sends hash of values to be incremented in nohist_resourcetracker.db
+ for the course. Increments total number of attempts, unique students
+ and corrects for each part for an instance of a problem, as appropriate.
+
+=cut
+
sub store_aggregates {
my ($symb,$courseid) = @_;
my %aggregate;
@@ -545,7 +677,7 @@ sub checkout_msg {
$lt{'warning'}
-
@@ -554,17 +686,37 @@ ENDCHECKOUT
sub firstaccess_msg {
my ($time,$symb)=@_;
- my ($map)=&Apache::lonnet::decode_symb($symb);
- my $foldertitle=&Apache::lonnet::gettitle($map);
- &Apache::lonxml::debug("map is $map title is $foldertitle");
+ my $result;
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ if ($interval[1] eq 'map') {
+ my ($map)=&Apache::lonnet::decode_symb($symb);
+ my $foldertitle=&Apache::lonnet::gettitle($map);
+
+ &Apache::lonxml::debug("map is $map title is $foldertitle");
+ $result .= "
".&mt('The resources in "[_1]" are open for a limited time.'
+ .' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".'
+ ,$foldertitle,$time)."
".&mt('The resources in "[_1]" are open for a limited time.'
+ .' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".'
+ ,$course,$time)."
".&mt('This resource "[_1]" is open for a limited time.'
+ .' Once you click the "Show Resource" button below you have [_2] to complete this resource "[_1]".'
+ ,$title,$time)."
";
+ }
my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});
- return (<The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".
-
ENDCHECKOUT
+ return $result;
}
sub init_problem_globals {
@@ -576,19 +728,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 = ();
@@ -617,8 +769,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 {
@@ -669,9 +821,10 @@ sub start_problem {
}
if ($target ne 'analyze') {
- $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
+ my $type = &Apache::lonnet::EXT('resource.0.type');
+ $Apache::lonhomework::type=$type;
if (($env{'request.state'} eq 'construct') &&
- defined($env{'form.problemtype'})) {
+ $env{'form.problemtype'} =~ /\S/) {
$Apache::lonhomework::type=$env{'form.problemtype'};
}
&Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:");
@@ -732,7 +885,8 @@ sub start_problem {
$result.=&Apache::lonxml::printtokenheader($target,$token);
}
if ($env{'form.markaccess'}) {
- &Apache::lonnet::set_first_access('map');
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ &Apache::lonnet::set_first_access($interval[1]);
}
#handle rand seed in construction space
my $rndseed=&setup_rndseed($safeeval);
@@ -750,13 +904,16 @@ sub start_problem {
}
if ($env{'request.role.adv'}) {
$form_tag_start.=
- ' ';
}
+ if ($Apache::lonhomework::type eq 'practice') {
+ $form_tag_start.=&practice_problem_header();
+ }
$form_tag_start.='';
}
@@ -782,6 +939,8 @@ sub start_problem {
my $msg;
if ($status eq 'UNAVAILABLE') {
$msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
'.&mt('You are not currently signed up to work at this time and/or place.').'
';
} elsif ($status ne 'NOT_YET_VIEWED') {
$msg.='
'.&mt('Not open to be viewed').'
';
}
@@ -792,13 +951,13 @@ sub start_problem {
} elsif ($status eq 'NOT_YET_VIEWED') {
$msg.=&firstaccess_msg($accessmsg,$symb);
} 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");
}
$result.=$msg.' ';
} elsif ($target eq 'tex') {
my $startminipage = ($env{'form.problem_split'}=~/yes/i)? ''
: '\begin{minipage}{\textwidth}';
- $result.='\begin{document}\noindent \vskip 1 mm '.
+ $result.='\noindent \vskip 1 mm '.
$startminipage.'\vskip 0 mm';
if ($status eq 'UNAVAILABLE') {
$result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
@@ -829,6 +988,11 @@ sub start_problem {
# create a page header and exit
if ($env{'request.state'} eq "construct") {
$result.= &problem_web_to_edit_header($env{'form.rndseed'});
+ if ($Apache::lonhomework::type eq 'practice') {
+ $result.= ''.
+ &practice_problem_header().'';
+ }
}
# if we are viewing someone else preserve that info
if (defined $env{'form.grade_symb'}) {
@@ -894,7 +1058,7 @@ sub end_problem {
$allow_print_points=0;
}
my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
- my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$env{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent ';
+ my $begin_doc=' \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$env{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent ';
my $toc_line='\vskip 1 mm\noindent '.$startminipage.
'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
@@ -1064,6 +1228,11 @@ sub start_library {
$result.=" \n $form_tag_start".
'';
$result.=&problem_web_to_edit_header($rndseed);
+ if ($Apache::lonhomework::type eq 'practice') {
+ $result.= ''.
+ &practice_problem_header().'';
+ }
}
return $result;
}
@@ -1164,7 +1333,7 @@ sub start_languageblock {
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
my $include = $token->[2]->{'include'};
my $exclude = $token->[2]->{'exclude'};
- my @preferred_languages=&Apache::loncommon::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'; }
# Now loop over all languages in order of preference
@@ -1271,7 +1440,17 @@ sub end_languageblock {
my $result = &Apache::lonxml::endredirection();
my $which = &Apache::lonxml::get_param('which',$parstack,
$safeeval);
- $available_texts{$which} = $result;
+ if ($which=~/\w/) {
+ $available_texts{$which} = $result;
+ }
+ my $otherlangs = &Apache::lonxml::get_param('other',$parstack,
+ $safeeval);
+ foreach my $language (split(/\s*\,\s*/,$otherlangs)) {
+ if ($language=~/\w/) {
+ $available_texts{$language} = $result;
+ }
+ }
+
}
return '';
}
@@ -1368,7 +1547,7 @@ sub end_while {
$return = &Apache::run::run($code,$safeeval);
}
if ($error) {
- &Apache::lonxml::error('
'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occured while running <while> on line').' '.$line.'
');
+ &Apache::lonxml::error('
'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occurred while running <while> on line').' '.$line.'
');
}
} elsif ($target eq "edit") {
$result.= &Apache::edit::tag_end($target,$token,'');
@@ -1422,6 +1601,20 @@ sub start_randomlist {
my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
$showarg--;
if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; }
+ if (($target eq 'analyze') && ($env{'form.check_parts_withrandomlist'})) {
+ my @currlist;
+ my $part = $Apache::inputtags::part;
+ if ($part ne '') {
+ if (ref($Apache::lonhomework::analyze{'parts_withrandomlist'}) eq 'ARRAY') {
+ my @currlist = @{$Apache::lonhomework::analyze{'parts_withrandomlist'}};
+ if (!(grep(/^\Q$part\E$/,@currlist))) {
+ push(@{$Apache::lonhomework::analyze{'parts_withrandomlist'}},$part);
+ }
+ } else {
+ push(@{$Apache::lonhomework::analyze{'parts_withrandomlist'}},$part);
+ }
+ }
+ }
for(0 .. $show) {
$bodytext .= "$randomlist[ $idx_arr[$_] ]";
}
@@ -1488,7 +1681,7 @@ 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);
@@ -1728,7 +1921,8 @@ sub start_problemtype {
$result .=&Apache::edit::checked_arg('When used as type(s):','for',
[ ['exam','Exam/Quiz Problem'],
['survey','Survey'],
- ['problem','Homework Problem'] ]
+ ['problem','Homework Problem'],
+ ['practice','Practice Problem'] ]
,$token);
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
@@ -1747,6 +1941,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);
}
@@ -1754,17 +1955,23 @@ sub end_startouttext {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
my $text='';
-
if ($target eq 'edit') {
+ my $areaid = 'homework_edit_'.$Apache::lonxml::curdepth;
$text=&Apache::lonxml::get_all_text("endouttext",$parser,$style);
- $result.=&Apache::edit::start_table($token)."
' .
+ &Apache::loncommon::helpLatexCheatsheet().
&Apache::edit::end_row().
&Apache::edit::start_spanning_row()."\n".
&Apache::edit::editfield($token->[1],$text,"",80,8,1);
@@ -1786,6 +1993,14 @@ sub start_endouttext {
$result=''.
&Apache::edit::handle_insertafter('startouttext');
}
+
+ my $nesting =
+ &Apache::lonxml::set_state('outtext',
+ &Apache::lonxml::get_state('outtext')-1);
+ if ($nesting < 0 && $env{'request.state'} eq 'construct') {
+ &Apache::lonxml::error(" Extraneous <endouttext /> not allowed on line ".$token->[5]);
+ &Apache::lonxml::set_state('outtext', 0);
+ }
return $result;
}
@@ -1819,9 +2034,16 @@ sub start_simpleeditbutton {
my $url=$env{'request.noversionuri'};
$url=~s/\?.*$//;
my ($symb) = &Apache::lonnet::whichuser();
- $result='
'.
- ''.&mt('Edit').' - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
-&Apache::loncommon::help_open_topic('Caching').'
';
+# Warning make more sense and is more important on edit screen
+# $result='
'
+# .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.')
+# .&Apache::loncommon::help_open_topic('Caching')
+# .'