diff options
author | Prabhu Ramachandran | 2014-06-23 10:34:59 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2014-06-23 10:34:59 +0530 |
commit | fa402a2c9a34a1728f863ddcbab62fa8e030099e (patch) | |
tree | 7e29521a61b1717bb011275c8e38a9ab5d23ac22 /testapp/static | |
parent | e50eb8426d5f22fd35a2575cd3f4617226bc1a01 (diff) | |
parent | c525c8f26b8e926733d5e4e3d415e19250e54e72 (diff) | |
download | online_test-fa402a2c9a34a1728f863ddcbab62fa8e030099e.tar.gz online_test-fa402a2c9a34a1728f863ddcbab62fa8e030099e.tar.bz2 online_test-fa402a2c9a34a1728f863ddcbab62fa8e030099e.zip |
Merge pull request #25 from prathamesh920/question_paper_generator
Question paper generator
Diffstat (limited to 'testapp/static')
-rw-r--r-- | testapp/static/exam/js/add_question.js | 29 | ||||
-rw-r--r-- | testapp/static/exam/js/edit_question.js | 51 |
2 files changed, 68 insertions, 12 deletions
diff --git a/testapp/static/exam/js/add_question.js b/testapp/static/exam/js/add_question.js index ba17492..56fdd1f 100644 --- a/testapp/static/exam/js/add_question.js +++ b/testapp/static/exam/js/add_question.js @@ -135,7 +135,19 @@ function textareaformat() $('#id_snippet').bind('blur', function( event ){ document.getElementById("id_snippet").rows=1; document.getElementById("id_snippet").cols=40; - }); + }); + + + $('#id_type').bind('focus', function(event){ + var type = document.getElementById('id_type'); + type.style.border = '1px solid #ccc'; + }); + + $('#id_language').bind('focus', function(event){ + var language = document.getElementById('id_language'); + language.style.border = '1px solid #ccc'; + }); + $('#id_type').bind('change',function(event){ var value = document.getElementById('id_type').value; if(value == 'mcq') @@ -167,7 +179,20 @@ function textareaformat() function autosubmit() { - if (document.getElementById('id_type').value == 'mcq') + var language = document.getElementById('id_language'); + if(language.value == 'select') + { + language.style.border="solid red"; + return false; + } + var type = document.getElementById('id_type'); + if(type.value == 'select') + { + type.style.border = 'solid red'; + return false; + } + + if (type.value == 'mcq') { var value = document.getElementById('id_options').value; if(value.split('\n').length < 4) diff --git a/testapp/static/exam/js/edit_question.js b/testapp/static/exam/js/edit_question.js index 28d95f9..c5df631 100644 --- a/testapp/static/exam/js/edit_question.js +++ b/testapp/static/exam/js/edit_question.js @@ -120,6 +120,7 @@ function textareaformat() var option = document.getElementsByName('options'); var descriptions = document.getElementsByName('description'); var snippets = document.getElementsByName('snippet'); + var language = document.getElementsByName('language') var type = document.getElementsByName('type'); var tags = document.getElementsByName('tags'); for (var i=0;i<point.length;i++) @@ -130,16 +131,18 @@ function textareaformat() snippets[i].id=snippets[i].id + i; option[i].id=option[i].id + i; type[i].id = type[i].id + i; + language[i].id = language[i].id + i; tags[i].id = tags[i].id + i; } for(var i=0;i<point.length;i++) { var point_id = document.getElementById('id_points'+i); point_id.setAttribute('class','mini-text'); - var tags_id = document.getElementById('id_tags'+i); + var tags_id = document.getElementById('id_tags'+i); tags_id.setAttribute('class','ac_input'); - tags_id.setAttribute('autocomplete','off'); - var type_id = document.getElementById('id_type'+i); + tags_id.setAttribute('autocomplete','off'); + var language_id = document.getElementById('id_language'+i); + var type_id = document.getElementById('id_type'+i); type_id.setAttribute('class','select-type'); type_id.onchange = showOptions; var value = type_id.value; @@ -150,12 +153,21 @@ function textareaformat() test_id.onfocus = gainfocus; test_id.onblur = lostfocus; var snippet_id = document.getElementById('id_snippet'+i); - $(snippet_id).bind('focus',function(event){ + $(snippet_id).bind('focus', function(event){ + console.log("dv") this.rows = 5; }); $(snippet_id).bind('keydown', function (event){ catchTab(snippet_id,event); }); + + $(language_id).bind('focus', function(event){ + this.style.border = '1px solid #ccc'; + }); + $(type_id).bind('focus', function(event){ + this.style.border = '1px solid #ccc'; + }); + var option_id = document.getElementById('id_options' + i); option_id.onfocus = gainfocus; option_id.onblur = lostfocus; @@ -163,13 +175,12 @@ function textareaformat() { document.getElementById('id_options'+i).style.visibility='hidden'; document.getElementById('label_option'+(i+1)).innerHTML = ""; - } document.getElementById('my'+ (i+1)).innerHTML = desc_id.value; - jQuery().ready(function() - { - jQuery("#id_tags" + i).autocomplete("/taggit_autocomplete_modified/json", { multiple: true }); - }); + jQuery().ready(function(){ + jQuery("#id_tags" + i).autocomplete("/taggit_autocomplete_modified/json", { multiple: true }); + }); + } } @@ -199,6 +210,7 @@ function showOptions(e) { document.getElementById('id_options'+no).style.visibility = 'visible'; document.getElementById('label_option'+ (no+1)).innerHTML = "Options : " + document.getElementById('label_option'+ (no+1)).style.fontWeight = 'bold'; } else { @@ -217,14 +229,33 @@ function lostfocus(e) this.rows = 1; } +function changeColor(element) +{ + element.style.border = 'solid red'; +} function autosubmit() { var total_form = document.getElementsByName('summary').length; var empty_options = 0 ; var count_mcq = 0; - + var language; + var type; + for (var i=0;i<total_form;i++) { + language = document.getElementById('id_language'+i); + type = document.getElementById('id_type'+i); + if(language.value == 'select') + { + changeColor(language); + return false; + } + if(type.value == 'select') + { + changeColor(type); + return false; + } + if (document.getElementById('id_type' + i).value != 'mcq') { continue; |