diff options
author | adityacp | 2018-05-24 12:37:54 +0530 |
---|---|---|
committer | adityacp | 2018-06-07 14:50:47 +0530 |
commit | 0adb0d3b79980544bb5a724ce3b106dbd8e01c9c (patch) | |
tree | 624a5947dc960a0283b606c244aeb470e94c3a57 /yaksh | |
parent | 97b657edc2a323f832c81f0e34ce5761bd21f7e9 (diff) | |
download | online_test-0adb0d3b79980544bb5a724ce3b106dbd8e01c9c.tar.gz online_test-0adb0d3b79980544bb5a724ce3b106dbd8e01c9c.tar.bz2 online_test-0adb0d3b79980544bb5a724ce3b106dbd8e01c9c.zip |
Further pep8 changes
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/admin.py | 1 | ||||
-rw-r--r-- | yaksh/cpp_code_evaluator.py | 4 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_grader_evaluation.py | 1 | ||||
-rw-r--r-- | yaksh/java_code_evaluator.py | 4 | ||||
-rw-r--r-- | yaksh/java_stdio_evaluator.py | 2 | ||||
-rw-r--r-- | yaksh/models.py | 2 | ||||
-rw-r--r-- | yaksh/test_models.py | 6 | ||||
-rw-r--r-- | yaksh/urls.py | 63 | ||||
-rw-r--r-- | yaksh/views.py | 17 |
9 files changed, 51 insertions, 49 deletions
diff --git a/yaksh/admin.py b/yaksh/admin.py index a516b1d..7ea8ed6 100644 --- a/yaksh/admin.py +++ b/yaksh/admin.py @@ -13,6 +13,7 @@ class ProfileAdmin(admin.ModelAdmin): search_fields = ['user__first_name', 'user__last_name', 'user__username', "roll_number", "institute", "department"] + admin.site.register(Profile, ProfileAdmin) admin.site.register(Question) admin.site.register(TestCase) diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py index aab4995..7ab06ec 100644 --- a/yaksh/cpp_code_evaluator.py +++ b/yaksh/cpp_code_evaluator.py @@ -151,7 +151,7 @@ class CppCodeEvaluator(BaseEvaluator): err = "{0} \n {1}".format(err, e.split(":", 1)[1]) else: err = "{0} \n {1}".format(err, e) - except: + except Exception: err = "{0} \n {1}".format(err, main_err) else: err = "Compilation Error:" @@ -162,7 +162,7 @@ class CppCodeEvaluator(BaseEvaluator): err = "{0} \n {1}".format(err, e.split(":", 1)[1]) else: err = "{0} \n {1}".format(err, e) - except: + except Exception: err = "{0} \n {1}".format(err, stdnt_stderr) return success, err, mark_fraction diff --git a/yaksh/evaluator_tests/test_grader_evaluation.py b/yaksh/evaluator_tests/test_grader_evaluation.py index e8b519a..6a05e19 100644 --- a/yaksh/evaluator_tests/test_grader_evaluation.py +++ b/yaksh/evaluator_tests/test_grader_evaluation.py @@ -37,5 +37,6 @@ class RegistryTestCase(unittest.TestCase): def tearDown(self): self.registry_object = None + if __name__ == '__main__': unittest.main() diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py index 55e6c9f..2612509 100644 --- a/yaksh/java_code_evaluator.py +++ b/yaksh/java_code_evaluator.py @@ -158,7 +158,7 @@ class JavaCodeEvaluator(BaseEvaluator): err = err + "\n" + e.split(":", 1)[1] else: err = err + "\n" + e - except: + except Exception: err = err + "\n" + main_err else: err = "Compilation Error:" @@ -169,7 +169,7 @@ class JavaCodeEvaluator(BaseEvaluator): err = err + "\n" + e.split(":", 1)[1] else: err = err + "\n" + e - except: + except Exception: err = err + "\n" + stdnt_stderr return success, err, mark_fraction diff --git a/yaksh/java_stdio_evaluator.py b/yaksh/java_stdio_evaluator.py index 6be7066..0504177 100644 --- a/yaksh/java_stdio_evaluator.py +++ b/yaksh/java_stdio_evaluator.py @@ -84,7 +84,7 @@ class JavaStdIOEvaluator(StdIOEvaluator): err = err + "\n" + e.split(":", 1)[1] else: err = err + "\n" + e - except: + except Exception: err = err + "\n" + stdnt_stderr mark_fraction = 1.0 if self.partial_grading and success else 0.0 return success, err, mark_fraction diff --git a/yaksh/models.py b/yaksh/models.py index 648d0ca..43f39e9 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1035,7 +1035,7 @@ class Question(models.Model): new_test_case.type = test_case_type new_test_case.save() - except: + except Exception: msg = "File not correct." except Exception as exc_msg: msg = "Error Parsing Yaml: {0}".format(exc_msg) diff --git a/yaksh/test_models.py b/yaksh/test_models.py index b30607a..132537d 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -3,9 +3,9 @@ from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\ QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\ StdIOBasedTestCase, FileUpload, McqTestCase, AssignmentUpload,\ LearningModule, LearningUnit, Lesson, LessonFile, CourseStatus -from yaksh.code_server import(ServerPool, - get_result as get_result_from_code_server - ) +from yaksh.code_server import( + ServerPool, get_result as get_result_from_code_server + ) import json import ruamel.yaml as yaml from datetime import datetime, timedelta diff --git a/yaksh/urls.py b/yaksh/urls.py index db2c63b..c559011 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -26,13 +26,15 @@ urlpatterns = [ url(r'^get_result/(?P<uid>\d+)/(?P<course_id>\d+)/(?P<module_id>\d+)/$', views.get_result), url(r'^(?P<q_id>\d+)/check/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',\ - views.check, name="check"), + views.check, name="check"), url(r'^(?P<q_id>\d+)/skip/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', views.skip), url(r'^(?P<q_id>\d+)/skip/(?P<next_q>\d+)/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', views.skip), - url(r'^enroll_request/(?P<course_id>\d+)/$', views.enroll_request, name='enroll_request'), - url(r'^self_enroll/(?P<course_id>\d+)/$', views.self_enroll, name='self_enroll'), + url(r'^enroll_request/(?P<course_id>\d+)/$', views.enroll_request, + name='enroll_request'), + url(r'^self_enroll/(?P<course_id>\d+)/$', views.self_enroll, + name='self_enroll'), url(r'^view_answerpaper/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)$', views.view_answerpaper, name='view_answerpaper'), url(r'^show_lesson/(?P<lesson_id>\d+)/(?P<module_id>\d+)/(?P<course_id>\d+)/$', @@ -50,7 +52,7 @@ urlpatterns = [ url(r'^manage/$', views.prof_manage, name='manage'), url(r'^manage/addquestion/$', views.add_question, name="add_question"), url(r'^manage/addquestion/(?P<question_id>\d+)/$', views.add_question, - name="add_question"), + name="add_question"), url(r'^manage/addquiz/$', views.add_quiz, name='add_quiz'), url(r'^manage/add_exercise/$', views.add_exercise, name='add_exercise'), url(r'^manage/add_exercise/(?P<quiz_id>\d+)/$', views.add_exercise, @@ -63,11 +65,11 @@ urlpatterns = [ views.add_quiz, name='edit_quiz'), url(r'^manage/gradeuser/$', views.grade_user, name="grade_user"), url(r'^manage/gradeuser/(?P<quiz_id>\d+)/(?P<course_id>\d+)/$', - views.grade_user, name="grade_user"), + views.grade_user, name="grade_user"), url(r'^manage/gradeuser/(?P<quiz_id>\d+)/(?P<user_id>\d+)/(?P<course_id>\d+)/$', - views.grade_user, name="grade_user"), + views.grade_user, name="grade_user"), url(r'^manage/gradeuser/(?P<quiz_id>\d+)/(?P<user_id>\d+)/(?P<attempt_number>\d+)/(?P<course_id>\d+)/$', - views.grade_user, name="grade_user"), + views.grade_user, name="grade_user"), url(r'^manage/questions/$', views.show_all_questions, name="show_questions"), url(r'^manage/monitor/$', views.monitor, name="monitor"), url(r'^manage/monitor/(?P<quiz_id>\d+)/(?P<course_id>\d+)/$', @@ -75,8 +77,8 @@ urlpatterns = [ url(r'^manage/user_data/(?P<user_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', views.user_data, name="user_data"), url(r'^manage/user_data/(?P<user_id>\d+)/$', views.user_data), - url(r'^manage/quiz/designquestionpaper/(?P<quiz_id>\d+)/$', views.design_questionpaper, - name='design_questionpaper'), + url(r'^manage/quiz/designquestionpaper/(?P<quiz_id>\d+)/$', + views.design_questionpaper, name='design_questionpaper'), url(r'^manage/designquestionpaper/(?P<quiz_id>\d+)/(?P<questionpaper_id>\d+)/$', views.design_questionpaper, name='designquestionpaper'), url(r'^manage/designquestionpaper/(?P<quiz_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', @@ -91,45 +93,52 @@ urlpatterns = [ views.duplicate_course, name='duplicate_course'), url(r'manage/courses/$', views.courses, name='courses'), url(r'manage/add_course/$', views.add_course, name='add_course'), - url(r'manage/edit_course/(?P<course_id>\d+)$', views.add_course, name='edit_course'), - url(r'manage/course_detail/(?P<course_id>\d+)/$', views.course_detail, name='course_detail'), + url(r'manage/edit_course/(?P<course_id>\d+)$', views.add_course, + name='edit_course'), + url(r'manage/course_detail/(?P<course_id>\d+)/$', views.course_detail, + name='course_detail'), url(r'manage/enroll/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.enroll, - name="enroll_user"), + name="enroll_user"), url(r'manage/enroll/rejected/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.enroll, {'was_rejected': True}), - url(r'manage/upload_users/(?P<course_id>\d+)/$', views.upload_users, name="upload_users"), - url(r'manage/send_mail/(?P<course_id>\d+)/$', views.send_mail, name="send_mail"), + url(r'manage/upload_users/(?P<course_id>\d+)/$', views.upload_users, + name="upload_users"), + url(r'manage/send_mail/(?P<course_id>\d+)/$', views.send_mail, + name="send_mail"), url(r'manage/reject/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.reject, - name="reject_user"), + name="reject_user"), url(r'manage/enrolled/reject/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.reject, {'was_enrolled': True}, name="reject_user"), - url(r'manage/toggle_status/(?P<course_id>\d+)/$', views.toggle_course_status, - name="toggle_course_status"), + url(r'manage/toggle_status/(?P<course_id>\d+)/$', + views.toggle_course_status, name="toggle_course_status"), url(r'^ajax/questions/filter/$', views.ajax_questions_filter, - name="questions_filter"), + name="questions_filter"), url(r'^editprofile/$', views.edit_profile, name='edit_profile'), url(r'^viewprofile/$', views.view_profile, name='view_profile'), - url(r'^manage/enroll/(?P<course_id>\d+)/$', views.enroll, name="enroll_users"), + url(r'^manage/enroll/(?P<course_id>\d+)/$', views.enroll, + name="enroll_users"), url(r'manage/enroll/rejected/(?P<course_id>\d+)/$', views.enroll, {'was_rejected': True}), url(r'manage/enrolled/reject/(?P<course_id>\d+)/$', views.reject, {'was_enrolled': True}, name="reject_users"), url(r'^manage/searchteacher/(?P<course_id>\d+)/$', views.search_teacher), - url(r'^manage/addteacher/(?P<course_id>\d+)/$', views.add_teacher, name='add_teacher'), - url(r'^manage/remove_teachers/(?P<course_id>\d+)/$', views.remove_teachers, name='remove_teacher'), + url(r'^manage/addteacher/(?P<course_id>\d+)/$', views.add_teacher, + name='add_teacher'), + url(r'^manage/remove_teachers/(?P<course_id>\d+)/$', views.remove_teachers, + name='remove_teacher'), url(r'^manage/download_questions/$', views.show_all_questions, - name="show_questions"), + name="show_questions"), url(r'^manage/upload_questions/$', views.show_all_questions, - name="show_questions"), + name="show_questions"), url(r'^manage/grader/$', views.grader, name='grader'), url(r'^manage/regrade/question/(?P<course_id>\d+)/(?P<question_id>\d+)/$', - views.regrade, name='regrade'), + views.regrade, name='regrade'), url(r'^manage/regrade/questionpaper/(?P<course_id>\d+)/(?P<question_id>\d+)/(?P<questionpaper_id>\d+)/$', - views.regrade, name='regrade'), + views.regrade, name='regrade'), url(r'^manage/regrade/answerpaper/(?P<course_id>\d+)/(?P<question_id>\d+)/(?P<answerpaper_id>\d+)/$', - views.regrade, name='regrade'), + views.regrade, name='regrade'), url(r'^manage/regrade/paper/(?P<course_id>\d+)/(?P<answerpaper_id>\d+)/$', - views.regrade, name='regrade'), + views.regrade, name='regrade'), url(r'^manage/(?P<mode>godmode|usermode)/(?P<quiz_id>\d+)/(?P<course_id>\d+)/$', views.test_quiz), url(r'^manage/create_demo_course/$', views.create_demo_course), diff --git a/yaksh/views.py b/yaksh/views.py index 4ea387a..8983070 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1,30 +1,20 @@ -import random -import string import os -from datetime import datetime, timedelta -import collections import csv from django.http import HttpResponse, JsonResponse -from django.core.urlresolvers import reverse from django.contrib.auth import login, logout, authenticate from django.shortcuts import render, get_object_or_404, redirect -from django.template import RequestContext, Context, Template -from django.template.loader import get_template, render_to_string +from django.template import Context, Template from django.http import Http404 -from django.db.models import Sum, Max, Q, F +from django.db.models import Max, Q, F 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.utils import timezone -from django.core.validators import URLValidator from django.core.exceptions import ( - MultipleObjectsReturned, ObjectDoesNotExist, ValidationError + MultipleObjectsReturned, ObjectDoesNotExist ) -from django.conf import settings -import pytz from taggit.models import Tag -from itertools import chain import json import six from textwrap import dedent @@ -89,6 +79,7 @@ def add_to_group(users): if not is_moderator(user): user.groups.add(group) + CSV_FIELDS = ['name', 'username', 'roll_number', 'institute', 'department', 'questions', 'marks_obtained', 'out_of', 'percentage', 'status'] |