summaryrefslogtreecommitdiff
path: root/yaksh/static
diff options
context:
space:
mode:
authorprathamesh2016-10-04 16:57:25 +0530
committerprathamesh2016-10-04 16:57:25 +0530
commitc5ae3d4589a71c3f3b9f622c7b67a04277269cde (patch)
tree78bd889cb40f647db6ba152063dce47ae7b8f430 /yaksh/static
parent64bb8507cbfbaf8b4558926a0c3206eb85547ed1 (diff)
downloadonline_test-c5ae3d4589a71c3f3b9f622c7b67a04277269cde.tar.gz
online_test-c5ae3d4589a71c3f3b9f622c7b67a04277269cde.tar.bz2
online_test-c5ae3d4589a71c3f3b9f622c7b67a04277269cde.zip
Edit Question Paper Feature.
Can edit question paper. For creating new and editing existing question paper, same UI and view is used. Ajax previously used for creation is removed. Not necessary as post request handles the same. Removed unnecessary js.
Diffstat (limited to 'yaksh/static')
-rw-r--r--yaksh/static/yaksh/css/question_paper_creation.css12
-rw-r--r--yaksh/static/yaksh/js/question_paper_creation.js218
2 files changed, 18 insertions, 212 deletions
diff --git a/yaksh/static/yaksh/css/question_paper_creation.css b/yaksh/static/yaksh/css/question_paper_creation.css
index c915320..588b65c 100644
--- a/yaksh/static/yaksh/css/question_paper_creation.css
+++ b/yaksh/static/yaksh/css/question_paper_creation.css
@@ -5,9 +5,6 @@ body {
line-height: 18px;
color: #404040;
}
-.clearfix {
- clear: both;
-}
.tabs li {
text-align: center;
width: 33%;
@@ -48,7 +45,7 @@ body {
padding: 7px 0;
border: 2px solid #f5f5f5;
}
-#selectors .span4 {
+#selectors .col-md-6 {
margin-left: 0;
}
#id_question_type {
@@ -57,8 +54,8 @@ body {
#id_marks {
width: 100%;
}
-#fixed-questions .span7 > div,
-#random-questions .span7 > div{
+#fixed-questions .col-md-6 > div,
+#random-questions .col-md-6 > div{
background: #f5f5f5;
height: 200px;
border: 1px solid #333333;
@@ -111,9 +108,6 @@ body {
.red-alert {
border: 2px solid red;
}
-#myModal .qcard .remove{
- display: none;
-}
.well{
padding: 5px;
}
diff --git a/yaksh/static/yaksh/js/question_paper_creation.js b/yaksh/static/yaksh/js/question_paper_creation.js
index a144540..898e491 100644
--- a/yaksh/static/yaksh/js/question_paper_creation.js
+++ b/yaksh/static/yaksh/js/question_paper_creation.js
@@ -1,204 +1,33 @@
$(document).ready(function(){
- /* selectors for the 3 step tabs*/
- $fixed_tab = $("#fixed-tab");
- $random_tab = $("#random-tab");
- $finish_tab = $("#finish-tab");
-
- $question_type = $("#id_question_type");
- $marks = $("#id_marks");
-
- $total_marks = $("#total_marks");
+ $question_type = $('#id_question_type');
+ $qpaper_id = $('#qpaper_id');
+ $marks = $('#id_marks');
+ $show = $('#show');
/* ajax requsts on selectors change */
$question_type.change(function() {
- $.ajax({
- url: "/exam/ajax/questionpaper/marks/",
- type: "POST",
- data: {
- question_type: $question_type.val()
- },
- dataType: "html",
- success: function(output) {
- $marks.html(output);
- }
- });
+ this.form.submit();
});
$marks.change(function() {
- var fixed_question_list = [];
- var fixed_inputs = $("input[name=fixed]");
- var random_question_list = [];
- var random_inputs = $("input[name=random]");
- for(var i = 0; i < fixed_inputs.length; i++){
- fixed_question_list.push($(fixed_inputs[i]).val());
- }
- for(var i = 0; i < random_inputs.length; i++){
- random_question_list.push($(random_inputs[i]).val());
- }
- $.ajax({
- url: "/exam/ajax/questionpaper/questions/",
- type: "POST",
- data: {
- question_type: $question_type.val(),
- marks: $marks.val(),
- fixed_list: fixed_question_list,
- random_list: random_question_list
- },
- dataType: "html",
- success: function(output) {
- if($fixed_tab.hasClass("active")) {
- var questions = $(output).filter("#questions").html();
- $("#fixed-available").html(questions);
- } else if($random_tab.hasClass("active")) {
- var questions = $(output).filter("#questions").html();
- var numbers = $(output).filter("#num").html();
- $("#random-available").html(questions);
- $("#number-wrapper").html(numbers);
- }
- }
- });
- });
-
- /* adding fixed questions */
- $("#add-fixed").click(function(e) {
- var count = 0;
- var selected = [];
- var html = "";
- var $element;
- var total_marks = parseFloat($total_marks.text());
- var marks_per = parseFloat($marks.val())
- $("#fixed-available input:checkbox").each(function(index, element) {
- if($(this).attr("checked")) {
- qid = $(this).attr("data-qid");
- if(!$(this).hasClass("ignore")) {
- selected.push(qid);
- $element = $("<div class='qcard'></div>");
- html += "<li>" + $(this).next().html() + "</li>";
- count++;
- }
- }
- });
- html = "<ul>" + html + "</ul>";
- selected = selected.join(",");
- var $input = $("<input type='hidden'>");
- $input.attr({
- value: selected,
- name: "fixed"
- });
- $remove = $("<a href='#' class='remove' data-num="+count+" data-marks = "+marks_per +">&times;</div>");
- $element.html(count + " question(s) added").append(html).append($input).append($remove);
- $("#fixed-added").prepend($element);
- total_marks = total_marks + count * marks_per;
- $total_marks.text(total_marks)
- e.preventDefault();
- });
-
- /* adding random questions */
- $("#add-random").click(function(e) {
- $numbers = $("#numbers");
- random_number = $numbers.val()
- if($numbers.val()) {
- $numbers.removeClass("red-alert");
- var count = 0;
- var selected = [];
- var html = "";
- var $element;
- var total_marks = parseFloat($total_marks.text());
- var marks_per = parseFloat($marks.val())
- $("#random-available input:checkbox").each(function(index, element) {
- if($(this).attr("checked")) {
- qid = $(this).attr("data-qid");
- if(!$(this).hasClass("ignore")) {
- selected.push(qid);
- $element = $("<div class='qcard'></div>");
- html += "<li>" + $(this).next().html() + "</li>";
- count++;
- }
- }
- });
- html = "<ul>" + html + "</ul>";
- selected = selected.join(",");
- var $input_random = $("<input type='hidden'>");
- $input_random.attr({
- value: selected,
- name: "random"
- });
- var $input_number = $("<input type='hidden'>");
- $input_number.attr({
- value: $numbers.val(),
- name: "number"
- });
- $remove = $("<a href='#' class='remove' data-num="+random_number+" data-marks = "+marks_per +">&times;</div>");
- $element.html(random_number + " question(s) will be selected from " + count + " question(s)").append(html).append($input_random).append($input_number).append($remove);
- $("#random-added").prepend($element);
- total_marks = total_marks + random_number * marks_per;
- $total_marks.text(total_marks)
- } else {
- $numbers.addClass("red-alert");
- }
- e.preventDefault();
- });
-
- /* removing added questions */
- $(".qcard .remove").live("click", function(e) {
- var marks_per = $(this).attr('data-marks');
- var num_question = $(this).attr('data-num');
- var sub_marks = marks_per*num_question;
- var total_marks = parseFloat($total_marks.text());
- total_marks = total_marks - sub_marks;
- $total_marks.text(total_marks);
-
- $(this).parent().slideUp("normal", function(){ $(this).remove(); });
- e.preventDefault();
+ this.form.submit();
});
/* showing/hiding selectors on tab click */
$(".tabs li").click(function() {
if($(this).attr("id") == "finish-tab") {
$("#selectors").hide();
+ $('#is_active').val("finish");
} else {
- $question_type.val('select');
- $marks.val('select')
- $("#selectors").show();
- }
- });
- /* check all questions on checked*/
- $("#checkall").live("click", function(){
- if($(this).attr("checked")) {
- if($("#fixed-tab").hasClass("active")) {
- $("#fixed-available input:checkbox").each(function(index, element) {
- $(this).attr('checked','checked');
- });
+ if($(this).attr("id") == "fixed-tab") {
+ $('#is_active').val("fixed");
}
- else {
- $("#random-available input:checkbox").each(function(index, element) {
- $(this).attr('checked','checked');
- });
+ if($(this).attr("id") == "random-tab") {
+ $('#is_active').val("random");
}
- }
- else {
- if($("#fixed-tab").hasClass("active")) {
- $("#fixed-available input:checkbox").each(function(index, element) {
- $(this).removeAttr('checked');
- });
- }
- else {
- $("#random-available input:checkbox").each(function(index, element) {
- $(this).removeAttr('checked');
- });
- }
- }
- });
-
- /* show preview on preview click */
- $("#preview").click(function(){
- questions = getQuestions()
- if(questions.trim() == ""){
- $('#modal_body').html("No questions selected");
+ $question_type.val('select');
+ $marks.val('select')
+ $("#selectors").show();
}
- else {
- $('#modal_body').html(questions);
- }
- $("#myModal").modal('show');
});
/* tab change on next or previous button click */
@@ -217,21 +46,4 @@ $(document).ready(function(){
$("#random").click();
});
- /* Check at least one question is present before saving */
- $('#save').click(function(){
- questions = getQuestions();
- if(questions.trim() == ""){
- $("#modalSave").modal("show");
- }
- else {
- document.forms["frm"].submit();
- }
- });
-
- /* Fetch selected questions */
- function getQuestions(){
- var fixed_div = $("#fixed-added").html();
- var random_div = $("#random-added").html();
- return fixed_div+random_div;
- }
-}); //document
+});//document