author | amit@thunder |
Mon, 14 Jun 2010 01:00:59 +0530 | |
changeset 3 | 34d0c21e3352 |
parent 1 | 0eda880b3d25 |
permissions | -rw-r--r-- |
0
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
1 |
{# {%extends "base.html"%} #} |
3
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
2 |
<script type="text/javascript"> |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
3 |
function run_code(params){ |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
4 |
|
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
5 |
if (window.XMLHttpRequest) |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
6 |
{// code for IE7+, Firefox, Chrome, Opera, Safari |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
7 |
|
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
8 |
xmlhttp=new XMLHttpRequest(); |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
9 |
} |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
10 |
else |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
11 |
{// code for IE6, IE5 |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
12 |
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
13 |
} |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
14 |
xmlhttp.onreadystatechange=function() |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
15 |
{ |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
16 |
if (xmlhttp.readyState==4 && xmlhttp.status==200) |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
17 |
{ |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
18 |
document.getElementById("code_form").innerHTML=xmlhttp.responseText; |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
19 |
} |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
20 |
} |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
21 |
xmlhttp.open("POST","/run/",true); |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
22 |
xmlhttp.send(params); |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
23 |
} |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
24 |
function process_form(element) { |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
25 |
|
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
26 |
var poststr = "user_code=" + encodeURI( document.getElementById("code-area").value ) + |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
27 |
"&problem_id=" + encodeURI( document.getElementById("problem_id").value ); |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
28 |
run_code(poststr); |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
29 |
} |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
30 |
|
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
31 |
</script> |
0
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
32 |
{%block body%} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
33 |
<h2>{{ problem.name }}</h2> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
34 |
|
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
35 |
{% comment %} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
36 |
{% load pykata_extras %} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
37 |
{% autoescape off %} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
38 |
<p> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
39 |
{{problem.description|force_escape|spacify_code|linebreaksbr}} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
40 |
</p> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
41 |
{% endautoescape %} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
42 |
{% endcomment %} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
43 |
|
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
44 |
<pre> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
45 |
{{ problem.examples }} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
46 |
</pre> |
3
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
47 |
<div id="code_form"> |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
48 |
<form method="post" action="javascript:process_form(document.getElementById('code_form'));"> |
0
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
49 |
<p><strong>Enter your solution here:</strong></p> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
50 |
<p><textarea id="code-area" name="user_code" rows="22" cols="80"> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
51 |
{% ifequal pu.classname "ProblemUser" %}{{ pu.solution }}{% else %}{{ problem.skeleton }}{% endifequal %} |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
52 |
</textarea></p> |
3
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
53 |
<input id="problem_id" type="hidden" name="problem_id" value="{{ problem.id }}" /> |
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
54 |
<p><input type="submit" name="submit" value="Done" ></p> |
0
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
55 |
</form> |
3
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
56 |
</div> |
0
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
57 |
<script language="javascript" type="text/javascript" src="/static/edit_area_full.js"></script> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
58 |
<script language="javascript" type="text/javascript"> |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
59 |
editAreaLoader.init({ |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
60 |
id: "code-area", |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
61 |
syntax: "python", |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
62 |
start_highlight: true, |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
63 |
allow_resize: "both", |
3
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
64 |
cursor_position: "begin", |
0
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
65 |
font_size: 14, |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
66 |
toolbar: "new_document, select_font, |, help", |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
67 |
replace_tab_by_spaces: 4 |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
68 |
}); |
0b061d58aea3
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff
changeset
|
69 |
</script> |
3
34d0c21e3352
Checking if exam has been previously done by the user or not
amit@thunder
parents:
1
diff
changeset
|
70 |
{%endblock%} |