abuse old contest form for exercise view
authorJan Szejko <janek37@gmail.com>
Tue, 27 Nov 2018 12:29:35 +0000 (13:29 +0100)
committerJan Szejko <janek37@gmail.com>
Tue, 27 Nov 2018 12:29:35 +0000 (13:29 +0100)
wtem/templates/wtem/exercises/edumed_wybor.html
wtem/templates/wtem/exercises/exercise_no.html
wtem/templates/wtem/main.html
wtem/views.py

index a41e177..1d23f33 100644 (file)
@@ -21,7 +21,7 @@
             {% for option in exercise.options %}
                 <li class="question-piece" data-name="{{option.id}}">
                     <input type="checkbox" name="e{{no}}_{{option.id}}" id="e{{no}}_{{option.id}}"{% if option.id|stringformat:"s" in exercise.saved_answer.closed_part %} checked="checked"{% endif %}>
-                    <label for="e{{no}}_{{option.id}}">{# if option.id in exercise.answer %}<strong>{% endif #}{{option.text|safe}}{# if option.id in exercise.answer %}</strong>{% endif #}</label>
+                    <label for="e{{no}}_{{option.id}}">{% if show_answers and option.id in exercise.answer %}<strong>{% endif %}{{option.text|safe}}{% if show_answers and option.id in exercise.answer %}</strong>{% endif %}</label>
                 </li>
             {% endfor %}
         </ol>
index 0bd9c6d..7e60a65 100644 (file)
@@ -1,3 +1,3 @@
 {% if not exercise.continuation %}
-    <h3>Zadanie {{ no }}/{{ exercise_count }}{# {{exercise.id_show|default:exercise.id}} #}{# ({{ exercise.max_points }} pkt)#}</h3>
+    <h3>Zadanie {{ no }}{% if exercise_count %}/{{ exercise_count }}{% endif %}{# {{exercise.id_show|default:exercise.id}} #}{# ({{ exercise.max_points }} pkt)#}</h3>
 {% endif %}
\ No newline at end of file
index b38fc57..0289c2c 100644 (file)
@@ -42,6 +42,7 @@
 </style>
 
 <h1>{% include "wtem/title.html" %}</h1>
+{% comment %}
 <div class="wtem-fixed-info">Rozwiązania można wysyłać do godziny {{end_time|default:"11:30"}}. <strong>Nie czekaj na ostatnią chwilę!</strong></div>
 
 <p>Witamy w I etapie Olimpiady Cyfrowej. Na rozwiązanie zadań masz czas do godz. {{end_time|default:"11:30"}}. Test składa się z 30 pytań.</p>
@@ -50,7 +51,7 @@
 
 <p>Powodzenia!<br/>
 Zespół Olimpiady Cyfrowej, fundacja Nowoczesna Polska</p>
-
+{% endcomment %}
 <form method="post" enctype="multipart/form-data">
 
 {% cache 30 wtem %}
@@ -62,6 +63,7 @@ Zespół Olimpiady Cyfrowej, fundacja Nowoczesna Polska</p>
 {% endcache %}
 
 
+{% comment %}
 <hr/>
 <input type="hidden" name="answers" value=""/>
 
@@ -76,7 +78,7 @@ Zespół Olimpiady Cyfrowej, fundacja Nowoczesna Polska</p>
 </p>
 
 <div class="wtem-fixed-info" style="margin-top:15px;">Rozwiązania można wysyłać do godziny {{end_time|default:"11:30"}}. <strong>Nie czekaj na ostatnią chwilę!</strong></div>
-
+{% endcomment %}
 </form>
 
 {% endblock %}
\ No newline at end of file
index 1d1074c..fa327c8 100644 (file)
@@ -70,9 +70,8 @@ def form_after(request, submission_id, key):
 @csrf_exempt
 def form_during(request, key):
 
-    if CompetitionState.get_state() != CompetitionState.DURING:
-        if request.META['REMOTE_ADDR'] not in getattr(settings, 'WTEM_CONTEST_IP_ALLOW', []):
-            return HttpResponseForbidden('Not allowed')
+    if request.META['REMOTE_ADDR'] not in getattr(settings, 'WTEM_CONTEST_IP_ALLOW', []):
+        return HttpResponseForbidden('Not allowed')
 
     try:
         submission = Submission.objects.get(key=key)
@@ -94,7 +93,11 @@ def form_during(request, key):
             for field in exercise['fields']:
                 field['saved_answer'] = field_answers.get(field['id'], '')
     if request.method == 'GET':
-        return render(request, 'wtem/main.html', {'exercises': exercises_with_answers, 'end_time': submission.end_time})
+        return render(request, 'wtem/main.html', {
+            'exercises': exercises_with_answers,
+            'end_time': submission.end_time,
+            'show_answers': True,
+        })
     elif request.method == 'POST':
         form = WTEMForm(request.POST, request.FILES, instance=submission)
         if form.is_valid():