From c8b68813ca80aee16261e5f02d541ed48712feae Mon Sep 17 00:00:00 2001 From: Hardik Ghaghada Date: Fri, 26 Apr 2013 16:40:34 +0530 Subject: Dumped JS from HTML pages to separate JS files --- testapp/static/exam/js/add_questionpaper.js | 25 ++++++++++++++++++ testapp/static/exam/js/add_quiz.js | 8 ++++++ testapp/static/exam/js/edit_question.js | 13 ++++++++++ testapp/static/exam/js/question.js | 27 ------------------- testapp/templates/exam/add_questionpaper.html | 30 ++-------------------- testapp/templates/exam/add_quiz.html | 12 +-------- .../templates/exam/automatic_questionpaper.html | 18 ++----------- testapp/templates/exam/grade_user.html | 17 ++---------- testapp/templates/exam/manual_questionpaper.html | 16 ++---------- testapp/templates/exam/question.html | 30 +++++++++++++++++++++- 10 files changed, 84 insertions(+), 112 deletions(-) create mode 100644 testapp/static/exam/js/add_questionpaper.js create mode 100644 testapp/static/exam/js/add_quiz.js diff --git a/testapp/static/exam/js/add_questionpaper.js b/testapp/static/exam/js/add_questionpaper.js new file mode 100644 index 0000000..6185dd5 --- /dev/null +++ b/testapp/static/exam/js/add_questionpaper.js @@ -0,0 +1,25 @@ +function load_data() +{ + var url_root = document.getElementById('url_root').value; + var value = document.getElementById('mode').value; + var pathArray = window.location.pathname.split( '/' ); + length = pathArray.length; + var digit = parseInt(pathArray[length-2]); + + if (! isNaN(digit) && value == 'Automatic') + { + window.location = url_root + "/exam/manage/designquestionpaper/automatic/" + digit; + } + else if(!isNaN(digit) && value == 'Manual') + { + window.location = url_root + "/exam/manage/designquestionpaper/manual/" + digit; + } + else if(value == 'Automatic') + { + window.location = window.location.pathname + "automatic"; + } + else if( value == 'Manual') + { + window.location = window.location.pathname + "manual"; + } +} diff --git a/testapp/static/exam/js/add_quiz.js b/testapp/static/exam/js/add_quiz.js new file mode 100644 index 0000000..56b0e95 --- /dev/null +++ b/testapp/static/exam/js/add_quiz.js @@ -0,0 +1,8 @@ +function test() +{ + if (document.getElementById("id_description").value != "") + { + alert("reached condition"); + document.getElementById("submit").innerHTML = "Save"; + } +} diff --git a/testapp/static/exam/js/edit_question.js b/testapp/static/exam/js/edit_question.js index 69e0d97..acba384 100644 --- a/testapp/static/exam/js/edit_question.js +++ b/testapp/static/exam/js/edit_question.js @@ -33,6 +33,19 @@ function decrease(frm,n) } } +function grade_data(showHideDiv) +{ + var ele=document.getElementById(showHideDiv); + if (ele.style.display=="block") + { + ele.style.display = "none"; + } + else + { + ele.style.display = "block"; + } +} + function data(showContent,showHideDiv,a,summary) { diff --git a/testapp/static/exam/js/question.js b/testapp/static/exam/js/question.js index 3078c64..ba3f6d2 100644 --- a/testapp/static/exam/js/question.js +++ b/testapp/static/exam/js/question.js @@ -8,33 +8,6 @@ function submitCode() x.value = "Checking Answer ..."; document.getElementById("skip").disabled = true; } - -function secs_to_time(secs) -{ - var h = Math.floor(secs/3600); - var h_s = (h > 0) ? h+'h:' : ''; - var m = Math.floor((secs%3600)/60); - var m_s = (m > 0) ? m+'m:' : ''; - var s_s = Math.floor(secs%60) + 's'; - return h_s + m_s + s_s; -} - -function update_time() -{ - var time_left = document.getElementById("time").value; - time_left -= 1; - if (time_left) - { - var elem = document.getElementById("time_left"); - var t_str = secs_to_time(time_left); - elem.innerHTML = "" + t_str + ""; - setTimeout("update_time()", 1000); - } - else - { - document.forms["code"].submit(); - } -} function setSelectionRange(input, selectionStart, selectionEnd) { diff --git a/testapp/templates/exam/add_questionpaper.html b/testapp/templates/exam/add_questionpaper.html index 664093c..4cce8a9 100644 --- a/testapp/templates/exam/add_questionpaper.html +++ b/testapp/templates/exam/add_questionpaper.html @@ -10,36 +10,11 @@ {% block script %} - - + {% endblock %} {% block manage %} +
{% csrf_token %} Select mode to design Question Paper: @@ -50,5 +25,4 @@ Select mode to design Question Paper:
- {% endblock %} diff --git a/testapp/templates/exam/add_quiz.html b/testapp/templates/exam/add_quiz.html index 2667c0c..9851584 100644 --- a/testapp/templates/exam/add_quiz.html +++ b/testapp/templates/exam/add_quiz.html @@ -10,17 +10,7 @@ {% block script %} - + {% endblock %} {% block onload %} onload="javascript:test();" {% endblock %} {% block manage %} diff --git a/testapp/templates/exam/automatic_questionpaper.html b/testapp/templates/exam/automatic_questionpaper.html index 7a70748..1175f55 100644 --- a/testapp/templates/exam/automatic_questionpaper.html +++ b/testapp/templates/exam/automatic_questionpaper.html @@ -16,26 +16,12 @@ select {% block script %} - - + {% endblock %} {% block manage %} +
Automatic mode to design the Question Paper

-
{% csrf_token %}
diff --git a/testapp/templates/exam/grade_user.html b/testapp/templates/exam/grade_user.html index 58e118b..ae9274e 100644 --- a/testapp/templates/exam/grade_user.html +++ b/testapp/templates/exam/grade_user.html @@ -9,20 +9,7 @@ {% endblock %} {% block script %} - + {% endblock %} {% block manage %} @@ -59,7 +46,7 @@ Start time: {{ paper.start_time }}

Question: {{ question.id }}. {{ question.summary }} (Points: {{ question.points }}) -Details

+Details