[LON-CAPA-cvs] cvs: doc /loncapafiles loncapafiles.lpml loncom/homework structuretags.pm loncom/html/res/adm/pages timer.png loncom/interface lonhtmlcommon.pm lonmenu.pm
raeburn
raeburn at source.lon-capa.org
Mon May 28 09:09:34 EDT 2012
raeburn Mon May 28 13:09:34 2012 EDT
Added files:
/loncom/html/res/adm/pages timer.png
Modified files:
/loncom/interface lonmenu.pm lonhtmlcommon.pm
/loncom/homework structuretags.pm
/doc/loncapafiles loncapafiles.lpml
Log:
- Bug 5891
- countdown moved to first item in right breadcrumbs.
- added "stopwatch" icon.
- added ability to toggle hiding/display of countdown.
- default is to hide unless timed interval parameter is in effect.
- "Submit Early" message only displayed ~ 5 mins before due date.
- "Past Due" text replaces "Submit Early" when time left is zero.
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.377 loncom/interface/lonmenu.pm:1.378
--- loncom/interface/lonmenu.pm:1.377 Fri May 25 03:22:43 2012
+++ loncom/interface/lonmenu.pm Mon May 28 13:09:16 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.377 2012/05/25 03:22:43 raeburn Exp $
+# $Id: lonmenu.pm,v 1.378 2012/05/28 13:09:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -778,9 +778,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'){
@@ -891,9 +900,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 '';
}
@@ -1179,6 +1198,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/}
@@ -1213,6 +1253,8 @@
my $esc_url=&escape($currenturl);
my $esc_symb=&escape($currentsymb);
+ my $countdown = &countdown_toggle_js();
+
return (<<ENDUTILITY)
var currentURL=unescape("$esc_url");
@@ -1363,6 +1405,8 @@
});
}(jQuery));
+$countdown
+
ENDUTILITY
}
@@ -1761,6 +1805,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 {
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.313 loncom/interface/lonhtmlcommon.pm:1.314
--- loncom/interface/lonhtmlcommon.pm:1.313 Wed May 9 19:46:30 2012
+++ loncom/interface/lonhtmlcommon.pm Mon May 28 13:09:17 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.313 2012/05/09 19:46:30 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.314 2012/05/28 13:09:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1370,7 +1370,9 @@
# is used to determine when the countdown timer turns red to warn the user
# to think about submitting.
- my $dueDateLayout = '<b>' . &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} - Submit early!') . '</b>';
+ my $dueDateLayout = &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} [_1]',"<span id='submitearly'></span>");
+ my $early = '- <b>'.&mt('Submit Early').'</b>';
+ my $pastdue = '- <b>'.&mt('Past Due').'</b>';
$output .= <<JAVASCRIPT;
var documentReadyTime;
@@ -1382,6 +1384,12 @@
layout: "$dueDateLayout",
onTick: function (periods) {
var latencyEstimate = (documentReadyTime - clientTime) * 2;
+ if(\$.countdown.periodsToSeconds(periods) < (300 + latencyEstimate)) {
+ \$("#submitearly").html("$early");
+ if (\$.countdown.periodsToSeconds(periods) < 1) {
+ \$("#submitearly").html("$pastdue");
+ }
+ }
if(\$.countdown.periodsToSeconds(periods) < (60 + latencyEstimate)) {
\$(this).css("color", "red"); //Highlight last minute.
}
@@ -1568,7 +1576,8 @@
my %tools = ();
sub breadcrumbs {
- my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $CourseBreadcrumbs) = @_;
+ my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt,
+ $CourseBreadcrumbs) = @_;
#
$css_class ||= 'LC_breadcrumbs';
@@ -1643,10 +1652,6 @@
$links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',
$lasttext), {title => $lasttext});
- unless ($CourseBreadcrumbs) {
- $links .= '<li> <span id="duedatecountdown"></span></li>';
- }
-
my $icons = '';
$faq = $last->{'faq'} if (exists($last->{'faq'}));
$bug = $last->{'bug'} if (exists($last->{'bug'}));
@@ -1724,7 +1729,7 @@
left of breadcrumbs line
=item tools
-right of breadcrumbs line
+remaining items in right of breadcrumbs line
=item advtools
advanced tools shown in a separate box below breadcrumbs line
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.505 loncom/homework/structuretags.pm:1.506
--- loncom/homework/structuretags.pm:1.505 Wed Apr 18 11:49:50 2012
+++ loncom/homework/structuretags.pm Mon May 28 13:09:22 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.505 2012/04/18 11:49:50 goltermann Exp $
+# $Id: structuretags.pm,v 1.506 2012/05/28 13:09:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1162,7 +1162,20 @@
my $accessmsg;
my $name= &get_resource_name($parstack,$safeeval);
- my ($result,$form_tag_start);
+ my ($result,$form_tag_start,$slot_name,$slot);
+
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex') {
+ if ($env{'form.markaccess'}) {
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ &Apache::lonnet::set_first_access($interval[1]);
+ }
+
+ ($status,$accessmsg,$slot_name,$slot) =
+ &Apache::lonhomework::check_slot_access('0','problem');
+ push (@Apache::inputtags::status,$status);
+ }
+
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex'
|| $target eq 'edit') {
($result,$form_tag_start) =
@@ -1175,20 +1188,14 @@
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval,$target); }
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex') {
- if ($env{'form.markaccess'}) {
- my @interval=&Apache::lonnet::EXT("resource.0.interval");
- &Apache::lonnet::set_first_access($interval[1]);
- }
- my $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'});
- my $time_left = $resource_due - time();
- if ($resource_due && ($time_left > 0) && ($target eq 'web')) {
- $result .= &Apache::lonhtmlcommon::set_due_date($resource_due);
- }
-
- ($status,$accessmsg,my $slot_name,my $slot) =
- &Apache::lonhomework::check_slot_access('0','problem');
- push (@Apache::inputtags::status,$status);
+ if ($status eq 'CAN_ANSWER') {
+ my $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'});
+ my $time_left = $resource_due - time();
+ if ($resource_due && ($time_left > 0) && ($target eq 'web')) {
+ $result .= &Apache::lonhtmlcommon::set_due_date($resource_due);
+ }
+ }
#handle rand seed in construction space
my $rndseed=&setup_rndseed($safeeval,$target);
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.801 doc/loncapafiles/loncapafiles.lpml:1.802
--- doc/loncapafiles/loncapafiles.lpml:1.801 Thu May 24 04:28:17 2012
+++ doc/loncapafiles/loncapafiles.lpml Mon May 28 13:09:34 2012
@@ -2,7 +2,7 @@
"http://lpml.sourceforge.net/DTD/lpml.dtd">
<!-- loncapafiles.lpml -->
-<!-- $Id: loncapafiles.lpml,v 1.801 2012/05/24 04:28:17 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.802 2012/05/28 13:09:34 raeburn Exp $ -->
<!--
@@ -7490,6 +7490,7 @@
symbs.png;
system-lock-screen.png;
system-users.png;
+timer.png;
ungrade_sub.png;
uplcrs.png;
uploadscores.png;
More information about the LON-CAPA-cvs
mailing list