diff options
author | prathamesh | 2014-06-16 17:04:40 +0530 |
---|---|---|
committer | prathamesh | 2014-06-16 17:04:40 +0530 |
commit | 763f96559bd1827ce87a72708d72efc9361ef588 (patch) | |
tree | b3de9316a59d31c785251c58baecab6c7a068c11 /testapp/static/exam | |
parent | 5adb38569bec47ea0a1ea63e22ceec8906717b04 (diff) | |
download | online_test-763f96559bd1827ce87a72708d72efc9361ef588.tar.gz online_test-763f96559bd1827ce87a72708d72efc9361ef588.tar.bz2 online_test-763f96559bd1827ce87a72708d72efc9361ef588.zip |
Models modified.
QuestionPaper model modified for generating random questions.
Added language field to Question model.
Removed tags from Quiz model.
Template and javascript for Add and Edit questions modified.
Added test cases for models.
Diffstat (limited to 'testapp/static/exam')
-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; |