--- loncom/interface/lonmenu.pm	2016/04/04 17:24:05	1.444
+++ loncom/interface/lonmenu.pm	2016/06/19 04:27:50	1.451
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.444 2016/04/04 17:24:05 raeburn Exp $
+# $Id: lonmenu.pm,v 1.451 2016/06/19 04:27:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -124,9 +124,13 @@ dropdown list when mouse hovers over top
 (no hover psuedo class) via LC_hoverable class for <li> tag for top-
 level item, which employs jQuery to handle behavior on mouseover.
 
-Inputs: 4 - (a) link and (b) target for anchor href in top level item,
-            (c) title for text wrapped by anchor tag in top level item.
-            (d) reference to array of arrays of sub-menu items.
+Inputs: 6 - (a) link and (b) target for anchor href in top level item,
+            (c) title for text wrapped by anchor tag in top level item,
+            (d) reference to array of arrays of sub-menu items,
+            (e) boolean to indicate whether to call &mt() to translate 
+                name of menu item,
+            (f) optional class for <li> element in primary menu, for which
+                sub menu is being generated.
 
  The underlying datastructure used in (d) contains data from mydesk.tab.
  It consists of an array which has an array for each item appearing in
@@ -534,13 +538,13 @@ sub secondary_menu {
 }
 
 sub create_submenu {
-    my ($link,$target,$title,$submenu,$translate) = @_;
+    my ($link,$target,$title,$submenu,$translate,$addclass) = @_;
     return unless (ref($submenu) eq 'ARRAY');
     my $disptarget;
     if ($target ne '') {
         $disptarget = ' target="'.$target.'"';
     }
-    my $menu = '<li class="LC_hoverable">'.
+    my $menu = '<li class="LC_hoverable '.$addclass.'">'.
                '<a href="'.$link.'"'.$disptarget.'>'.
                '<span class="LC_nobreak">'.$title.
                '<span class="LC_fontsize_small" style="font-weight:normal;">'.
@@ -560,7 +564,7 @@ sub create_submenu {
 # see perldoc create_submenu documentation for further information
 sub build_submenu {
     my ($target, $submenu, $translate, $first_level) = @_; 
-    if (!defined(@{$submenu})) {
+    unless (@{$submenu}) {
         return '';
     }
 
@@ -808,7 +812,11 @@ sub innerregister {
             if ($currdir =~ m-/$-) {
                 $is_const_dir = 1;
                 if ($thisdisfn eq '') {
-                    $is_const_dir = 2;
+                    unless (($env{'request.course.id'}) && 
+                            ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
+                            ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) { 
+                        $is_const_dir = 2;
+                    }
                 }
             } else {
                 $currdir =~ s|[^/]+$||;
@@ -947,9 +955,14 @@ ENDMENUITEMS
                 }
             }
         }
+        my $showprogress;
+        if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
+            $showprogress = &placement_progress();
+        }
+
+	my $addremote=0;
+	foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
 
-	    my $addremote=0;
-	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
     if ($addremote) {
         my $countdown;
         if ($env{'request.filename'} =~ /\.page$/) {
@@ -969,6 +982,9 @@ ENDMENUITEMS
             if ($countdown) {
                 &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
             }
+            if ($showprogress) {
+                &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
+            }
         } else {
             my @tools = @inlineremote[93,91,81,82,83];
             if ($countdown) {
@@ -987,6 +1003,10 @@ ENDMENUITEMS
             }
             &advtools_crumbs(@inlineremote);
         }
+    } else {
+        if ($showprogress) {
+            &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
+        }
     }
     my ($topic_help,$topic_help_text);
     if ($is_const_dir == 2) {
@@ -1618,11 +1638,10 @@ END
 # LC_interval_done is true.
 #
 sub done_button_js {
-    my ($type,$width,$height,$proctor) = @_;
+    my ($type,$width,$height,$proctor,$donebuttontext) = @_;
     return unless (($type eq 'map') || ($type eq 'resource'));
     my %lt = &Apache::lonlocal::texthash(
                  title    => 'WARNING!',
-                 button   => 'Done',
                  preamble => 'You are trying to end this timed event early.',
                  map      => 'Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder.',
                  resource => 'Confirming that you are done will cause the time to expire for this question, and prevent you from changing your answer(s).', 
@@ -1635,10 +1654,8 @@ sub done_button_js {
                  nokey    => 'A proctor key is required', 
     );
     my $navmap = Apache::lonnavmaps::navmap->new(); 
-    my ($missing,$tried);
+    my ($missing,$tried) = (0,0);
     if (ref($navmap)) {
-        $missing=0;
-        $tried=0;
         my @resources=();
         if ($type eq 'map') {
             my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'});
@@ -1652,13 +1669,7 @@ sub done_button_js {
             }
         }
         foreach my $res (@resources) {
-            if ($res->singlepart()) {
-                if (!$res->tries()) {
-                    $missing++;
-                } else {
-                    $tried++;
-                }
-            } else {
+            if (ref($res->parts()) eq 'ARRAY') {
                 foreach my $part (@{$res->parts()}) {
                     if (!$res->tries($part)) {
                         $missing++;
@@ -1682,6 +1693,7 @@ sub done_button_js {
             $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'</p>';
         }
     }
+    $donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"');
     if ($proctor) {
         if ($height !~ /^\d+$/) {
             $height = 400;
@@ -1699,14 +1711,14 @@ sub done_button_js {
 <form method="post" name="LCdoneButton" action="">
     <input type="hidden" name="LC_interval_done" value="" />
     <input type="hidden" name="LC_interval_done_proctorpass" value="" />
-    <button id="LC_done-confirm-opener" type="button">$lt{'button'}</button>
+    <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
 </form>
 
 <div id="LC_done-confirm" title="$lt{'title'}">
   <p>$lt{'preamble'} $lt{$type}</p>
   $lt{'miss'}
   <p>$lt{'proctor'}</p>
-  <form>
+  <form name="LCdoneButtonProctor" action="">
     <label>$lt{'key'}<input type="password" name="LC_interval_done_proctorkey" value="" /></label>
     <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
   </form>
@@ -1780,7 +1792,7 @@ END
 
 <form method="post" name="LCdoneButton" action="">
     <input type="hidden" name="LC_interval_done" value="" />
-    <button id="LC_done-confirm-opener" type="button">$lt{'button'}</button>
+    <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
 </form>
 
 <div id="LC_done-confirm" title="$lt{'title'}">
@@ -2485,9 +2497,17 @@ sub countdown_timer {
         }
         my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
         my @interval=&Apache::lonnet::EXT("resource.0.interval");
-        my ($timelimit,$usesdone,$proctor,$secret);
+        my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
         if (@interval > 1) {
-            ($timelimit,$usesdone,$proctor,$secret) = split(/_/,$interval[0]); 
+            ($timelimit,my $donesuffix) = split(/_/,$interval[0],2);
+            if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
+                $usesdone = 'done';
+                $donebuttontext = $1;
+                (undef,$proctor,$secret) = split(/_/,$2);
+            } elsif ($donesuffix =~ /^done(|_.+)$/) {
+                $donebuttontext = &mt('Done');
+                ($usesdone,$proctor,$secret) = split(/_/,$donesuffix);
+            }
             my $first_access=&Apache::lonnet::get_first_access($interval[1]);
             if ($first_access > 0) {
                 if ($first_access+$timelimit > time) {
@@ -2505,7 +2525,7 @@ sub countdown_timer {
                 $collapse = '&#9658;&nbsp;';
                 if ((@interval > 1) && ($hastimeleft)) {
                     if ($usesdone eq 'done') {
-                        $donebutton = &done_button_js($interval[1],'','',$proctor);
+                        $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);
                     }
                 }
             } else {
@@ -2534,6 +2554,13 @@ END
     return;
 }
 
+sub placement_progress {
+    my ($totalpoints,$incomplete) = &Apache::lonplacementtest::check_completion(undef,undef,1);
+    my $complete = 100 - $incomplete;
+    return '<span class="LC_placement_prog">'.
+           &mt('Test is [_1]% complete',$complete).'</span>';
+}
+
 # ================================================================ Main Program
 
 BEGIN {