diff options
-rw-r--r-- | yaksh/models.py | 2 | ||||
-rw-r--r-- | yaksh/static/yaksh/js/question_paper_creation.js | 34 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_quiz.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/design_questionpaper.html | 72 | ||||
-rw-r--r-- | yaksh/views.py | 13 |
5 files changed, 87 insertions, 36 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6542daa..d3d90c9 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1729,7 +1729,7 @@ class QuestionPaper(models.Model): total_marks = models.FloatField(default=0.0, blank=True) # Sequence or Order of fixed questions - fixed_question_order = models.CharField(max_length=255, blank=True) + fixed_question_order = models.TextField(blank=True) # Shuffle testcase order. shuffle_testcases = models.BooleanField("Shuffle testcase for each user", diff --git a/yaksh/static/yaksh/js/question_paper_creation.js b/yaksh/static/yaksh/js/question_paper_creation.js index 9d04728..871d6cc 100644 --- a/yaksh/static/yaksh/js/question_paper_creation.js +++ b/yaksh/static/yaksh/js/question_paper_creation.js @@ -57,7 +57,38 @@ $(document).ready(function(){ $('#design_q').submit(function(eventObj) { $(this).append('<input type="hidden" name="checked_ques" value='+checked_vals+'>'); return true; -}); + }); + + $('#add_checkall').change(function () { + if($(this).prop("checked")) { + $("#fixed-available input:checkbox").each(function(index, element) { + if(isNaN($(this).val())) {return}; + $(this).prop("checked", true); + checked_vals.push(parseInt($(this).val())) + }); + } else { + $("#fixed-available input:checkbox").each(function(index, element){ + $(this).prop('checked', false); + checked_vals.pop(parseInt($(this).val())); + }); + } + }); + + $('#remove_checkall').change(function () { + if($(this).prop("checked")) { + $("#fixed-added input:checkbox").each(function (index, element) { + if(isNaN($(this).val())) { return }; + $(this).prop('checked', true); + checked_vals.push(parseInt($(this).val())); + }); + } else { + $("#fixed-added input:checkbox").each(function (index, element) { + console.log('unchecked'); + $(this).prop('checked', false); + checked_vals.pop(parseInt($(this).val())); + }); + } + }); });//document function append_tag(tag){ @@ -69,3 +100,4 @@ function append_tag(tag){ tag_name.value = tag.value; } } + diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index 55e3bd6..01b6f8c 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -55,7 +55,7 @@ {% if quiz and course_id %} {% if quiz.questionpaper_set.get.id %} <center> - <a href="{% url 'yaksh:designquestionpaper' quiz.id quiz.questionpaper_set.get.id course_id %}" class="btn btn-primary"> + <a href="{% url 'yaksh:designquestionpaper' course_id quiz.id quiz.questionpaper_set.get.id %}" class="btn btn-primary"> <i class="fa fa-edit"></i> Edit Question Paper </a> <a href="{% url 'yaksh:preview_questionpaper' quiz.questionpaper_set.get.id %}" class="btn btn-info" target="_blank"> diff --git a/yaksh/templates/yaksh/design_questionpaper.html b/yaksh/templates/yaksh/design_questionpaper.html index ffbdf5f..fcc3ed5 100644 --- a/yaksh/templates/yaksh/design_questionpaper.html +++ b/yaksh/templates/yaksh/design_questionpaper.html @@ -114,12 +114,47 @@ <div id="fixed-available-wrapper"> <p><u>Select questions to add:</u></p> <div id="fixed-available"> - {% if state == "fixed" or state == "None" %} + {% if questions %} + {% if state == "fixed" or state == "None" %} + <ul class="inputs-list"> + <h5><input id="add_checkall" name="add_checkall" type="checkbox"> Select All </h5> + {% for question in questions %} + <li> + <label> + <input type="checkbox" name="questions" data-qid="{{question.id}}" value={{question.id}}> + <span> + {% if user == question.user %} + <a href="{% url 'yaksh:add_question' question.id %}" target="_blank">{{ question.summary }}</a> + {% else %} + {{question.summary}} + {% endif %} + </span> + <span> {{ question.points }}</span> + </label> + </li> + {% endfor %} + </ul> + {% endif %} + {% endif %} + </div> + </div> + <br /> + <button id="add-fixed" name="add-fixed" class="btn btn-success pull-right" type="submit"> + <i class="fa fa-plus-square"></i> Add to paper + </button> + </div> + <div class="col-md-6"> + <div id="fixed-added-wrapper"> + <p><u>Fixed questions currently in paper:</u></p> + <div id="fixed-added"> + {% if fixed_questions %} <ul class="inputs-list"> - {% for question in questions %} + <h5><input id="remove_checkall" type="checkbox"> Select All </h5> + {% for question in fixed_questions %} <li> <label> - <input type="checkbox" name="questions" data-qid="{{question.id}}" value={{question.id}}> + <input type="checkbox" name="added-questions" + data-qid="{{question.id}}" value={{question.id}}> <span> {% if user == question.user %} <a href="{% url 'yaksh:add_question' question.id %}" target="_blank">{{ question.summary }}</a> @@ -127,7 +162,7 @@ {{question.summary}} {% endif %} </span> - <span> {{ question.points }}</span> + <span> {{ question.points }} </span> </label> </li> {% endfor %} @@ -136,35 +171,6 @@ </div> </div> <br /> - <button id="add-fixed" name="add-fixed" class="btn btn-success pull-right" type="submit"> - <i class="fa fa-plus-square"></i> Add to paper - </button> - </div> - <div class="col-md-6"> - <div id="fixed-added-wrapper"> - <p><u>Fixed questions currently in paper:</u></p> - <div id="fixed-added"> - <ul class="inputs-list"> - {% for question in fixed_questions %} - <li> - <label> - <input type="checkbox" name="added-questions" - data-qid="{{question.id}}" value={{question.id}}> - <span> - {% if user == question.user %} - <a href="{% url 'yaksh:add_question' question.id %}" target="_blank">{{ question.summary }}</a> - {% else %} - {{question.summary}} - {% endif %} - </span> - <span> {{ question.points }} </span> - </label> - </li> - {% endfor %} - </ul> - </div> - </div> - <br /> <button id="remove-fixed" name="remove-fixed" class="btn btn-danger pull-right" type="submit"> <i class="fa fa-minus-square"></i> Remove from paper </button> diff --git a/yaksh/views.py b/yaksh/views.py index 3adb536..a1d4e05 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1444,6 +1444,13 @@ def design_questionpaper(request, course_id, quiz_id, questionpaper_id=None): question_paper.save() question_paper.fixed_questions.add(*questions) messages.success(request, "Questions added successfully") + return redirect( + 'yaksh:designquestionpaper', + course_id=course_id, + quiz_id=quiz_id, + questionpaper_id=questionpaper_id + ) + else: messages.warning(request, "Please select atleast one question") @@ -1462,6 +1469,12 @@ def design_questionpaper(request, course_id, quiz_id, questionpaper_id=None): question_paper.save() question_paper.fixed_questions.remove(*question_ids) messages.success(request, "Questions removed successfully") + return redirect( + 'yaksh:designquestionpaper', + course_id=course_id, + quiz_id=quiz_id, + questionpaper_id=questionpaper_id + ) else: messages.warning(request, "Please select atleast one question") |