diff --git a/js/tools.js b/js/tools.js
index 4a9f979c07..e18cde2be3 100644
--- a/js/tools.js
+++ b/js/tools.js
@@ -273,6 +273,11 @@ function exercise_init_countdown(params) {
var exerciseId = params.exerciseId,
eurid = params.eurid;
+ $('.clearSelect').click(function (e) {
+ e.preventDefault();
+ $(this).closest('.panel-body').find('input[type=radio]').prop('checked', false);
+ });
+
// Don't submit question on enter keypress in input field
$('.exercise input').keydown(function(event) {
if (event.which === 13) {
@@ -713,10 +718,10 @@ function unit_password_bootbox(e) {
title;
if (el.hasClass('paused_exercise')) {
- title = lang.continueAttempt;
+ lang.submit = title = lang.continueAttempt;
notice = '
' + lang.temporarySaveNotice + '
';
} else if (el.hasClass('active_exercise')) {
- title = lang.continueAttempt;
+ lang.submit = title = lang.continueAttempt;
notice = '
' + lang.continueAttemptNotice + '
';
}
if (el.hasClass('password_protected')) {
diff --git a/lang/el/messages.inc.php b/lang/el/messages.inc.php
index a6ffd5015f..a60e4dac25 100644
--- a/lang/el/messages.inc.php
+++ b/lang/el/messages.inc.php
@@ -1886,6 +1886,7 @@
$langQuestionPoolPurgeSuccess = "Η διαγραφή των αχρησιμοποίητων ερωτήσεων από την τράπεζα ερωτήσεων πραγματοποιήθηκε.";
$langShuffleQuestions = "Ανακάτεμα όλων των ερωτήσεων";
$langShuffleQuestions = "Ανακάτεμα όλων των ερωτήσεων";
+$langClear = 'Εκκαθάριση';
// admin.php
$langExerciseManagement = "Διαχείριση Άσκησης";
diff --git a/lang/en/messages.inc.php b/lang/en/messages.inc.php
index aef8c23a61..74e109f168 100644
--- a/lang/en/messages.inc.php
+++ b/lang/en/messages.inc.php
@@ -5391,3 +5391,4 @@
$langUsersInOtherGroups = 'The following users were already members of other groups and cannot be added to this one';
$langUsersOverMaximum = 'The final count (%d) exceeds the maximum number of group members (%d).';
$langUsersAddedToGroup = 'The users were added to the group.';
+$langClear = 'Clear';
diff --git a/modules/exercise/exercise.lib.php b/modules/exercise/exercise.lib.php
index 0adf90b780..92f441612f 100644
--- a/modules/exercise/exercise.lib.php
+++ b/modules/exercise/exercise.lib.php
@@ -28,8 +28,7 @@
function showQuestion(&$objQuestionTmp, $exerciseResult = array(), $question_number) {
global $tool_content, $picturePath, $langNoAnswer, $langQuestion,
$langColumnA, $langColumnB, $langMakeCorrespond, $langInfoGrades,
- $exerciseType, $nbrQuestions, $langInfoGrade, $langHasAnswered;
-
+ $exerciseType, $nbrQuestions, $langInfoGrade, $langHasAnswered, $langClear;
$questionId = $objQuestionTmp->selectId();
$questionWeight = $objQuestionTmp->selectWeighting();
@@ -199,6 +198,9 @@ function showQuestion(&$objQuestionTmp, $exerciseResult = array(), $question_num
if (!$nbrAnswers && $answerType != FREE_TEXT) {
$tool_content .= "
";
}
-}
\ No newline at end of file
+}
diff --git a/modules/exercise/exercise_submit.php b/modules/exercise/exercise_submit.php
index 38f2a563b9..1914e2729c 100644
--- a/modules/exercise/exercise_submit.php
+++ b/modules/exercise/exercise_submit.php
@@ -384,7 +384,6 @@ function unset_exercise_var($exerciseId) {
$nbrQuestions = count($questionList);
-
// determine begin time:
// either from a previews attempt meaning that user hasn't submitted his answers permanently
// and exerciseTimeConstrain hasn't yet passed,
@@ -392,11 +391,18 @@ function unset_exercise_var($exerciseId) {
if (isset($_SESSION['exerciseUserRecordID'][$exerciseId][$attempt_value]) || isset($paused_attempt)) {
$eurid = isset($paused_attempt) ? $_SESSION['exerciseUserRecordID'][$exerciseId][$attempt_value] = $paused_attempt->eurid : $_SESSION['exerciseUserRecordID'][$exerciseId][$attempt_value];
- $recordStartDate = Database::get()->querySingle("SELECT record_start_date FROM exercise_user_record WHERE eurid = ?d", $eurid)->record_start_date;
- $recordStartDate = strtotime($recordStartDate);
- // if exerciseTimeConstrain has not passed yet calculate the remaining time
- if ($exerciseTimeConstraint > 0) {
- $timeleft = isset($paused_attempt) ? $paused_attempt->secs_remaining : ($exerciseTimeConstraint * 60) - ($temp_CurrentDate - $recordStartDate);
+ $record = Database::get()->querySingle("SELECT record_start_date, record_end_date, secs_remaining FROM exercise_user_record WHERE eurid = ?d", $eurid);
+ $recordStartDate = strtotime($record->record_start_date);
+ if (isset($paused_attempt) and $paused_attempt->secs_remaining) {
+ // resume paused attempt with same time left
+ $timeleft = $paused_attempt->secs_remaining;
+ } elseif ($record->record_end_date and $record->secs_remaining) {
+ // navigation within exercise: subtract time from last submission timestamp
+ $recordEndDate = strtotime($record->record_end_date);
+ $timeleft = $record->secs_remaining - ($temp_CurrentDate - $recordEndDate);
+ } elseif ($exerciseTimeConstraint > 0) {
+ // if exerciseTimeConstrain has not passed yet calculate the remaining time
+ $timeleft = $exerciseTimeConstraint * 60 - ($temp_CurrentDate - $recordStartDate);
}
} elseif (!isset($_SESSION['exerciseUserRecordID'][$exerciseId][$attempt_value]) && $nbrQuestions > 0) {
$attempt = Database::get()->querySingle("SELECT COUNT(*) AS count FROM exercise_user_record WHERE eid = ?d AND uid= ?d", $exerciseId, $uid)->count;
@@ -457,8 +463,8 @@ function unset_exercise_var($exerciseId) {
$exerciseTimeLeft = $exercise_EndDate->getTimestamp() - $temp_CurrentDate;
if ($exerciseTimeLeft) {
if ($exerciseTimeLeft < 0 and $is_editor) {
- // Give editors time to test expired exercises
- $exerciseTimeLeft = 24 * 3600;
+ // Give editors unlimited time to test expired exercises
+ unset($timeleft);
} elseif ($exerciseTimeLeft < 3 * 3600 and (!isset($timeleft) or $exerciseTimeLeft < $timeleft)) {
// Display countdown of exercise remaining time if less than
// user's remaining time or less than 3 hours away
@@ -471,12 +477,9 @@ function unset_exercise_var($exerciseId) {
// if the user has submitted the form
if (isset($_POST['formSent'])) {
$time_expired = false;
- // checking if user's time expired
- if (isset($timeleft)) {
- $timeleft += 1; // Add 1 sec for leniency when submitting
- if ($timeleft < 0) {
- $time_expired = true;
- }
+ // check if user's time expired
+ if (isset($timeleft) and $timeleft <= 0) {
+ $time_expired = true;
}
// insert answers in the database and add them in the $exerciseResult array which is returned
@@ -489,10 +492,8 @@ function unset_exercise_var($exerciseId) {
$_SESSION['exerciseResult'][$exerciseId][$attempt_value] = $exerciseResult;
- // if it is a non-sequential exercise
- // OR the time has expired
- if ($exerciseType == SINGLE_PAGE_TYPE && !isset($_POST['buttonSave']) ||
- ($exerciseType == MULTIPLE_PAGE_TYPE || $exerciseType == ONE_WAY_TYPE) && (isset($_POST['buttonFinish']) || $time_expired)) {
+ // if the user has made a final submission or the time has expired
+ if (isset($_POST['buttonFinish']) or $time_expired) {
if (isset($_POST['secsRemaining'])) {
$secs_remaining = $_POST['secsRemaining'];
} else {
@@ -500,7 +501,6 @@ function unset_exercise_var($exerciseId) {
}
$eurid = $_SESSION['exerciseUserRecordID'][$exerciseId][$attempt_value];
$record_end_date = date('Y-m-d H:i:s', time());
-
$totalScore = $objExercise->calculate_total_score($eurid);
if ($objExercise->isRandom() or $objExercise->hasQuestionListWithRandomCriteria()) {
@@ -580,13 +580,10 @@ function unset_exercise_var($exerciseId) {
}
}
-if (isset($timeleft)) {
+if (isset($timeleft)) { // time remaining
if ($timeleft <= 1) {
$timeleft = 1;
}
-}
-
-if (isset($timeleft)) { // time remaining
$tool_content .= "