summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2018-05-28 12:38:21 +0530
committeradityacp2018-06-07 14:50:47 +0530
commitd0c7f9eb35651fadffb53e32d6baf8a2efb55840 (patch)
treec66695a5579049877630a4d284037d3a35a5c8d5
parenta2769e56ab99427beb196b85bf3fc125ffd9bac2 (diff)
downloadonline_test-d0c7f9eb35651fadffb53e32d6baf8a2efb55840.tar.gz
online_test-d0c7f9eb35651fadffb53e32d6baf8a2efb55840.tar.bz2
online_test-d0c7f9eb35651fadffb53e32d6baf8a2efb55840.zip
One more round of pep8 changes
-rw-r--r--yaksh/cpp_stdio_evaluator.py45
-rw-r--r--yaksh/test_models.py2
-rw-r--r--yaksh/urls.py77
3 files changed, 65 insertions, 59 deletions
diff --git a/yaksh/cpp_stdio_evaluator.py b/yaksh/cpp_stdio_evaluator.py
index 51471e1..4e8f8df 100644
--- a/yaksh/cpp_stdio_evaluator.py
+++ b/yaksh/cpp_stdio_evaluator.py
@@ -25,9 +25,14 @@ class CppStdIOEvaluator(StdIOEvaluator):
self.weight = test_case_data.get('weight')
def teardown(self):
- os.remove(self.submit_code_path)
+ if os.path.exists(self.submit_code_path):
+ os.remove(self.submit_code_path)
if self.files:
delete_files(self.files)
+ if os.path.exists(self.ref_output_path):
+ os.remove(self.ref_output_path)
+ if os.path.exists(self.user_output_path):
+ os.remove(self.user_output_path)
def set_file_paths(self):
user_output_path = os.getcwd() + '/output_file'
@@ -77,31 +82,17 @@ class CppStdIOEvaluator(StdIOEvaluator):
if stdnt_stderr == '':
proc, main_out, main_err = self.compiled_test_code
main_err = self._remove_null_substitute_char(main_err)
- if main_err == '':
- proc = subprocess.Popen("./executable",
- shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- preexec_fn=os.setpgrp
- )
- success, err = self.evaluate_stdio(self.user_answer, proc,
- self.expected_input,
- self.expected_output
- )
- os.remove(self.ref_output_path)
- else:
- err = "Error:"
- try:
- error_lines = main_err.splitlines()
- for e in error_lines:
- if ':' in e:
- err = err + "\n" + e.split(":", 1)[1]
- else:
- err = err + "\n" + e
- except:
- err = err + "\n" + main_err
- os.remove(self.user_output_path)
+ proc = subprocess.Popen("./executable",
+ shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ preexec_fn=os.setpgrp
+ )
+ success, err = self.evaluate_stdio(self.user_answer, proc,
+ self.expected_input,
+ self.expected_output
+ )
else:
err = "Compilation Error:"
try:
@@ -111,7 +102,7 @@ class CppStdIOEvaluator(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/test_models.py b/yaksh/test_models.py
index 210456f..eaf5bbc 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -3,7 +3,7 @@ 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(
+from yaksh.code_server import (
ServerPool, get_result as get_result_from_code_server
)
import json
diff --git a/yaksh/urls.py b/yaksh/urls.py
index c559011..1e1def6 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -12,24 +12,27 @@ urlpatterns = [
url(r'^quizzes/(?P<enrolled>\w+)/$', views.quizlist_user,
name='quizlist_user'),
url(r'^results/$', views.results_user),
- url(r'^start/(?P<questionpaper_id>\d+)/(?P<module_id>\d+)/(?P<course_id>\d+)/$',
- views.start),
- url(r'^start/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',
- views.start),
- url(r'^quit/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',
- views.quit),
+ url(r'^start/(?P<questionpaper_id>\d+)/(?P<module_id>\d+)/'
+ '(?P<course_id>\d+)/$', views.start),
+ url(r'^start/(?P<attempt_num>\d+)/(?P<module_id>\d+)/'
+ '(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', views.start),
+ url(r'^quit/(?P<attempt_num>\d+)/(?P<module_id>\d+)/'
+ '(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', views.quit),
url(r'^complete/$', views.complete),
- url(r'^complete/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',\
- views.complete),
+ url(r'^complete/(?P<attempt_num>\d+)/(?P<module_id>\d+)/'
+ '(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$', views.complete),
url(r'^register/$', views.user_register, name="register"),
url(r'^(?P<q_id>\d+)/check/$', views.check, name="check"),
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+)/$',\
+ 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"),
- url(r'^(?P<q_id>\d+)/skip/(?P<attempt_num>\d+)/(?P<module_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',
+ 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+)/$',
+ 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'),
@@ -37,15 +40,16 @@ urlpatterns = [
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+)/$',
- views.show_lesson, name='show_lesson'),
+ url(r'^show_lesson/(?P<lesson_id>\d+)/(?P<module_id>\d+)/'
+ '(?P<course_id>\d+)/$', views.show_lesson, name='show_lesson'),
url(r'^quizzes/view_module/(?P<module_id>\d+)/(?P<course_id>\d+)/$',
views.view_module, name='view_module'),
- url(r'^next_unit/(?P<course_id>\d+)/(?P<module_id>\d+)/(?P<current_unit_id>\d+)/$',
- views.get_next_unit, name='next_unit'),
+ url(r'^next_unit/(?P<course_id>\d+)/(?P<module_id>\d+)/'
+ '(?P<current_unit_id>\d+)/$', views.get_next_unit, name='next_unit'),
url(r'^next_unit/(?P<course_id>\d+)/(?P<module_id>\d+)/$',
views.get_next_unit, name='next_unit'),
- url(r'^next_unit/(?P<course_id>\d+)/(?P<module_id>\d+)/(?P<current_unit_id>\d+)/(?P<first_unit>\d+)/$',
+ url(r'^next_unit/(?P<course_id>\d+)/(?P<module_id>\d+)/'
+ '(?P<current_unit_id>\d+)/(?P<first_unit>\d+)/$',
views.get_next_unit, name='next_unit'),
url(r'^course_modules/(?P<course_id>\d+)/$',
views.course_modules, name='course_modules'),
@@ -66,26 +70,34 @@ urlpatterns = [
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"),
- url(r'^manage/gradeuser/(?P<quiz_id>\d+)/(?P<user_id>\d+)/(?P<course_id>\d+)/$',
+ url(r'^manage/gradeuser/(?P<quiz_id>\d+)/(?P<user_id>\d+)/'
+ '(?P<course_id>\d+)/$',
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+)/$',
+ 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"),
- url(r'^manage/questions/$', views.show_all_questions, name="show_questions"),
+ 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+)/$',
views.monitor, name="monitor"),
- url(r'^manage/user_data/(?P<user_id>\d+)/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',
+ 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/designquestionpaper/(?P<quiz_id>\d+)/(?P<questionpaper_id>\d+)/$',
+ 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+)/$',
+ url(r'^manage/designquestionpaper/(?P<quiz_id>\d+)/'
+ '(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',
views.design_questionpaper, name='designquestionpaper'),
- url(r'^manage/statistics/question/(?P<questionpaper_id>\d+)/(?P<course_id>\d+)/$',
+ url(r'^manage/statistics/question/(?P<questionpaper_id>\d+)/'
+ '(?P<course_id>\d+)/$',
views.show_statistics, name="show_statistics"),
- url(r'^manage/statistics/question/(?P<questionpaper_id>\d+)/(?P<attempt_number>\d+)/(?P<course_id>\d+)/$',
+ url(r'^manage/statistics/question/(?P<questionpaper_id>\d+)/'
+ '(?P<attempt_number>\d+)/(?P<course_id>\d+)/$',
views.show_statistics, name="show_statistics"),
url(r'^manage/download_quiz_csv/(?P<course_id>\d+)/(?P<quiz_id>\d+)/$',
views.download_quiz_csv, name="download_quiz_csv"),
@@ -133,18 +145,21 @@ urlpatterns = [
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'),
- url(r'^manage/regrade/questionpaper/(?P<course_id>\d+)/(?P<question_id>\d+)/(?P<questionpaper_id>\d+)/$',
+ url(r'^manage/regrade/questionpaper/(?P<course_id>\d+)/'
+ '(?P<question_id>\d+)/(?P<questionpaper_id>\d+)/$',
views.regrade, name='regrade'),
- url(r'^manage/regrade/answerpaper/(?P<course_id>\d+)/(?P<question_id>\d+)/(?P<answerpaper_id>\d+)/$',
+ url(r'^manage/regrade/answerpaper/(?P<course_id>\d+)/'
+ '(?P<question_id>\d+)/(?P<answerpaper_id>\d+)/$',
views.regrade, name='regrade'),
url(r'^manage/regrade/paper/(?P<course_id>\d+)/(?P<answerpaper_id>\d+)/$',
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/(?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),
url(r'^manage/courses/download_course_csv/(?P<course_id>\d+)/$',
views.download_course_csv, name="download_course_csv"),
- url(r'^manage/download/user_assignment/(?P<question_id>\d+)/(?P<user_id>\d+)/(?P<quiz_id>\d+)/$',
+ url(r'^manage/download/user_assignment/(?P<question_id>\d+)/'
+ '(?P<user_id>\d+)/(?P<quiz_id>\d+)/$',
views.download_assignment_file, name="download_user_assignment"),
url(r'^manage/download/quiz_assignments/(?P<quiz_id>\d+)/$',
views.download_assignment_file, name="download_quiz_assignment"),
@@ -160,8 +175,8 @@ urlpatterns = [
views.edit_lesson, name="edit_lesson"),
url(r'^manage/courses/designmodule/(?P<module_id>\d+)/$',
views.design_module, name="design_module"),
- url(r'^manage/courses/designmodule/(?P<module_id>\d+)/(?P<course_id>\d+)/$',
- views.design_module, name="design_module"),
+ url(r'^manage/courses/designmodule/(?P<module_id>\d+)/'
+ '(?P<course_id>\d+)/$', views.design_module, name="design_module"),
url(r'^manage/courses/all_quizzes/$',
views.show_all_quizzes, name="show_all_quizzes"),
url(r'^manage/courses/all_lessons/$',