summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2017-03-17 20:47:55 +0530
committeradityacp2017-03-17 20:47:55 +0530
commit5ae3841e4c432d5c0ee378ac9a4142f205b1dbb6 (patch)
treea4148d1d9abd9ddf83dbdab1554fc07947952c12
parent6b4817fb731f9f61114b8395aaccdfd379589e28 (diff)
downloadonline_test-5ae3841e4c432d5c0ee378ac9a4142f205b1dbb6.tar.gz
online_test-5ae3841e4c432d5c0ee378ac9a4142f205b1dbb6.tar.bz2
online_test-5ae3841e4c432d5c0ee378ac9a4142f205b1dbb6.zip
Change consolidate_answer_data to get assignment uploads
-rw-r--r--yaksh/models.py16
-rw-r--r--yaksh/views.py2
2 files changed, 11 insertions, 7 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 4dcd2ec..f6efeba 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -267,7 +267,7 @@ class Question(models.Model):
# Check assignment upload based question
grade_assignment_upload = models.BooleanField(default=False)
- def consolidate_answer_data(self, user_answer):
+ def consolidate_answer_data(self, user_answer, user=None):
question_data = {}
metadata = {}
test_case_data = []
@@ -283,13 +283,16 @@ class Question(models.Model):
metadata['language'] = self.language
metadata['partial_grading'] = self.partial_grading
files = FileUpload.objects.filter(question=self)
- assignment_files = AssignmentUpload.objects.filter()
if files:
metadata['file_paths'] = [(file.file.path, file.extract)
for file in files]
- if assignment_files:
- metadata['assign_files'] = [(file.assignmentFile.path, False)
- for file in assignment_files]
+ if self.type == "upload":
+ assignment_files = AssignmentUpload.objects.filter(
+ assignmentQuestion=self, user=user
+ )
+ if assignment_files:
+ metadata['assign_files'] = [(file.assignmentFile.path, False)
+ for file in assignment_files]
question_data['metadata'] = metadata
return json.dumps(question_data)
@@ -1272,7 +1275,8 @@ class HookTestCase(TestCase):
success - Boolean, indicating if code was executed correctly
mark_fraction - Float, indicating fraction of the
weight to a test case
- error - String, error message if success is false'''
+ error - String, error message if success is false
+ In case of assignment upload there will be no user answer '''
success = False
err = "Incorrect Answer" # Please make this more specific
mark_fraction = 0.0
diff --git a/yaksh/views.py b/yaksh/views.py
index d4d11f5..bd3540d 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -500,7 +500,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
# If we were not skipped, we were asked to check. For any non-mcq
# questions, we obtain the results via XML-RPC with the code executed
# safely in a separate process (the code_server.py) running as nobody.
- json_data = current_question.consolidate_answer_data(user_answer) \
+ json_data = current_question.consolidate_answer_data(user_answer, user) \
if current_question.type == 'code' or \
current_question.type == 'upload' else None
result = paper.validate_answer(user_answer, current_question, json_data)