summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2019-12-27 17:58:09 +0530
committerGitHub2019-12-27 17:58:09 +0530
commit18188766cf1e91fe086ed8bfe2939d836ea92ff7 (patch)
tree34fbf78dd0fb85671746be09008d49dcfb269486 /yaksh/views.py
parentf082788af3c31e0bcc184d184fdedd4e0893136e (diff)
parent28c64f6f1771fe93385e3767d5bee9fe55af8c82 (diff)
downloadonline_test-18188766cf1e91fe086ed8bfe2939d836ea92ff7.tar.gz
online_test-18188766cf1e91fe086ed8bfe2939d836ea92ff7.tar.bz2
online_test-18188766cf1e91fe086ed8bfe2939d836ea92ff7.zip
Merge pull request #635 from ankitjavalkar/maheshgudi-fix_stdio_spacing_error
Allow new line to be added in an stdio testcase
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 0bf91eb..56f1873 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -6,10 +6,12 @@ from django.shortcuts import render, get_object_or_404, redirect
from django.template import Context, Template
from django.http import Http404
from django.db.models import Max, Q, F
+from django.db import models
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Group
from django.forms.models import inlineformset_factory
+from django.forms import fields
from django.utils import timezone
from django.core.exceptions import (
MultipleObjectsReturned, ObjectDoesNotExist
@@ -97,6 +99,13 @@ def get_html_text(md_text):
return Markdown().convert(md_text)
+def formfield_callback(field):
+ if (isinstance(field, models.TextField) and field.name == 'expected_output'
+ or field.name == 'expected_input'):
+ return fields.CharField(strip=False)
+ return field.formfield()
+
+
@email_verified
def index(request, next_url=None):
"""The start page.
@@ -243,8 +252,12 @@ def add_question(request, question_id=None):
file.toggle_hide_status()
formsets = []
for testcase in TestCase.__subclasses__():
- formset = inlineformset_factory(Question, testcase, extra=0,
- fields='__all__')
+
+ formset = inlineformset_factory(
+ Question, testcase, extra=0,
+ fields='__all__',
+ formfield_callback=formfield_callback
+ )
formsets.append(formset(
request.POST, request.FILES, instance=question
)
@@ -929,10 +942,9 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None,
"""Show a page to inform user that the quiz has been completed."""
user = request.user
if questionpaper_id is None:
- message = (
- reason or "An Unexpected Error occurred."
- " Please contact your instructor/administrator."
- )
+ message = reason or ("An Unexpected Error occurred. Please "
+ "contact your instructor/administrator."
+ )
context = {'message': message}
return my_render_to_response(request, 'yaksh/complete.html', context)
else: