From c72cf1ec5abe3cb7cadf24dbf69f949a66f8cf4d Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 10 Jan 2017 17:31:20 +0530 Subject: Change views and models to create demo course --- yaksh/models.py | 41 ++++++++++++++++++++++++++++++++++++++++- yaksh/views.py | 7 +++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/yaksh/models.py b/yaksh/models.py index 6ad5eec..fa884b2 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -23,6 +23,7 @@ from os.path import join, abspath, dirname, exists import shutil import zipfile import tempfile +from textwrap import dedent from .file_utils import extract_files, delete_files from yaksh.xmlrpc_clients import code_server from django.conf import settings @@ -66,6 +67,43 @@ test_status = ( ('completed', 'Completed'), ) +instructions_data = dedent("""\ +

+ This examination system has been developed with the intention of + making you learn programming and be assessed in an interactive and + fun manner. You will be presented with a series of programming questions + and problems that you will answer online and get immediate + feedback for. +

+

+ Here are some important instructions and rules that you should + understand carefully.

+ +

+ We hope you enjoy taking this + exam !!! +

+ """) + def get_assignment_dir(instance, filename): return '%s/%s/%s' % (instance.user.user, instance.assignmentQuestion.id, filename) @@ -564,6 +602,7 @@ class Quiz(models.Model): end_date_time=timezone.now() + timedelta(176590), duration=30, active=True, attempts_allowed=-1, + instructions=instructions_data, time_between_attempts=0, description='Yaksh Demo quiz', pass_criteria=0, language='Python', prerequisite=None, @@ -702,7 +741,7 @@ class QuestionPaper(models.Model): def create_demo_quiz_ppr(self, demo_quiz, user): question_paper = QuestionPaper.objects.create(quiz=demo_quiz, - total_marks=7.0, + total_marks=6.0, shuffle_questions=True ) questions = Question.objects.filter(active=True, diff --git a/yaksh/views.py b/yaksh/views.py index 7ecf6aa..a2ad6f2 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -269,7 +269,7 @@ def show_all_questionpapers(request, questionpaper_id=None): @login_required -def prof_manage(request): +def prof_manage(request, msg=None): """Take credentials of the user with professor/moderator rights/permissions and log in.""" user = request.user @@ -303,7 +303,7 @@ def prof_manage(request): temp = paper, answer_papers, users_passed, users_failed users_per_paper.append(temp) context = {'user': user, 'users_per_paper': users_per_paper, - 'trial_paper': trial_paper + 'trial_paper': trial_paper, 'msg': msg } return my_render_to_response('yaksh/moderator_dashboard.html', context, context_instance=ci) return my_redirect('/exam/login/') @@ -1241,8 +1241,7 @@ def create_demo_course(request): msg = "Created Demo course successfully" else: msg = "Demo course already created" - context = {'msg': msg} - return my_render_to_response('manage.html', context, context_instance=ci) + return prof_manage(request, msg) @login_required -- cgit