diff options
author | Prabhu Ramachandran | 2011-11-25 18:48:13 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2011-11-25 18:48:13 +0530 |
commit | fdc531b561565345847812f409ee44af0a784e82 (patch) | |
tree | 447b297d28dccb700dcd244404e6cd748191890d /templates | |
parent | b4023e17d6f97e51ffde740c17d19630b5a9c2d1 (diff) | |
download | online_test-fdc531b561565345847812f409ee44af0a784e82.tar.gz online_test-fdc531b561565345847812f409ee44af0a784e82.tar.bz2 online_test-fdc531b561565345847812f409ee44af0a784e82.zip |
ENH: Adding support for Multiple Choice Questions
Adds simple support for multiple choice questions that are also
auto-checked. Many fixes to the templates and useful feature additions.
This changes the database.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/exam/grade_user.html | 36 | ||||
-rw-r--r-- | templates/exam/monitor.html | 12 | ||||
-rw-r--r-- | templates/exam/question.html | 17 | ||||
-rw-r--r-- | templates/exam/user_data.html | 31 |
4 files changed, 69 insertions, 27 deletions
diff --git a/templates/exam/grade_user.html b/templates/exam/grade_user.html index 2994ee2..2a109af 100644 --- a/templates/exam/grade_user.html +++ b/templates/exam/grade_user.html @@ -35,17 +35,27 @@ Start time: {{ paper.start_time }} <br/> action="{{URL_ROOT}}/exam/grade_user/{{data.user.username}}/" method="post"> {% csrf_token %} {% for question, answers in paper.get_question_answers.items %} -<p><strong> Question: {{ question.id }}. {{ question.summary }} (Points: {{ question.points }})</strong> </p> -{% for answer in answers %} -<pre> -################################################################################ -{{ answer.answer|safe }} -# Autocheck: {{ answer.error }} -</pre> +<p><strong> + <a href="{{URL_ROOT}}/admin/exam/question/{{question.id}}"> + Question: {{ question.id }}. {{ question.summary }} </a> + (Points: {{ question.points }})</strong> </p> +{% if question.type == "mcq" %} +<p> Choices: +{% for option in question.options.strip.splitlines %} {{option}}, {% endfor %} +</p> +<p>Student answer: {{ answers.0|safe }}</p> +{% else %}{# non-mcq questions #} +<pre> +{% for answer in answers %}################################################################################ +{{ answer.answer.strip|safe }} +# Autocheck: {{ answer.error|safe }} +{% endfor %}</pre> +{% endif %} {# if question.type #} +{% with answers|last as answer %} Marks: <input id="q{{ question.id }}" type="text" name="q{{ question.id }}_marks" size="4" value="{{ answer.marks }}" /> -{% endfor %} {# for answer in answers #} +{% endwith %} {% endfor %} {# for question, answers ... #} <h3>Teacher comments: </h3> <textarea id="comments_{{paper.quiz.id}}" rows="10" cols="80" @@ -59,5 +69,15 @@ Marks: <input id="q{{ question.id }}" type="text" {% endif %} {# if data.papers #} +{% if data.papers.count > 1 %} +<a href="{{URL_ROOT}}/exam/monitor/"> + Monitor quiz</a> +{% else %} +{% with data.papers.0 as paper %} +<a href="{{URL_ROOT}}/exam/monitor/{{paper.quiz.id}}/"> + Monitor quiz</a> +{% endwith %} +{% endif %} +<br /> <a href="{{URL_ROOT}}/admin/">Admin</a> {% endblock content %} diff --git a/templates/exam/monitor.html b/templates/exam/monitor.html index a15b2a2..fb6cb58 100644 --- a/templates/exam/monitor.html +++ b/templates/exam/monitor.html @@ -6,7 +6,7 @@ {% block content %} -{% if not quizzes and not papers %} +{% if not quizzes and not quiz %} <h1> Quiz results </h1> <p> No quizzes available. </p> @@ -27,9 +27,9 @@ {# ############################################################### #} {# This is rendered when we are just viewing exam/monitor/quiz_num #} -{% if papers %} +{% if quiz %} <h1> {{ quiz.description }} results </h1> - +{% if papers %} {# <p> Quiz: {{ quiz_name }}</p> #} <p>Number of papers: {{ papers|length }} </p> @@ -57,9 +57,9 @@ </tr> {% endfor %} </table> -{% else %} {% if quiz %} - <p> No answer papers so far. </p> - {% endif %} +{% else %} +<p> No answer papers so far. </p> +{% endif %} {# if papers #} {% endif %} <a href="{{URL_ROOT}}/admin/">Admin</a> diff --git a/templates/exam/question.html b/templates/exam/question.html index f4d3f67..62b8b3d 100644 --- a/templates/exam/question.html +++ b/templates/exam/question.html @@ -60,15 +60,20 @@ function update_time() <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/" method="post"> {% csrf_token %} - -<textarea rows="20" cols="100" name="answer"> -{% if last_attempt %}{{last_attempt}}{% else %}# Enter your answer here.{% endif %} -</textarea> - +{% if question.type == "mcq" %} +{% for option in question.options.strip.splitlines %} +<input name="answer" type="radio" value="{{option}}" />{{option}} <br/> +{% endfor %} +{% else %} +<textarea rows="20" cols="100" name="answer">{% if last_attempt %}{{last_attempt.strip}}{% else %}# Enter your answer here.{% endif %}</textarea> +{% endif %} <br/> - +{% if question.type == "mcq" %} +<input id="check" type="submit" name="check" value="Submit answer"/> +{% else %} <input id="check" type="submit" name="check" value="Check Answer" onclick="submitCode();"/> +{% endif %} <input id="skip" type="submit" name="skip" value="Skip question" /> </form> diff --git a/templates/exam/user_data.html b/templates/exam/user_data.html index 7db0af2..77de5ce 100644 --- a/templates/exam/user_data.html +++ b/templates/exam/user_data.html @@ -41,14 +41,21 @@ User IP address: {{ paper.user_ip }} <h3> Answers </h3> {% for question, answers in paper.get_question_answers.items %} <p><strong> Question: {{ question.id }}. {{ question.summary }} (Points: {{ question.points }})</strong> </p> -{% for answer in answers %} +{% if question.type == "mcq" %} +<p> Choices: +{% for option in question.options.strip.splitlines %} {{option}}, {% endfor %} +</p> +<p>Student answer: {{ answers.0|safe }}</p> +{% else %}{# non-mcq questions #} <pre> -################################################################################ -{{ answer.answer|safe }} -# Autocheck: {{ answer.error }} -# Marks: {{ answer.marks }} -</pre> -{% endfor %} {# for answer in answers #} +{% for answer in answers %}################################################################################ +{{ answer.answer.strip|safe }} +# Autocheck: {{ answer.error|safe }} +{% endfor %}</pre> +{% endif %} +{% with answers|last as answer %} +<p><em>Marks: {{answer.marks}} </em> </p> +{% endwith %} {% endfor %} {# for question, answers ... #} <h3>Teacher comments: </h3> {{ paper.comments|default:"None" }} @@ -62,6 +69,16 @@ User IP address: {{ paper.user_ip }} <a href="{{URL_ROOT}}/exam/grade_user/{{ data.user.username }}/"> Grade/correct paper</a> <br/> +{% if data.papers.count > 1 %} +<a href="{{URL_ROOT}}/exam/monitor/"> + Monitor quiz</a> +{% else %} +{% with data.papers.0 as paper %} +<a href="{{URL_ROOT}}/exam/monitor/{{paper.quiz.id}}/"> + Monitor quiz</a> +{% endwith %} +{% endif %} +<br /> <a href="{{URL_ROOT}}/admin/">Admin</a> {% endblock content %} |