--- loncom/homework/structuretags.pm 2016/04/02 04:16:19 1.545
+++ loncom/homework/structuretags.pm 2016/09/14 02:42:43 1.550
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.545 2016/04/02 04:16:19 raeburn Exp $
+# $Id: structuretags.pm,v 1.550 2016/09/14 02:42:43 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';
@@ -417,9 +419,13 @@ sub page_start {
$extra_head .= &homework_js().
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
if (&Apache::lonhtmlcommon::htmlareabrowser()) {
- my %textarea_args = (
+ my %textarea_args;
+ if (($env{'request.state'} ne 'construct') ||
+ ($env{'environment.nocodemirror'})) {
+ %textarea_args = (
dragmath => 'math',
);
+ }
$extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
}
my $is_task = ($env{'request.uri'} =~ /\.task$/);
@@ -772,7 +778,9 @@ sub problem_edit_buttons {
if ($mode eq 'editxml') {
$result.=&problem_edit_action_button('subedit','edit','e','Edit',1);
$result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1);
- $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
+ if ($env{'environment.nocodemirror'}) {
+ $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
+ }
} else {
$result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1);
$result.=&problem_edit_action_button('subundo','undo','u','Undo',1);
@@ -1602,7 +1610,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);
@@ -1922,7 +1933,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 = '';
@@ -2966,9 +3009,13 @@ sub end_startouttext {
.''.&mt('Delete?').' '
.&Apache::edit::deletelist($target,$token)
.' | '
- .''
- .&Apache::lonhtmlcommon::dragmath_button($areaid,1)
- .' | '
+ .'';
+ if ($env{'environment.nocodemirror'}) {
+ $result.=&Apache::lonhtmlcommon::dragmath_button($areaid,1);
+ } else {
+ $result.=' ';
+ }
+ $result.=' | '
.''
.&Apache::edit::insertlist($target,$token)
.' | '