Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions www/addons/mod_quiz/controllers/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,14 @@ angular.module('mm.addons.mod_quiz')
function loadSummary() {
$scope.showSummary = true;
$scope.summaryQuestions = [];

return $mmaModQuiz.getAttemptSummary(attempt.id, $scope.preflightData, offline, true, true).then(function(questions) {
$scope.summaryQuestions = questions;
$scope.canReturn = attempt.state == $mmaModQuiz.ATTEMPT_IN_PROGRESS && !attempt.finishedOffline;
$scope.preventSubmitMessages = $mmaModQuiz.getPreventSubmitMessages(questions);

attempt.dueDateWarning = $mmaModQuiz.getAttemptDueDateWarning(quiz, attempt);

// Remove all answers stored since the questions aren't rendered anymore.
$mmUtil.emptyObject($scope.answers);

// Log summary as viewed.
$mmaModQuiz.logViewAttemptSummary(attempt.id);
}).catch(function(message) {
Expand Down
1 change: 1 addition & 0 deletions www/addons/mod_quiz/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"attemptnumber": "Attempt",
"attemptquiznow": "Attempt quiz now",
"attemptstate": "State",
"cannotsubmitquizdueto": "This quiz cannot be submitted due to the following reasons:",
"comment": "Comment",
"completedon": "Completed on",
"confirmclose": "Once you submit, you will no longer be able to change your answers for this attempt.",
Expand Down
22 changes: 22 additions & 0 deletions www/addons/mod_quiz/services/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,28 @@ angular.module('mm.addons.mod_quiz')
}
};

/**
* Given a list of questions, check if the quiz can be submitted.
* Will return an array with the messages to prevent the submit. Empty array if quiz can be submitted.
*
* @module mm.addons.mod_quiz
* @ngdoc method
* @name $mmaModQuiz#getPreventSubmitMessages
* @param {Object[]} questions Questions.
* @return {String[]} List of prevent submit messages. Empty array if quiz can be submitted.
*/
self.getPreventSubmitMessages = function(questions) {
var messages = [];
angular.forEach(questions, function(question) {
var message = $mmQuestionDelegate.getPreventSubmitMessage(question);
if (message) {
message = $translate.instant(message);
messages.push($translate.instant('mm.question.questionmessage', {$a: question.slot, $b: message}));
}
});
return messages;
};

/**
* Get cache key for Quiz data WS calls.
*
Expand Down
9 changes: 7 additions & 2 deletions www/addons/mod_quiz/templates/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2>{{ 'mma.mod_quiz.summaryofattempt' | translate }}</h2>
<p class="col col-25 text-center">{{ question.number }}</p>
<p class="col col-65 text-center">{{ question.status }}</p>
<p class="col col-10 text-center" ng-if="!quiz.isSequential && canReturn">
<a class="button button-block button-icon ion-ios-arrow-forward" ng-click="loadPage(question.page, false, question.number)" aria-label="{{ 'mma.mod_quiz.questionno' | translate:{$a: question.number} }}"></a>
<a class="button button-block button-icon ion-ios-arrow-forward" ng-click="loadPage(question.page, false, question.slot)" aria-label="{{ 'mma.mod_quiz.questionno' | translate:{$a: question.number} }}"></a>
</p>
</div>
<div class="item" ng-if="canReturn">
Expand All @@ -64,7 +64,12 @@ <h2>{{ 'mma.mod_quiz.summaryofattempt' | translate }}</h2>
{{ attempt.dueDateWarning }}
</div>
<mm-timer ng-if="endTime" class="item item-text-wrap" end-time="endTime" finished="timeUp()" timer-text="{{ 'mma.mod_quiz.timeleft' | translate }}"></mm-timer>
<div class="item" ng-if="!attempt.finishedOffline">
<div class="item item-text-wrap" ng-if="preventSubmitMessages.length">
<p class="item-heading">{{ 'mma.mod_quiz.cannotsubmitquizdueto' | translate }}</p>
<p ng-repeat="message in preventSubmitMessages">{{message}}</p>
<a class="button button-block" ng-href="{{moduleUrl}}" mm-browser>{{ 'mm.core.openinbrowser' | translate }}</a>
</div>
<div class="item" ng-if="!attempt.finishedOffline && !preventSubmitMessages.length">
<a class="button button-block" ng-click="finishAttempt()">{{ 'mma.mod_quiz.submitallandfinish' | translate }}</a>
</div>
</div>
Expand Down
23 changes: 13 additions & 10 deletions www/addons/qtype/calculated/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ angular.module('mm.addons.qtype_calculated')
/**
* Check if a response is complete.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
*/
self.isCompleteResponse = function(answers) {
self.isCompleteResponse = function(question, answers) {
// This question type depends on numerical.
return $mmaQtypeNumericalHandler.isCompleteResponse(answers);
return $mmaQtypeNumericalHandler.isCompleteResponse(question, answers);
};

/**
Expand All @@ -49,24 +50,26 @@ angular.module('mm.addons.qtype_calculated')
* Check if a student has provided enough of an answer for the question to be graded automatically,
* or whether it must be considered aborted.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
*/
self.isGradableResponse = function(answers) {
self.isGradableResponse = function(question, answers) {
// This question type depends on numerical.
return $mmaQtypeNumericalHandler.isGradableResponse(answers);
return $mmaQtypeNumericalHandler.isGradableResponse(question, answers);
};

/**
* Check if two responses are the same.
*
* @param {Object} question Question.
* @param {Object} prevAnswers Previous answers.
* @param {Object} newAnswers New answers.
* @return {Boolean} True if same, false otherwise.
*/
self.isSameResponse = function(prevAnswers, newAnswers) {
self.isSameResponse = function(question, prevAnswers, newAnswers) {
// This question type depends on numerical.
return $mmaQtypeNumericalHandler.isSameResponse(prevAnswers, newAnswers);
return $mmaQtypeNumericalHandler.isSameResponse(question, prevAnswers, newAnswers);
};

/**
Expand Down
17 changes: 10 additions & 7 deletions www/addons/qtype/calculatedmulti/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ angular.module('mm.addons.qtype_calculatedmulti')
/**
* Check if a response is complete.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
*/
self.isCompleteResponse = function(answers) {
self.isCompleteResponse = function(question, answers) {
// This question type depends on multichoice.
return $mmaQtypeMultichoiceHandler.isCompleteResponseSingle(answers);
};
Expand All @@ -49,22 +50,24 @@ angular.module('mm.addons.qtype_calculatedmulti')
* Check if a student has provided enough of an answer for the question to be graded automatically,
* or whether it must be considered aborted.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
*/
self.isGradableResponse = function(answers) {
self.isGradableResponse = function(question, answers) {
// This question type depends on multichoice.
return $mmaQtypeMultichoiceHandler.isGradableResponseSingle(answers);
};

/**
* Check if two responses are the same.
*
* @param {Object} question Question.
* @param {Object} prevAnswers Previous answers.
* @param {Object} newAnswers New answers.
* @return {Boolean} True if same, false otherwise.
*/
self.isSameResponse = function(prevAnswers, newAnswers) {
self.isSameResponse = function(question, prevAnswers, newAnswers) {
// This question type depends on multichoice.
return $mmaQtypeMultichoiceHandler.isSameResponseSingle(prevAnswers, newAnswers);
};
Expand Down
23 changes: 13 additions & 10 deletions www/addons/qtype/calculatedsimple/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ angular.module('mm.addons.qtype_calculatedsimple')
/**
* Check if a response is complete.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
*/
self.isCompleteResponse = function(answers) {
self.isCompleteResponse = function(question, answers) {
// This question type depends on calculated.
return $mmaQtypeCalculatedHandler.isCompleteResponse(answers);
return $mmaQtypeCalculatedHandler.isCompleteResponse(question, answers);
};

/**
Expand All @@ -49,24 +50,26 @@ angular.module('mm.addons.qtype_calculatedsimple')
* Check if a student has provided enough of an answer for the question to be graded automatically,
* or whether it must be considered aborted.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
*/
self.isGradableResponse = function(answers) {
self.isGradableResponse = function(question, answers) {
// This question type depends on calculated.
return $mmaQtypeCalculatedHandler.isGradableResponse(answers);
return $mmaQtypeCalculatedHandler.isGradableResponse(question, answers);
};

/**
* Check if two responses are the same.
*
* @param {Object} question Question.
* @param {Object} prevAnswers Previous answers.
* @param {Object} newAnswers New answers.
* @return {Boolean} True if same, false otherwise.
*/
self.isSameResponse = function(prevAnswers, newAnswers) {
self.isSameResponse = function(question, prevAnswers, newAnswers) {
// This question type depends on calculated.
return $mmaQtypeCalculatedHandler.isSameResponse(prevAnswers, newAnswers);
return $mmaQtypeCalculatedHandler.isSameResponse(question, prevAnswers, newAnswers);
};

/**
Expand Down
29 changes: 16 additions & 13 deletions www/addons/qtype/ddimageortext/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ angular.module('mm.addons.qtype_ddimageortext')
/**
* Check if a response is complete.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
*/
self.isCompleteResponse = function(answers) {
// An answer is complete if all drop zones have an answer. Since we don't have the list of drop zones
// we cannot determine if the answer is complete, only if it's unanswered.
var hasReponse = false;
self.isCompleteResponse = function(question, answers) {
// An answer is complete if all drop zones have an answer.
// We should always receive all the drop zones with their value ('' if not answered).
var isComplete = true;
angular.forEach(answers, function(value) {
if (value && value !== '0') {
hasReponse = true;
if (!value || value === '0') {
isComplete = false;
}
});
return hasReponse ? -1 : false;
return isComplete;
};

/**
Expand All @@ -56,10 +57,11 @@ angular.module('mm.addons.qtype_ddimageortext')
* Check if a student has provided enough of an answer for the question to be graded automatically,
* or whether it must be considered aborted.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
*/
self.isGradableResponse = function(answers) {
self.isGradableResponse = function(question, answers) {
var hasReponse = false;
angular.forEach(answers, function(value) {
if (value && value !== '0') {
Expand All @@ -72,11 +74,12 @@ angular.module('mm.addons.qtype_ddimageortext')
/**
* Check if two responses are the same.
*
* @param {Object} question Question.
* @param {Object} prevAnswers Previous answers.
* @param {Object} newAnswers New answers.
* @return {Boolean} True if same, false otherwise.
*/
self.isSameResponse = function(prevAnswers, newAnswers) {
self.isSameResponse = function(question, prevAnswers, newAnswers) {
return $mmQuestion.compareAllAnswers(prevAnswers, newAnswers);
};

Expand Down
21 changes: 12 additions & 9 deletions www/addons/qtype/ddmarker/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ angular.module('mm.addons.qtype_ddmarker')
/**
* Check if a response is complete.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
*/
self.isCompleteResponse = function(answers) {
// We should always get a value for each dragitem so we can assume we receive all the possible answers.
self.isCompleteResponse = function(question, answers) {
// If 1 dragitem is set we assume the answer is complete (like Moodle does).
var hasReponse = false;
angular.forEach(answers, function(value) {
if (value) {
Expand All @@ -55,21 +56,23 @@ angular.module('mm.addons.qtype_ddmarker')
* Check if a student has provided enough of an answer for the question to be graded automatically,
* or whether it must be considered aborted.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
*/
self.isGradableResponse = function(answers) {
return self.isCompleteResponse(answers);
self.isGradableResponse = function(question, answers) {
return self.isCompleteResponse(question, answers);
};

/**
* Check if two responses are the same.
*
* @param {Object} question Question.
* @param {Object} prevAnswers Previous answers.
* @param {Object} newAnswers New answers.
* @return {Boolean} True if same, false otherwise.
*/
self.isSameResponse = function(prevAnswers, newAnswers) {
self.isSameResponse = function(question, prevAnswers, newAnswers) {
return $mmQuestion.compareAllAnswers(prevAnswers, newAnswers);
};

Expand Down
29 changes: 16 additions & 13 deletions www/addons/qtype/ddwtos/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ angular.module('mm.addons.qtype_ddwtos')
/**
* Check if a response is complete.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if complete, false if not complete, -1 if cannot determine.
*/
self.isCompleteResponse = function(answers) {
// An answer is complete if all drop zones have an answer. Since we don't have the list of drop zones
// we cannot determine if the answer is complete, only if it's unanswered.
var hasReponse = false;
self.isCompleteResponse = function(question, answers) {
// An answer is complete if all drop zones have an answer.
// We should always receive all the drop zones with their value ('0' if not answered).
var isComplete = true;
angular.forEach(answers, function(value) {
if (value && value !== '0') {
hasReponse = true;
if (!value || value === '0') {
isComplete = false;
}
});
return hasReponse ? -1 : false;
return isComplete;
};

/**
Expand All @@ -56,10 +57,11 @@ angular.module('mm.addons.qtype_ddwtos')
* Check if a student has provided enough of an answer for the question to be graded automatically,
* or whether it must be considered aborted.
*
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
* @param {Object} question Question.
* @param {Object} answers Question answers (without prefix).
* @return {Mixed} True if gradable, false if not gradable, -1 if cannot determine.
*/
self.isGradableResponse = function(answers) {
self.isGradableResponse = function(question, answers) {
var hasReponse = false;
angular.forEach(answers, function(value) {
if (value && value !== '0') {
Expand All @@ -72,11 +74,12 @@ angular.module('mm.addons.qtype_ddwtos')
/**
* Check if two responses are the same.
*
* @param {Object} question Question.
* @param {Object} prevAnswers Previous answers.
* @param {Object} newAnswers New answers.
* @return {Boolean} True if same, false otherwise.
*/
self.isSameResponse = function(prevAnswers, newAnswers) {
self.isSameResponse = function(question, prevAnswers, newAnswers) {
return $mmQuestion.compareAllAnswers(prevAnswers, newAnswers);
};

Expand Down
Loading