First exercise of type przyporzadkuj
[edumed.git] / wtem / static / wtem / edumed.js
index f828dec..2a6ddb0 100644 (file)
       });
     };
 
+    Exercise.prototype.get_answers = function() {
+      var answers,
+        _this = this;
+      answers = [];
+      $('.question', this.element).each(function(i, question) {
+        return answers.push(_this.get_answer(question));
+      });
+      return answers;
+    };
+
     Exercise.prototype.get_value_list = function(elem, data_key, numbers) {
       var vl;
       vl = $(elem).attr("data-" + data_key).split(/[ ,]+/).map($.trim);
       });
     };
 
+    Wybor.prototype.get_answer = function(question) {
+      var answer,
+        _this = this;
+      answer = [];
+      $('.question-piece', question).each(function(i, qpiece) {
+        var $qpiece;
+        $qpiece = $(qpiece);
+        if ($("input[type=checkbox],input[type=radio]", qpiece).is(':checked')) {
+          return answer.push($qpiece.attr('data-name'));
+        }
+      });
+      return answer;
+    };
+
     return Wybor;
 
   })(Exercise);
       return _results;
     };
 
+    Przyporzadkuj.prototype.get_answer = function(question) {
+      var answer,
+        _this = this;
+      answer = {};
+      $(".predicate [data-predicate]", question).each(function(i, subjects) {
+        var predicate;
+        predicate = $(subjects).attr('data-predicate');
+        answer[predicate] = [];
+        return $('.question-piece', subjects).each(function(i, qpiece) {
+          var $qpiece;
+          $qpiece = $(qpiece);
+          return answer[predicate].push($qpiece.attr('data-id'));
+        });
+      });
+      return answer;
+    };
+
     return Przyporzadkuj;
 
   })(Exercise);