Index: lams_tool_assessment/web/pages/learning/learning.jsp =================================================================== diff -u -r269c13324c6bb998631af858dc8091ad3102ef78 -r02ce40b60524aa33d326fbda824dcd43f566ab94 --- lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 269c13324c6bb998631af858dc8091ad3102ef78) +++ lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 02ce40b60524aa33d326fbda824dcd43f566ab94) @@ -195,31 +195,30 @@ //autosave feature + + function learnerAutosave(){ + if (isWaitingForConfirmation) return; + + //copy value from CKEditor (only available in essay type of questions) to textarea before ajax submit + $("textarea[id^='question']").each(function() { + var ckeditorData = CKEDITOR.instances[this.name].getData(); + //skip out empty values + this.value = ((ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|

|<\/p>|\xa0/g, "").length == 0)) ? "" : ckeditorData; + }); + + //ajax form submit + $('#answers').ajaxSubmit({ + url: "?sessionMapID=${sessionMapID}&date=" + new Date().getTime(), + success: function() { + $.jGrowl( + " ", + { life: 2000, closeTemplate: '' } + ); + } + }); + } var autosaveInterval = "30000"; // 30 seconds interval - window.setInterval( - function(){ - if (isWaitingForConfirmation) return; - - //copy value from CKEditor (only available in essay type of questions) to textarea before ajax submit - $("textarea[id^='question']").each(function() { - var ckeditorData = CKEDITOR.instances[this.name].getData(); - //skip out empty values - this.value = ((ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|

|<\/p>|\xa0/g, "").length == 0)) ? "" : ckeditorData; - }); - - //ajax form submit - $('#answers').ajaxSubmit({ - url: "?sessionMapID=${sessionMapID}&date=" + new Date().getTime(), - success: function() { - $.jGrowl( - " ", - { life: 2000, closeTemplate: '' } - ); - } - }); - }, - autosaveInterval - ); + window.setInterval(learnerAutosave, autosaveInterval); //check if we came back due to failed answers' validation (missing required question's answer or min words limit not reached)