--- loncom/interface/lonmenu.pm 2015/03/03 16:53:59 1.431.2.1
+++ loncom/interface/lonmenu.pm 2015/09/14 13:45:01 1.437
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.431.2.1 2015/03/03 16:53:59 musolffc Exp $
+# $Id: lonmenu.pm,v 1.437 2015/09/14 13:45:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -288,6 +288,11 @@ sub primary_menu {
push(@primsub,$item);
}
if (@primsub > 0) {
+ if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ } else {
+ $title = &mt($title);
+ }
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1);
} elsif ($link) {
$menu{$position} .= '
'.&mt($title).'';
@@ -510,19 +515,9 @@ sub create_submenu {
if ($target ne '') {
$disptarget = ' target="'.$target.'"';
}
- my $name;
- if ($title eq 'Personal') {
- if ($env{'user.name'} && $env{'user.domain'}) {
- $name = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
- } else {
- $name = &mt($title);
- }
- } else {
- $name = &mt($title);
- }
my $menu = ''.
''.
- ''.$name.
+ ''.$title.
''.
' ▼'.
'';
@@ -639,8 +634,18 @@ sub innerregister {
&& $maptitle ne $coursetitle);
push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
+ my @tools;
+ if ($env{'request.filename'} =~ /\.page$/) {
+ my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
+ if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
+ @tools = @{$breadcrumb_tools{'tools'}};
+ }
+ }
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
+ if (@tools) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',@tools);
+ }
} else {
$resurl = $env{'request.noversionuri'};
my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
@@ -776,6 +781,9 @@ sub innerregister {
my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
if ($currdir =~ m-/$-) {
$is_const_dir = 1;
+ if ($thisdisfn eq '') {
+ $is_const_dir = 2;
+ }
} else {
$currdir =~ s|[^/]+$||;
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
@@ -897,13 +905,20 @@ ENDMENUITEMS
my $addremote=0;
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
if ($addremote) {
-
+ my $countdown;
+ if ($env{'request.filename'} =~ /\.page$/) {
+ my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
+ if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
+ $countdown = $breadcrumb_tools{'tools'}[0];
+ }
+ } else {
+ $countdown = &countdown_timer();
+ }
&Apache::lonhtmlcommon::clear_breadcrumb_tools();
&Apache::lonhtmlcommon::add_breadcrumb_tool(
'navigation', @inlineremote[21,23]);
- my $countdown = &countdown_timer();
if (&hidden_button_check() eq 'yes') {
if ($countdown) {
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
@@ -927,9 +942,18 @@ ENDMENUITEMS
&advtools_crumbs(@inlineremote);
}
}
-
+ my ($topic_help,$topic_help_text);
+ if ($is_const_dir == 2) {
+ if ((($ENV{'SERVER_PORT'} == 443) ||
+ ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) &&
+ (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) {
+ $topic_help = 'Authoring_WebDAV,Authoring_WebDAV_Mac_10v6,Authoring_WebDAV_Mac_10v10,'.
+ 'Authoring_WebDAV_Windows_v7,Authoring_WebDAV_Linux_Centos';
+ $topic_help_text = 'About WebDAV access';
+ }
+ }
return &Apache::lonhtmlcommon::scripttag('', 'start')
- . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
+ . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text)
. &Apache::lonhtmlcommon::scripttag('', 'end');
}
@@ -1533,14 +1557,70 @@ function toggleCountdown() {
return;
}
-function zeroTimer() {
- if (confirm('Are you sure?')) {
- document.getElementsByName('done')[0].value = 'true';
- document.getElementsByName('doneButton')[0].submit();
- }
+END
}
+# This creates a "done button" for timed events. The confirmation box is a jQuery
+# dialog widget. Clicking OK will set (LC_interval_done = 'true') which is checked in
+# lonhomework.pm.
+sub done_button_js {
+ my ($type,$height) = @_;
+ if ($height !~ /^\d+$/) {
+ $height = 320;
+ }
+ 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).',
+ ok => 'Click "OK" if you are completely finished.',
+ cancel => 'Click "Cancel" to continue working.',
+ );
+ my $confirm;
+ if (($type eq 'map') || ($type eq 'resource')) {
+ $confirm = $lt{'preamble'}.' '.$lt{$type}.' '.$lt{'ok'}.' '.$lt{'cancel'};
+ }
+ if ($confirm) {
+ return <
+
+
+
+
+
+
+
+
END
+ } else {
+ return;
+ }
}
sub utilityfunctions {
@@ -1792,7 +1872,7 @@ sub roles_selector {
my $now = time;
my (%courseroles,%seccount,%courseprivs);
my $is_cc;
- my ($js,$form,$switcher,$switchtext);
+ my ($js,$form,$switcher);
my $ccrole;
if ($crstype eq 'Community') {
$ccrole = 'co';
@@ -1880,7 +1960,6 @@ sub roles_selector {
}
}
}
- $switchtext = 'Switch role'; # do not translate here
my @roles_order = ($ccrole,'in','ta','ep','ad','st');
my $numdiffsec;
if (keys(%seccount) == 1) {
@@ -1936,7 +2015,7 @@ sub roles_selector {
}
}
if (@submenu > 0) {
- $switcher = &create_submenu('','',$switchtext,\@submenu);
+ $switcher = &create_submenu('','',&mt('Switch role'),\@submenu);
}
}
return ($js,$form,$switcher);
@@ -2207,10 +2286,12 @@ sub countdown_timer {
}
my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ my ($timelimit,$usesdone);
if (@interval > 1) {
+ ($timelimit,$usesdone) = split(/_/,$interval[0]);
my $first_access=&Apache::lonnet::get_first_access($interval[1]);
if ($first_access > 0) {
- if ($first_access+$interval[0] > time) {
+ if ($first_access+$timelimit > time) {
$hastimeleft = 1;
}
}
@@ -2218,11 +2299,16 @@ sub countdown_timer {
if (($duedate && $duedate > time) ||
(!$duedate && $hastimeleft) ||
($slot_name ne '' && $slothastime)) {
- my ($collapse,$expand,$alttxt,$title,$currdisp);
+ my ($collapse,$expand,$alttxt,$title,$currdisp,$donebutton);
if ((@interval > 1 && $hastimeleft) ||
($type eq 'Task' && $slothastime)) {
$currdisp = 'inline';
$collapse = '► ';
+ if ((@interval > 1) && ($hastimeleft)) {
+ if ($usesdone eq 'done') {
+ $donebutton = &done_button_js($interval[1]);
+ }
+ }
} else {
$currdisp = 'none';
$expand = '◄ ';
@@ -2232,8 +2318,9 @@ sub countdown_timer {
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
- return <