--- a/question_bank.xml Wed Apr 21 13:21:13 2010 +0530
+++ b/question_bank.xml Wed Apr 21 19:17:47 2010 +0530
@@ -1,91 +1,59 @@
<questionbank>
- <day1quiz1>
-
- <question>
- <description>
- How will you set the x and y axis limits so that the region of interest is in the rectangle $(0, -1.5)$ (left bottom coordinate) and $(2\pi, 1.5)$ (right top coordinate)?
- </description>
- <time_limit>
- 30
- </time_limit>
- <expected_answer>
- xlim\( 0 , 2 \* pi \) [;,\n+] ylim\( -1.5 , 1.5\)
- </expected_answer>
- </question>
+<day1quiz1>
- <question>
- <description>
- If a = [1, 2, 5, 9] then what is the value of a[0:-1]?
- </description>
- <time_limit>
- 30
- </time_limit>
- <expected_answer>
- \[ 1 , 2 , 5 \]
- </expected_answer>
- </question>
+<question>
+<description>
+How will you set the x and y axis limits so that the region of interest is in the rectangle (0, -1.5) and (2\pi, 1.5)?
+</description>
+<time_limit>
+30
+</time_limit>
+<expected_answer>
+xlim \( 0 , 2 \* pi \) [;,\n+] ylim \( -1.5 , 1.5\)
+</expected_answer>
+</question>
- <question>
- <description>
- A sample line from a Comma Separated Values (CSV) file:
- line = "Rossum, Guido, 42, 56, 34, 54"
- What code would you use to separate the line into fields?
- </description>
- <time_limit>
- 30
- </time_limit>
- <expected_answer>
- (line\.split\( ([",']) , \2 \))
- </expected_answer>
- </question>
+<question>
+<description>
+If a = [1, 2, 5, 9] then what is the value of a[0:-1]
+</description>
+<time_limit>
+30
+</time_limit>
+<expected_answer>
+\[ 1 , 2 , 5 \]
+</expected_answer>
+</question>
- <question>
- <description>
- If a = [1, 2, 5, 9] how do you find the length of this list?
- </description>
- <time_limit>
- 30
- </time_limit>
- <expected_answer>
- len\( a \)
- </expected_answer>
- </question>
- <question>
- <description>
- What is the maximum number that can be represented natively in Python.
- </description>
- <time_limit>
- 15
- </time_limit>
- <options>
- Infinite
- 2**32
- </options>
- <expected_answer>
- Infinite
- </expected_answer>
- </question>
+<question>
+<description>
+A sample line from a Comma Separated Values (CSV) file:
+line = "Rossum, Guido, 42, 56, 34, 54"
+What code would you use to separate the line into fields?
+</description>
+<time_limit>
+30
+</time_limit>
+<expected_answer>
+(line\.split \( ([",']) , \2 \))
+</expected_answer>
+</question>
- <question>
- <description>
- There is a bug in this code. What is the bug.
- </description>
- <time_limit>
- 30
- </time_limit>
- <code>
-for i in range(5):
- plot(i,sin(i))
+<question>
+<description>
+If a = [1, 2, 5, 9] how do you find the length of this list?
+</description>
+<time_limit>
+30
+</time_limit>
+<expected_answer>
+len \( a \)
+</expected_answer>
+</question>
- </code>
- <expected_answer>
- plot(i,sin(i))
- </expected_answer>
- </question>
-
- </day1quiz1>
+</day1quiz1>
- <day1quiz2>
+<day1quiz2>
</day1quiz2>
</questionbank>
--- a/quiz/views.py Wed Apr 21 13:21:13 2010 +0530
+++ b/quiz/views.py Wed Apr 21 19:17:47 2010 +0530
@@ -102,7 +102,29 @@
new_quiz.que_remaining = "|".join(available_que_ids)
new_quiz.save()
- return redirect("/quiz/answer/%s"%(new_quiz.key))
+ return redirect("/quiz/intro/%s"%(new_quiz.key))
+
+def quiz_intro(request, quiz_key):
+ """ simply give intro to user
+ if there are questions redirect.
+ else raise Http404
+ """
+
+ user = request.user
+
+ try:
+ event = Event.objects.all()[0]
+ except IndexError:
+ raise Http404
+
+ if event.quiz_status == "00":
+ raise Http404
+
+ try:
+ old_quiz = Quiz.objects.get(event=event,user=user, quiz_num=event.quiz_status)
+ return render_to_response("quiz_intro.html", {"user":user, "quiz":old_quiz})
+ except Quiz.DoesNotExist:
+ raise Http404
def answer(request, quiz_key):
""" see if username and quiz give a proper quiz object
--- a/templates/display_question.html Wed Apr 21 13:21:13 2010 +0530
+++ b/templates/display_question.html Wed Apr 21 19:17:47 2010 +0530
@@ -36,6 +36,7 @@
{% else %}
<textarea name="answer" rows="10" cols="40"></textarea><br />
{% endif %}
- <input type="button" value="Time left: {{question.time_limit}} secs" id="time_left">
+<input type="submit" value="Submit">
</form>
+<input type="button" value="Time left: {{question.time_limit}} secs" id="time_left">
{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/quiz_intro.html Wed Apr 21 19:17:47 2010 +0530
@@ -0,0 +1,44 @@
+{% extends 'base.html' %}
+{% block script %}
+<script language="javascript">
+ var time_left = 300;
+ function dec_counter (){
+ time_left -= 1;
+ if (time_left) {
+ document.getElementById("time_left").value = "Time left: " + time_left + " secs";
+ setTimeout("dec_counter()", 1000);
+ }
+ else {
+ dopost();
+ }
+ }
+ function dopost (){
+ document.getElementById("queform").submit();
+ }
+ setTimeout("dec_counter()", 1000);
+ </script>
+{% endblock %}
+{% block content %}
+Welcome {{user.get_full_name}} <br />
+<br />
+<ul>
+ <li> You are about to start quiz in a while </li>
+ <li> There will be a box (as shown below) where you have to type the answer </li>
+ <li> Please use 4 spaces for indentation </li>
+ <li> Some questions are multiple choice type and hence will have options instead of textbox </li>
+ <br />
+<li> There will be a timer running at the bottom as shown in this page.</li>
+<li> The page will auto submit after the timer runs out </li>
+<li> You can also click the submit button to submit the answer before the timer ends </li>
+<br />
+<li> DO NOT refresh the page after the timer starts. If a question reloads, it is marked as incorrect </li>
+<br />
+The quiz starts after the timer runs out.<br />
+You can click on submit to start the quiz right away.<br />
+All the best.<br /><br />
+Answer:<br />
+<textarea></textarea>
+ <form id="queform" action="/quiz/answer/{{quiz.key}}" method="get">
+ <input type="submit" value="Submit"></form>
+<input type="button" value="Time left: 300 secs" id="time_left">
+{% endblock %}
--- a/urls.py Wed Apr 21 13:21:13 2010 +0530
+++ b/urls.py Wed Apr 21 19:17:47 2010 +0530
@@ -30,6 +30,7 @@
(r'^quiz/open/(\w+)$', event_views.open_quiz),
(r'^quiz/close/(\w+)$', event_views.close_quiz),
(r'^quiz$', quiz_views.start_page),
+ (r'^quiz/intro/(\w+)$', quiz_views.quiz_intro),
(r'^quiz/start/$', quiz_views.start_quiz),
(r'^quiz/answer/(\w+)$', quiz_views.answer),
(r'^quiz/complete/$', quiz_views.quiz_complete),