diff options
Diffstat (limited to 'testapp/exam/static')
-rw-r--r-- | testapp/exam/static/exam/js/question_filter.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testapp/exam/static/exam/js/question_filter.js b/testapp/exam/static/exam/js/question_filter.js new file mode 100644 index 0000000..7dc92a6 --- /dev/null +++ b/testapp/exam/static/exam/js/question_filter.js @@ -0,0 +1,69 @@ +$(document).ready(function(){ + $question_type = $("#id_question_type"); + $marks = $("#id_marks"); + $language = $("#id_language"); + + $question_type.change(function() { + $.ajax({ + url: "/exam/ajax/questions/filter/", + type: "POST", + data: { + question_type: $question_type.val(), + marks: $marks.val(), + language: $language.val() + }, + dataType: "html", + success: function(output) { + var questions = $(output).filter("#questions").html(); + $("#filtered-questions").html(questions); + } + }); + }); + + $language.change(function() { + $.ajax({ + url: "/exam/ajax/questions/filter/", + type: "POST", + data: { + question_type: $question_type.val(), + marks: $marks.val(), + language: $language.val() + }, + dataType: "html", + success: function(output) { + var questions = $(output).filter("#questions").html(); + $("#filtered-questions").html(questions); + } + }); + }); + + $marks.change(function() { + $.ajax({ + url: "/exam/ajax/questions/filter/", + type: "POST", + data: { + question_type: $question_type.val(), + marks: $marks.val(), + language: $language.val() + }, + dataType: "html", + success: function(output) { + var questions = $(output).filter("#questions").html(); + $("#filtered-questions").html(questions); + } + }); + }); + + $("#checkall").live("click", function(){ + if($(this).attr("checked")) { + $("#filtered-questions input:checkbox").each(function(index, element) { + $(this).attr('checked','checked'); + }); + } + else { + $("#filtered_questions input:checkbox").each(function(index, element) { + $(this).removeAttr('checked'); + }); + } + }); +});
\ No newline at end of file |