[LON-CAPA-cvs] cvs: loncom(version_2_11_donebutton) /homework lonhomework.pm /interface lonmenu.pm

musolffc musolffc at source.lon-capa.org
Tue Mar 3 11:54:03 EST 2015


musolffc		Tue Mar  3 16:54:03 2015 EDT

  Modified files:              (Branch: version_2_11_donebutton)
    /loncom/interface	lonmenu.pm 
    /loncom/homework	lonhomework.pm 
  Log:
  Iplementing done button
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.431 loncom/interface/lonmenu.pm:1.431.2.1
--- loncom/interface/lonmenu.pm:1.431	Mon Jan 19 15:36:01 2015
+++ loncom/interface/lonmenu.pm	Tue Mar  3 16:53:59 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.431 2015/01/19 15:36:01 goltermann Exp $
+# $Id: lonmenu.pm,v 1.431.2.1 2015/03/03 16:53:59 musolffc Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1533,6 +1533,13 @@
     return;
 }
 
+function zeroTimer() {
+    if (confirm('Are you sure?')) {
+        document.getElementsByName('done')[0].value = 'true';
+        document.getElementsByName('doneButton')[0].submit();
+    }
+}
+
 END
 }
 
@@ -2235,6 +2242,10 @@
 <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" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
+<form method="post" name="doneButton">
+<input type="hidden" name="done" value=""/>
+<button type="button" onclick="zeroTimer()">Done</button>
+</form>    
 END
         }
     }
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.349 loncom/homework/lonhomework.pm:1.349.2.1
--- loncom/homework/lonhomework.pm:1.349	Sat Feb 21 21:53:34 2015
+++ loncom/homework/lonhomework.pm	Tue Mar  3 16:54:03 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.349 2015/02/21 21:53:34 raeburn Exp $
+# $Id: lonhomework.pm,v 1.349.2.1 2015/03/03 16:54:03 musolffc Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1331,10 +1331,30 @@
     }
 }
 
+# Sets timer to zero for the entire folder containing the current resource for the
+# current user.  This is called by the done button and the javascript function
+# zeroTimer() in lonmenu.pm
+sub zero_timer {
+    my $symb = shift;
+    my $first_access = &Apache::lonnet::get_first_access("map",$symb);
+    my $done_time = time() - $first_access;
+    &Apache::lonparmset::storeparm_by_symb($symb,"0_interval","2",$done_time,
+            "date_interval",$env{'user.name'},$env{'user.domain'},,'',);
+}
+
 
 sub handler {
     #my $t0 = [&gettimeofday()];
     my $request=$_[0];
+
+    my ($symb) = &Apache::lonnet::whichuser();
+
+    # Set the event timer to zero if the "done button" was clicked.
+    if ($env{"form.done"} eq "true") {
+        &zero_timer($symb);
+        $env{"form.done"} = "";
+    }
+
     $Apache::lonxml::request=$request;
     $Apache::lonxml::debug=$env{'user.debug'};
     $env{'request.uri'}=$request->uri;
@@ -1359,7 +1379,6 @@
     }
     &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade");
     &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'});
-    my ($symb) = &Apache::lonnet::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);
     if ($env{'request.state'} eq "construct") {
 	if ( -e $file ) {




More information about the LON-CAPA-cvs mailing list