summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorprathamesh2018-01-02 22:09:44 +0530
committerprathamesh2018-01-02 22:09:44 +0530
commit44e16651a9f7faec95a32c19738a996a731ae57a (patch)
tree0aa8439547b0f1281ab78964aaf3f7ad176ed6da /yaksh/views.py
parente14514e01052fb36cd9f14675cbe7ca940945a34 (diff)
parente566d54239efcb46f253e324b7295a676378f656 (diff)
downloadonline_test-44e16651a9f7faec95a32c19738a996a731ae57a.tar.gz
online_test-44e16651a9f7faec95a32c19738a996a731ae57a.tar.bz2
online_test-44e16651a9f7faec95a32c19738a996a731ae57a.zip
Merge branch 'master' of https://github.com/FOSSEE/online_test into exercise
Conflicts Resolved: yaksh/templates/yaksh/courses.html yaksh/templates/yaksh/question.html
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index fd07ade..ca22c9a 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -16,7 +16,10 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Group
from django.forms.models import inlineformset_factory
from django.utils import timezone
-from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
+from django.core.validators import URLValidator
+from django.core.exceptions import (
+ MultipleObjectsReturned, ObjectDoesNotExist, ValidationError
+)
from django.conf import settings
import pytz
from taggit.models import Tag
@@ -384,8 +387,10 @@ def prof_manage(request, msg=None):
rights/permissions and log in."""
user = request.user
ci = RequestContext(request)
- if not user.is_authenticated() and not is_moderator(user):
- return my_redirect('/exam/login/')
+ if not user.is_authenticated():
+ return my_redirect('/exam/login')
+ if not is_moderator(user):
+ return my_redirect('/exam/')
courses = Course.objects.filter(creator=user, is_trial=False)
trial_paper = AnswerPaper.objects.filter(
@@ -515,7 +520,7 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None,
)
# allowed to start
if not quest_paper.can_attempt_now(user, course_id):
- msg = "You cannot attempt {0} quiz more than {1} times".format(
+ msg = "You cannot attempt {0} quiz more than {1} time(s)".format(
quest_paper.quiz.description, quest_paper.quiz.attempts_allowed)
if is_moderator(user):
return prof_manage(request, msg=msg)
@@ -715,6 +720,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None,
previous_question=current_question
)
for fname in assignment_filename:
+ fname._name = fname._name.replace(" ","_")
assignment_files = AssignmentUpload.objects.filter(
assignmentQuestion=current_question,
assignmentFile__icontains=fname, user=user,
@@ -724,7 +730,8 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None,
assignmentQuestion=current_question,
assignmentFile__icontains=fname, user=user,
question_paper=questionpaper_id)
- os.remove(assign_file.assignmentFile.path)
+ if os.path.exists(assign_file.assignmentFile.path):
+ os.remove(assign_file.assignmentFile.path)
assign_file.delete()
AssignmentUpload.objects.create(
user=user, assignmentQuestion=current_question,
@@ -1791,7 +1798,7 @@ def test_mode(user, godmode=False, questions_list=None, quiz_id=None,
trial_quiz, questions_list
)
trial_unit, created = LearningUnit.objects.get_or_create(
- order=1, learning_type="quiz", quiz=trial_quiz,
+ order=1, type="quiz", quiz=trial_quiz,
check_prerequisite=False)
module, created = LearningModule.objects.get_or_create(
order=1, creator=user, check_prerequisite=False,
@@ -2357,15 +2364,15 @@ def design_module(request, module_id, course_id=None):
else:
start_val = 1
for order, value in enumerate(add_values, start_val):
- learning_id, learning_type = value.split(":")
- if learning_type == "quiz":
+ learning_id, type = value.split(":")
+ if type == "quiz":
learning_unit = LearningUnit.objects.create(
order=order, quiz_id=learning_id,
- learning_type=learning_type)
+ type=type)
else:
learning_unit = LearningUnit.objects.create(
order=order, lesson_id=learning_id,
- learning_type=learning_type)
+ type=type)
to_add_list.append(learning_unit)
learning_module.learning_unit.add(*to_add_list)
@@ -2530,7 +2537,7 @@ def get_next_unit(request, course_id, module_id, current_unit_id,
# make next available unit as current unit
course_status.current_unit = next_unit
course_status.save()
- if next_unit.learning_type == "quiz":
+ if next_unit.type == "quiz":
return my_redirect("/exam/start/{0}/{1}/{2}".format(
next_unit.quiz.questionpaper_set.get().id, module_id, course_id))
else: