Update of /var/cvs/contributions/didactor2/src/assessment/templates/assessment
In directory james.mmbase.org:/tmp/cvs-serv7782

Modified Files:
        stage5.js.jsp 
Log Message:
Solved a synchronizated issue. 


See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/assessment/templates/assessment


Index: stage5.js.jsp
===================================================================
RCS file: 
/var/cvs/contributions/didactor2/src/assessment/templates/assessment/stage5.js.jsp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- stage5.js.jsp       9 Jan 2009 14:34:37 -0000       1.7
+++ stage5.js.jsp       9 Jan 2009 15:12:05 -0000       1.8
@@ -2,8 +2,9 @@
 <%...@taglib uri="http://www.mmbase.org/mmbase-taglib-2.0"; prefix="mm"
     %><mm:content type="text/javascript">
 
-$(window).unload(function() {
 
+
+var commitDifficulties = function () {
     // Save difficulties first.
     var params = {};
 
@@ -35,11 +36,20 @@
 
              }
            });
+}
+
+var commitTest = function () {
     // Then the test
+    if (document.forms.questionform) {
     document.forms.questionform.command.value = 'done';
-
     postContent(document.forms.questionform.action, 
document.forms.questionform, false);
+    }
+}
 
+// Using beforeunload rather then unload to avoid synchorinization issues. If 
e.g. you click back to overview, this must not be started before caches are 
invalidated
+$(window).bind('beforeunload', function () {
+    commitDifficulties();
+    commitTest();
 });
 
 </mm:content>
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to