First exercise of type przyporzadkuj
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 31 Oct 2013 09:50:33 +0000 (10:50 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 15 Jan 2014 10:18:53 +0000 (11:18 +0100)
edumed/settings.d/50-static.py
wtem/static/wtem/edumed.coffee
wtem/static/wtem/edumed.js
wtem/templates/wtem/exercises/edumed_przyporzadkuj.html [new file with mode: 0644]

index 5b6c079..ce1d1da 100644 (file)
@@ -50,6 +50,7 @@ PIPELINE_JS = {
     },
     'wtem': {
         'source_filenames': (
     },
     'wtem': {
         'source_filenames': (
+            'catalogue/js/jquery-ui-1.10.0.custom.js',
             'wtem/edumed.js',
             'wtem/wtem.js',
         ),
             'wtem/edumed.js',
             'wtem/wtem.js',
         ),
index baae08e..d70ce8a 100644 (file)
@@ -459,6 +459,15 @@ class Przyporzadkuj extends Exercise
         $ph = $pr.find ".placeholder:visible"
         @draggable_move $(qp), $ph.eq(0), @multiple
 
         $ph = $pr.find ".placeholder:visible"
         @draggable_move $(qp), $ph.eq(0), @multiple
 
+  get_answer: (question) ->
+    answer = {}
+    $(".predicate [data-predicate]", question).each (i, subjects) =>
+      predicate = $(subjects).attr('data-predicate')
+      answer[predicate] = []
+      $('.question-piece', subjects).each (i, qpiece) =>
+        $qpiece = $(qpiece)
+        answer[predicate].push($qpiece.attr('data-id'))
+    return answer
 
 
 class PrawdaFalsz extends Exercise
 
 
 class PrawdaFalsz extends Exercise
index 58b5114..2a6ddb0 100644 (file)
       return _results;
     };
 
       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);
     return Przyporzadkuj;
 
   })(Exercise);
diff --git a/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html b/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
new file mode 100644 (file)
index 0000000..85122e0
--- /dev/null
@@ -0,0 +1,44 @@
+<div class="exercise przyporzadkuj" data-type="przyporzadkuj">
+
+    <h3>Zadanie {{no}}</h3>
+    
+    <div class="question" data-no="1">
+
+        <div class="description">
+            <p class="paragraph">
+                {{exercise.description}}
+                <span class="instruction">Przeciągnij odpowiedzi i upuść w wybranym polu.</span>
+            </p>
+        </div>
+
+        <p class="paragraph">{{exercise.buckets_name|default:"kategorie"|capfirst}}:</p>
+
+        <ul class="lista punkt predicate" data-name="kategorie">
+            {% for bucket in exercise.buckets %}
+                <li data-predicate="{{bucket.id}}">
+                    {{bucket.title}}
+                    <ul class="subjects">
+                        <li class="placeholder multiple ui-droppable accepting"></li>
+                    </ul>
+                </li>
+            {% endfor %}
+        </ul>
+        <br class="clr">
+
+        <div class="description">
+            <p class="paragraph">{{exercise.items_name|capfirst}}:</p>
+        </div>
+         
+        <ul class="lista punkt subject" data-target="kategorie">
+            {% for item in exercise.items %}
+                <!-- data-solution set to single bogus value only to indicate that this piece has no multiple solutions, not used otherwise (see: is_multiple in edumed.coffee). -->
+                <li data-solution="1" data-no="{{forloop.counter}}" data-id="{{item.id}}" class="question-piece draggable ui-draggable">{{item.text}}</li>
+            {% endfor %}
+        </ul>
+
+        <br class="clr">
+
+    </div>
+
+</div>
+