[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmenu.pm

raeburn raeburn at source.lon-capa.org
Mon May 28 10:45:21 EDT 2012


raeburn		Mon May 28 14:45:21 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmenu.pm 
  Log:
  - For 2.11.
    - Backport 1.378.
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.9 loncom/interface/lonmenu.pm:1.369.2.10
--- loncom/interface/lonmenu.pm:1.369.2.9	Sat May 26 13:57:02 2012
+++ loncom/interface/lonmenu.pm	Mon May 28 14:45:20 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.9 2012/05/26 13:57:02 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.10 2012/05/28 14:45:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -808,9 +808,18 @@
             &Apache::lonhtmlcommon::add_breadcrumb_tool(
                 'navigation', @inlineremote[21,23]);
 
-        if(hidden_button_check() ne 'yes') {
+        my $countdown = &countdown_timer();
+        if (&hidden_button_check() eq 'yes') {
+            if ($countdown) {
+                &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
+            }
+        } else {
+            my @tools = @inlineremote[93,91,81,82,83];
+            if ($countdown) {
+                unshift(@tools,$countdown);
+            }
             &Apache::lonhtmlcommon::add_breadcrumb_tool(
-                'tools', @inlineremote[93,91,81,82,83]);
+                'tools', at tools);
 
             #publish button in construction space
             if ($env{'request.state'} eq 'construct'){
@@ -1079,9 +1088,19 @@
 	   }
     } else {
 # Inline Menu
-      $inlineremote[$idx]=
+        my @tools = (93,91,81,82,83);
+        unless ($env{'request.state'} eq 'construct') {
+            push(@tools,63);
+        }
+        if (($env{'environment.icons'} eq 'iconsonly') &&
+            (grep(/^$idx$/, at tools))) {
+            $inlineremote[$idx] =
+        '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
+        } else {
+            $inlineremote[$idx] =
        '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
        '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
+        }
     }
     return '';
 }
@@ -1389,6 +1408,27 @@
 
 }
 
+sub countdown_toggle_js {
+    return <<"END";
+
+function toggleCountdown() {
+    var countdownid = document.getElementById('duedatecountdown');
+    var currstyle = countdownid.style.display;
+    if (currstyle == 'inline') {
+        countdownid.style.display = 'none';
+        document.getElementById('ddcountcollapse').innerHTML='';
+        document.getElementById('ddcountexpand').innerHTML='◄ ';
+    } else {
+        countdownid.style.display = 'inline';
+        document.getElementById('ddcountcollapse').innerHTML='► ';
+        document.getElementById('ddcountexpand').innerHTML='';
+    }
+    return;
+}
+
+END
+}
+
 sub utilityfunctions {
     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
     if ($currenturl =~ m{^/adm/wrapper/ext/}
@@ -1423,6 +1463,8 @@
     my $esc_url=&escape($currenturl);
     my $esc_symb=&escape($currentsymb);
 
+    my $countdown = &countdown_toggle_js();
+
 return (<<ENDUTILITY)
 
     var currentURL=unescape("$esc_url");
@@ -1573,6 +1615,8 @@
   });
 }(jQuery));
 
+$countdown
+
 ENDUTILITY
 }
 
@@ -1971,6 +2015,41 @@
     return $privs;
 }
 
+sub countdown_timer {
+    if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
+        ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&
+        ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
+        my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
+        if ($duedate && $duedate > time) {
+            my ($collapse,$expand,$title,$currdisp);
+            my @interval=&Apache::lonnet::EXT("resource.0.interval");
+            if (@interval > 1) {
+                $currdisp = 'inline';
+                $collapse = '► ';
+            } else {
+                $currdisp = 'none';
+                $expand = '◄ ';
+            }
+            unless ($env{'environment.icons'} eq 'iconsonly') {
+                $title = &mt('Timer');
+            }
+            my $desc = &mt('Countdown to due date/time');
+            return <<END;
+
+<a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
+<span id="ddcountcollapse" class="LC_menubuttons_inline_text">
+$collapse
+</a></span>
+<span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
+<a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
+<span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
+<img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon"><span class="LC_menubuttons_inline_text">$title</span></a>
+END
+        }
+    }
+    return;
+}
+
 # ================================================================ Main Program
 
 BEGIN {




More information about the LON-CAPA-cvs mailing list