'.&mt('Access requires reservation to work at specific time/place.').'
';
- } elsif ($status ne 'NOT_YET_VIEWED') {
- $msg.='
'.&mt('Not open to be viewed').'
';
- }
- if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
- $msg.=&mt('The problem ').$accessmsg;
- } elsif ($status eq 'UNCHECKEDOUT') {
- $msg.=&checkout_msg();
- } 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");
- } elsif ($status eq 'RESERVABLE') {
- $msg.=&mt('Available to make a reservation.').' '.&mt('Reservation window closes [_1].',
- &Apache::lonnavmaps::timeToHumanString($accessmsg,'end')).
- ' '.
- &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.');
- } elsif ($status eq 'NEED_DIFFERENT_IP') {
- if ($ipused) {
- $msg.=&mt('You must use the same computer ([_1]) you used when you first accessed this resource using your time/place-based reservation.',"IP: $ipused");
- } else {
- $msg.=&mt('Each student must use a different computer to access this resource at this time and/or place.').' '.
- &mt('Somebody else has already used this particular computer for that purpose.');
- }
- }
- $result.=$msg.' ';
- } elsif ($target eq 'tex') {
- my $startminipage = ($env{'form.problem_split'}=~/yes/i)? ''
- : '\begin{minipage}{\textwidth}';
- $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 ';
- } else {
- $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
- }
- }
+ if (($status eq 'NOT_YET_VIEWED') && ($firstaccres)) {
+ $result .= '
'.
+ &mt('A problem occurred when trying to start the timer.').'
';
+ }
+ $result .= &access_status_msg('problem',$status,$symb,$target,$ipused,$accessmsg);
} elsif ($status eq 'NEEDS_CHECKIN') {
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
$style);
- if ($target eq 'web') {
- $result .=
- &Apache::bridgetask::proctor_validation_screen($slot);
- } elsif ($target eq 'grade') {
- my $checkinresult = &Apache::bridgetask::proctor_check_auth($slot_name,$slot,
- 'problem');
- if ($checkinresult = /^error:/) {
- $result .= 'error';
- }
- }
+ $result .= &checkin_prompt($target,$slot_name,$slot,'problem');
} elsif ($target eq 'web') {
if ($status eq 'CAN_ANSWER') {
$resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'});
if ($slot_name ne '') {
- my $checked_in =
- $Apache::lonhomework::history{'resource.0.checkedin'};
- if ($checked_in eq '') {
- # unproctored slot access, self checkin
- my $needsiptied;
- if (ref($slot)) {
- $needsiptied = $slot->{'iptied'};
- }
- my $check = &Apache::bridgetask::check_in('problem',undef,undef,
- $slot_name,$needsiptied);
- if ($check =~ /^error: /) {
- &Apache::lonnet::logthis("Error during self-checkin of problem (symb: $env{'request.symb'}) using slot: $slot_name");
- } else {
- $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'};
- }
- }
- }
+ $resource_due = &selfcheckin_resource($resource_due,$slot_name,$slot,
+ $env{'request.symb'});
}
if ($resource_due) {
my $time_left = $resource_due - time();
@@ -1723,11 +1975,20 @@ 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 ($env{'form.inhibitmenu'} eq 'yes') {
+ # error messages can be useful in any case
+ $result.= &Apache::lonxml::message_location();
+ } else {
+ $result.= &problem_web_to_edit_header($env{'form.rndseed'});
+ }
if ($Apache::lonhomework::type eq 'practice') {
- $result.= ''.
- &practice_problem_header().'';
+ $result.= ''.
+ &practice_problem_header().'';
+ } elsif ($Apache::lonhomework::type eq 'randomizetry') {
+ my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
+ my $problemstatus = &get_problem_status($Apache::inputtags::part);
+ $result.=&randomizetry_problem_header($problemstatus,$reqtries);
}
}
# if we are viewing someone else preserve that info
@@ -1749,8 +2010,6 @@ sub start_problem {
} elsif ($target eq 'tex') {
$result .= 'INSERTTEXFRONTMATTERHERE';
$result .= &select_metadata_hyphenation();
-
-
}
} elsif ($target eq 'edit') {
$result .= $form_tag_start.&problem_edit_header();
@@ -1909,7 +2168,39 @@ sub end_problem {
# Added separately at end of this routine, after added
# so document will be valid xhtml.
#
- $result.= &Apache::loncommon::end_page({'discussion' => 1,
+ my $showdisc = 1;
+ if (($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement') &&
+ (!$env{'request.role.adv'})) {
+# For Placement Tests footer with "Post Discussion" and "Send Feedback" links is suppressed.
+ $showdisc = 0;
+ my ($symb)= &Apache::lonnet::whichuser();
+ if ($symb) {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ my $hastries = &Apache::lonplacementtest::has_tries($symb,$navmap);
+# For Placement Tests test status is displayed if this is the last resource in the course
+# and there are no tries left
+ unless ($hastries) {
+ if (&Apache::lonplacementtest::is_lastres($symb,$navmap)) {
+ my ($score,$incomplete) =
+ &Apache::lonplacementtest::check_completion(undef,undef,1);
+ if (!$incomplete) {
+ $result .= &Apache::lonplacementtest::showresult(1,1);
+ } elsif ($incomplete < 100) {
+ $result.= &Apache::lonplacementtest::showincomplete($incomplete,1);
+ }
+ } else {
+# For Placement Tests score is displayed if test has just been completed
+ my ($score,$incomplete) = &Apache::lonplacementtest::check_completion(undef,undef,1);
+ if (!$incomplete) {
+ $result.= &Apache::lonplacementtest::showresult(1,1);
+ }
+ }
+ }
+ }
+ }
+ }
+ $result.= &Apache::loncommon::end_page({'discussion' => $showdisc,
'notbody' => 1});
} elsif ($target eq 'tex') {
my $endminipage = '';
@@ -1929,7 +2220,24 @@ sub end_problem {
}
}
if ($target eq 'web') {
- $result.=&Apache::functionplotresponse::init_script();
+ $result.=&Apache::functionplotresponse::init_script();
+ if ($Apache::lonhomework::default_type eq 'randomizetry') {
+ my ($symb) = &Apache::lonnet::whichuser();
+ if ((($env{'request.state'} eq 'construct') || ($symb eq '')) &&
+ ($status eq 'CAN_ANSWER')) {
+ unless (@Apache::inputtags::partlist > 1) {
+ $result.= <<"ENDJS";
+
+ENDJS
+ }
+ }
+ }
}
if ($target eq 'grade') {
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
@@ -1946,7 +2254,7 @@ sub end_problem {
@Apache::inputtags::response=();
$result=&Apache::response::mandatory_part_meta;
}
- $result.=&Apache::response::meta_part_order();
+ $result.=&Apache::response::meta_part_order('problem');
$result.=&Apache::response::meta_response_order();
} elsif ($target eq 'edit') {
&Apache::lonxml::debug("in end_problem with $target, edit");
@@ -2006,9 +2314,9 @@ sub start_library {
'';
$result.=&problem_web_to_edit_header($rndseed);
if ($Apache::lonhomework::type eq 'practice') {
- $result.= ''.
- &practice_problem_header().'';
+ $result.= ''.
+ &practice_problem_header().'';
}
}
return $result;
@@ -2023,6 +2331,9 @@ sub end_library {
&& ($#$tagstack eq 0 && $$tagstack[0] eq 'library')
&& $env{'request.state'} eq "construct") {
$result.=''.&Apache::loncommon::end_page({'discussion' => 1});
+ } elsif ($target eq 'meta') {
+ $result.=&Apache::response::meta_part_order('library');
+ $result.=&Apache::response::meta_response_order();
}
if ( $#$tagstack eq 0 && $$tagstack[0] eq 'library') {
&reset_problem_globals('library');
@@ -2505,7 +2816,12 @@ sub start_randomlist {
}
if (@randomlist) {
my @idx_arr = (0 .. $#randomlist);
- &Apache::structuretags::shuffle(\@idx_arr);
+ if ($env{'form.code_for_randomlist'}) {
+ &Apache::structuretags::shuffle(\@idx_arr,$target);
+ undef($env{'form.code_for_randomlist'});
+ } else {
+ &Apache::structuretags::shuffle(\@idx_arr);
+ }
my $bodytext = '';
my $show=$#randomlist;
my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
@@ -2544,10 +2860,10 @@ sub start_randomlist {
}
sub shuffle {
- my $a=shift;
+ my ($a,$target) = @_;
my $i;
if (ref($a) eq 'ARRAY' && @$a) {
- &Apache::response::pushrandomnumber();
+ &Apache::response::pushrandomnumber(undef,$target);
for($i=@$a;--$i;) {
my $j=int(&Math::Random::random_uniform() * ($i+1));
next if $i == $j;
@@ -2646,6 +2962,14 @@ sub start_part {
if (($target eq 'grade') && &Apache::response::submitted()) {
$Apache::lonhomework::results{"resource.$id.rndseed"}=$rndseed;
}
+ } elsif (@Apache::inputtags::partlist > 1) {
+ my $prevparttype = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[-2].type");
+ if ($prevparttype eq 'randomizetry') {
+ my $rndseed=&setup_rndseed($safeeval,$target,'',$prevparttype);
+ if (($target eq 'grade') && &Apache::response::submitted()) {
+ $Apache::lonhomework::results{"resource.$id.rndseed"}=$rndseed;
+ }
+ }
} elsif (($target eq 'grade') && &Apache::response::submitted()) {
$Apache::lonhomework::results{"resource.$id.rndseed"}=$Apache::lonhomework::rawrndseed;
}
@@ -2721,20 +3045,14 @@ sub start_part {
} elsif ($target eq 'web') {
if ($status eq 'CAN_ANSWER') {
my $problemstatus = &get_problem_status($Apache::inputtags::part);
- my $probrandomize = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].type");
- my $probrandtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].randomizeontries");
my $num = scalar(@Apache::inputtags::partlist)-1;
- if ($probrandomize eq 'randomizetry') {
- if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.type") ne 'randomizetry') {
- $result .= &randomizetry_part_header($problemstatus,'none',$num);
- } else {
- my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
- if ($probrandtries ne $reqtries) {
- $result .= &randomizetry_part_header($problemstatus,$reqtries,$num);
- }
- }
- } elsif (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.type") eq 'randomizetry') {
- my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
+ if ((($Apache::lonhomework::default_type eq 'randomizetry') ||
+ ($Apache::lonhomework::randomizetrypart)) &&
+ ($Apache::lonhomework::type ne 'randomizetry')) {
+ $result .= &randomizetry_part_header($problemstatus,'none',$num);
+ } elsif ($Apache::lonhomework::type eq 'randomizetry') {
+ $Apache::lonhomework::randomizetrypart = 1;
+ my $reqtries = &Apache::lonnet::EXT("resource.$id.randomizeontries");
$result .= &randomizetry_part_header($problemstatus,$reqtries,$num);
}
}
@@ -2789,7 +3107,11 @@ sub end_part {
$gradestatus='';
}
$result.=$gradestatus;
- if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';}
+ if ($$tagstack[-2] eq 'td' and $target eq 'tex') {
+ if (not $env{'form.problem_split'}=~/yes/) {
+ $result.='\end{minipage}';
+ }
+ }
} elsif ($target eq 'edit') {
$result.=&Apache::edit::end_table();
} elsif ($target eq 'modified') {
@@ -2953,9 +3275,13 @@ sub end_startouttext {
.'
'
@@ -3044,13 +3370,13 @@ sub end_simpleeditbutton {
}
sub practice_problem_header {
- return '
'.&mt('Practice Problem').'
'.
+ return '
'.&mt('Practice Problem').'
'.
''.&mt('Submissions are not permanently recorded').
'';
}
sub randomizetry_problem_header {
- my ($problemstatus,$reqtries) = @_;
+ my ($problemstatus,$reqtries,$symb) = @_;
my ($header,$text);
if ($reqtries > 1) {
$header = &mt('New Problem Variation After Every [quant,_1,Try,Tries]',$reqtries);
@@ -3070,8 +3396,13 @@ sub randomizetry_problem_header {
$text = &mt('A new variation will be generated after each try until correct or tries limit is reached.');
}
}
- return '
'.
+ ''.$text.'';
+ }
}
sub randomizetry_part_header {
@@ -3079,7 +3410,7 @@ sub randomizetry_part_header {
my ($header,$text);
if ($reqtries eq 'none') {
$header = &mt('No Question Variation');
- $text = &mt('For this question there will no new variation after a try.');
+ $text = &mt('For this question there will be no new variation after a try.');
} elsif ($reqtries > 1) {
$header = &mt('New Question Variation After Every [quant,_1,Try,Tries]',$reqtries);
if (($problemstatus eq 'no') ||
@@ -3101,7 +3432,7 @@ sub randomizetry_part_header {
if ($num > 1) {
$output .= '';
}
- $output .= '