--- loncom/homework/structuretags.pm 2015/04/17 12:33:56 1.535
+++ loncom/homework/structuretags.pm 2016/04/04 17:34:01 1.549
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.535 2015/04/17 12:33:56 droeschl Exp $
+# $Id: structuretags.pm,v 1.549 2016/04/04 17:34:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -226,9 +226,11 @@ sub end_tex {
sub homework_js {
my ($postsubmit,$timeout);
if (($env{'request.course.id'}) && ($env{'request.state'} ne 'construct')) {
- my $crstype;
- if (&Apache::loncommon::course_type() eq 'Community') {
+ my $crstype = &Apache::loncommon::course_type();
+ if ($crstype eq 'Community') {
$crstype = 'community';
+ } elsif ($crstype eq 'Placement') {
+ $crstype = 'placement';
} else {
if ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) {
$crstype = 'official';
@@ -490,7 +492,9 @@ sub page_start {
}
}
if ($needs_upload) {
- $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js();
+ $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js()
+ .'';
}
}
@@ -521,23 +525,25 @@ sub page_start {
} elsif (!defined($found{'body'})
&& $env{'request.state'} eq 'construct') {
if ($target eq 'web' || $target eq 'edit') {
- # Breadcrumbs for Authoring Space
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb({
- 'text' => 'Authoring Space',
- 'href' => &Apache::loncommon::authorspace($env{'request.uri'}),
- });
- # breadcrumbs (and tools) will be created
- # in start_page->bodytag->innerregister
+ unless ($env{'form.inhibitmenu'} eq 'yes') {
+ # Breadcrumbs for Authoring Space
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Authoring Space',
+ 'href' => &Apache::loncommon::authorspace($env{'request.uri'}),
+ });
+ # breadcrumbs (and tools) will be created
+ # in start_page->bodytag->innerregister
# FIXME Where are we?
-# &Apache::lonhtmlcommon::add_breadcrumb({
-# 'text' => 'Problem Editing', # 'Problem Testing'
-# 'href' => '',
-# });
- $pageheader =&Apache::loncommon::head_subbox(
- &Apache::loncommon::CSTR_pageheader());
- }
+# &Apache::lonhtmlcommon::add_breadcrumb({
+# 'text' => 'Problem Editing', # 'Problem Testing'
+# 'href' => '',
+# });
+ $pageheader = &Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader());
+ }
+ }
} elsif (!defined($found{'body'})) {
my %add_entries;
my $background=&Apache::lonxml::get_param('background',$parstack,
@@ -974,6 +980,12 @@ $show_all
'onclick="javascript:setmode(this.form,'."'edit'".')" />';
$result .= '';
+ if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
+ my $uri = $env{'request.uri'};
+ my $daxeurl = '/daxepage'.$uri;
+ $result .= '';
+ }
$result.='
@@ -1276,8 +1288,8 @@ sub store_aggregates {
} else {
$anoncounter{$symb."\0".$part} = 1;
}
- my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}};
- if ($needsrelease) {
+ my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}.'::'};
+ if ($needsrelease) {
my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
if ($curr_required eq '') {
&Apache::lonnet::update_released_required($needsrelease);
@@ -1388,6 +1400,7 @@ sub init_problem_globals {
@Apache::inputtags::importlist = ();
@Apache::inputtags::previous=();
@Apache::inputtags::previous_version=();
+ $Apache::inputtags::leniency='';
$Apache::structuretags::printanswer='No';
@Apache::structuretags::whileconds=();
@Apache::structuretags::whilebody=();
@@ -1403,6 +1416,7 @@ sub reset_problem_globals {
undef(%Apache::lonhomework::history);
undef(%Apache::lonhomework::results);
undef($Apache::inputtags::part);
+ undef($Apache::inputtags::leniency);
if ($type eq 'Task') {
undef($Apache::inputtags::slot_name);
} elsif ($type eq 'problem') {
@@ -1506,6 +1520,7 @@ sub start_problem {
my $status;
my $accessmsg;
my $resource_due;
+ my $ipused;
my $name= &get_resource_name($parstack,$safeeval);
my ($result,$form_tag_start,$slot_name,$slot,$probpartlist);
@@ -1514,10 +1529,11 @@ sub start_problem {
$target eq 'tex') {
if ($env{'form.markaccess'}) {
my @interval=&Apache::lonnet::EXT("resource.0.interval");
- &Apache::lonnet::set_first_access($interval[1],$interval[0]);
+ my ($timelimit) = split(/_/,$interval[0]);
+ &Apache::lonnet::set_first_access($interval[1],$timelimit);
}
- ($status,$accessmsg,$slot_name,$slot) =
+ ($status,$accessmsg,$slot_name,$slot,$ipused) =
&Apache::lonhomework::check_slot_access('0','problem');
push (@Apache::inputtags::status,$status);
}
@@ -1588,7 +1604,10 @@ sub start_problem {
$form_tag_start.='
';
} elsif (($env{'request.state'} ne "construct") &&
($Apache::lonhomework::type eq 'randomizetry') &&
- ($status eq 'CAN_ANSWER')) {
+ ($status eq 'CAN_ANSWER') &&
+ ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement') &&
+ (!$env{'request.role.adv'})) {
+# "New Problem Variation Each Try" header suppressed for Placement Tests, unless course personnel.
my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
my $problemstatus = &get_problem_status($Apache::inputtags::part);
$form_tag_start.=&randomizetry_problem_header($problemstatus,$reqtries);
@@ -1608,7 +1627,8 @@ sub start_problem {
( $status eq 'NOTRESERVABLE') ||
( $status eq 'RESERVABLE') ||
( $status eq 'RESERVABLE_LATER') ||
- ( $status eq 'INVALID_ACCESS')) {
+ ( $status eq 'INVALID_ACCESS') ||
+ ( $status eq 'NEED_DIFFERENT_IP')) {
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
$style);
if ( $target eq "web" ) {
@@ -1641,7 +1661,14 @@ sub start_problem {
&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)? ''
@@ -1661,8 +1688,11 @@ sub start_problem {
$result .=
&Apache::bridgetask::proctor_validation_screen($slot);
} elsif ($target eq 'grade') {
- &Apache::bridgetask::proctor_check_auth($slot_name,$slot,
- 'problem');
+ my $checkinresult = &Apache::bridgetask::proctor_check_auth($slot_name,$slot,
+ 'problem');
+ if ($checkinresult = /^error:/) {
+ $result .= 'error';
+ }
}
} elsif ($target eq 'web') {
if ($status eq 'CAN_ANSWER') {
@@ -1672,10 +1702,18 @@ sub start_problem {
$Apache::lonhomework::history{'resource.0.checkedin'};
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"};
+ 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()) {
@@ -1698,7 +1736,12 @@ 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.= ''.
@@ -1884,7 +1927,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 = '';
@@ -2606,6 +2681,7 @@ sub start_part {
my $id= &Apache::lonxml::get_id($parstack,$safeeval);
$Apache::inputtags::part=$id;
push(@Apache::inputtags::partlist,$id);
+ $Apache::inputtags::leniency='';
@Apache::inputtags::response=();
@Apache::inputtags::previous=();
@Apache::inputtags::previous_version=();
@@ -2771,6 +2847,7 @@ sub end_part {
}
pop @Apache::inputtags::status;
$Apache::inputtags::part='';
+ $Apache::inputtags::leniency='';
$Apache::lonhomework::type = $Apache::lonhomework::default_type;
return $result;
}