1 {# {%extends "base.html"%} #} |
1 {# {%extends "base.html"%} #} |
|
2 <script type="text/javascript"> |
|
3 function run_code(params){ |
|
4 |
|
5 if (window.XMLHttpRequest) |
|
6 {// code for IE7+, Firefox, Chrome, Opera, Safari |
|
7 |
|
8 xmlhttp=new XMLHttpRequest(); |
|
9 } |
|
10 else |
|
11 {// code for IE6, IE5 |
|
12 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); |
|
13 } |
|
14 xmlhttp.onreadystatechange=function() |
|
15 { |
|
16 if (xmlhttp.readyState==4 && xmlhttp.status==200) |
|
17 { |
|
18 document.getElementById("code_form").innerHTML=xmlhttp.responseText; |
|
19 } |
|
20 } |
|
21 xmlhttp.open("POST","/run/",true); |
|
22 xmlhttp.send(params); |
|
23 } |
|
24 function process_form(element) { |
|
25 |
|
26 var poststr = "user_code=" + encodeURI( document.getElementById("code-area").value ) + |
|
27 "&problem_id=" + encodeURI( document.getElementById("problem_id").value ); |
|
28 run_code(poststr); |
|
29 } |
|
30 |
|
31 </script> |
2 {%block body%} |
32 {%block body%} |
3 <h2>{{ problem.name }}</h2> |
33 <h2>{{ problem.name }}</h2> |
4 |
34 |
5 |
|
6 {% comment %} |
35 {% comment %} |
7 {% load pykata_extras %} |
36 {% load pykata_extras %} |
8 {% autoescape off %} |
37 {% autoescape off %} |
9 <p> |
38 <p> |
10 {{problem.description|force_escape|spacify_code|linebreaksbr}} |
39 {{problem.description|force_escape|spacify_code|linebreaksbr}} |
11 </p> |
40 </p> |
12 {% endautoescape %} |
41 {% endautoescape %} |
13 {% endcomment %} |
42 {% endcomment %} |
14 |
43 |
15 <h3>Examples</h3> |
|
16 <pre> |
44 <pre> |
17 {{ problem.examples }} |
45 {{ problem.examples }} |
18 </pre> |
46 </pre> |
19 |
47 <div id="code_form"> |
20 <form method="post" action="/run/"> |
48 <form method="post" action="javascript:process_form(document.getElementById('code_form'));"> |
21 <p><strong>Enter your solution here:</strong></p> |
49 <p><strong>Enter your solution here:</strong></p> |
22 <p><textarea id="code-area" name="user_code" rows="22" cols="80"> |
50 <p><textarea id="code-area" name="user_code" rows="22" cols="80"> |
23 {% ifequal pu.classname "ProblemUser" %}{{ pu.solution }}{% else %}{{ problem.skeleton }}{% endifequal %} |
51 {% ifequal pu.classname "ProblemUser" %}{{ pu.solution }}{% else %}{{ problem.skeleton }}{% endifequal %} |
24 |
|
25 </textarea></p> |
52 </textarea></p> |
26 <input type="hidden" name="problem_id" value="{{ problem.id }}" /> |
53 <input id="problem_id" type="hidden" name="problem_id" value="{{ problem.id }}" /> |
27 <p><input type="submit" name="submit" value="Run" /></p> |
54 <p><input type="submit" name="submit" value="Done" ></p> |
28 </form> |
55 </form> |
29 |
56 </div> |
30 <script language="javascript" type="text/javascript" src="/static/edit_area_full.js"></script> |
57 <script language="javascript" type="text/javascript" src="/static/edit_area_full.js"></script> |
31 <script language="javascript" type="text/javascript"> |
58 <script language="javascript" type="text/javascript"> |
32 editAreaLoader.init({ |
59 editAreaLoader.init({ |
33 id: "code-area", |
60 id: "code-area", |
34 syntax: "python", |
61 syntax: "python", |
35 start_highlight: true, |
62 start_highlight: true, |
36 allow_resize: "both", |
63 allow_resize: "both", |
|
64 cursor_position: "begin", |
37 font_size: 14, |
65 font_size: 14, |
38 toolbar: "new_document, select_font, |, help", |
66 toolbar: "new_document, select_font, |, help", |
39 replace_tab_by_spaces: 4 |
67 replace_tab_by_spaces: 4 |
40 }); |
68 }); |
41 </script> |
69 </script> |
42 {%endblock%} |
70 {%endblock%} |