@@ -28,19 +28,20 @@ angular.module('mm.addons.qtype_ddimageortext')
2828 /**
2929 * Check if a response is complete.
3030 *
31- * @param {Object } answers Question answers (without prefix).
32- * @return {Mixed } True if complete, false if not complete, -1 if cannot determine.
31+ * @param {Object } question Question.
32+ * @param {Object } answers Question answers (without prefix).
33+ * @return {Mixed } True if complete, false if not complete, -1 if cannot determine.
3334 */
34- self . isCompleteResponse = function ( answers ) {
35- // An answer is complete if all drop zones have an answer. Since we don't have the list of drop zones
36- // we cannot determine if the answer is complete, only if it's unanswered .
37- var hasReponse = false ;
35+ self . isCompleteResponse = function ( question , answers ) {
36+ // An answer is complete if all drop zones have an answer.
37+ // We should always receive all the drop zones with their value ('' if not answered) .
38+ var isComplete = true ;
3839 angular . forEach ( answers , function ( value ) {
39- if ( value && value ! == '0' ) {
40- hasReponse = true ;
40+ if ( ! value || value = == '0' ) {
41+ isComplete = false ;
4142 }
4243 } ) ;
43- return hasReponse ? - 1 : false ;
44+ return isComplete ;
4445 } ;
4546
4647 /**
@@ -56,10 +57,11 @@ angular.module('mm.addons.qtype_ddimageortext')
5657 * Check if a student has provided enough of an answer for the question to be graded automatically,
5758 * or whether it must be considered aborted.
5859 *
59- * @param {Object } answers Question answers (without prefix).
60- * @return {Mixed } True if gradable, false if not gradable, -1 if cannot determine.
60+ * @param {Object } question Question.
61+ * @param {Object } answers Question answers (without prefix).
62+ * @return {Mixed } True if gradable, false if not gradable, -1 if cannot determine.
6163 */
62- self . isGradableResponse = function ( answers ) {
64+ self . isGradableResponse = function ( question , answers ) {
6365 var hasReponse = false ;
6466 angular . forEach ( answers , function ( value ) {
6567 if ( value && value !== '0' ) {
@@ -72,11 +74,12 @@ angular.module('mm.addons.qtype_ddimageortext')
7274 /**
7375 * Check if two responses are the same.
7476 *
77+ * @param {Object } question Question.
7578 * @param {Object } prevAnswers Previous answers.
7679 * @param {Object } newAnswers New answers.
7780 * @return {Boolean } True if same, false otherwise.
7881 */
79- self . isSameResponse = function ( prevAnswers , newAnswers ) {
82+ self . isSameResponse = function ( question , prevAnswers , newAnswers ) {
8083 return $mmQuestion . compareAllAnswers ( prevAnswers , newAnswers ) ;
8184 } ;
8285
0 commit comments