diff options
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 103504e..4dcd2ec 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -66,7 +66,7 @@ test_status = ( def get_assignment_dir(instance, filename): return os.sep.join(( - instance.user.user.username, str(instance.assignmentQuestion.id), filename + instance.user.username, str(instance.assignmentQuestion.id), filename )) @@ -264,6 +264,9 @@ class Question(models.Model): # Does this question allow partial grading partial_grading = models.BooleanField(default=False) + # Check assignment upload based question + grade_assignment_upload = models.BooleanField(default=False) + def consolidate_answer_data(self, user_answer): question_data = {} metadata = {} @@ -280,9 +283,13 @@ 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] question_data['metadata'] = metadata return json.dumps(question_data) @@ -1138,7 +1145,7 @@ class AnswerPaper(models.Model): if set(user_answer) == set(expected_answers): result['success'] = True result['error'] = ['Correct answer'] - elif question.type == 'code': + elif question.type == 'code' or question.type == "upload": user_dir = self.user.profile.get_user_dir() json_result = code_server.run_code( question.language, json_data, user_dir @@ -1201,7 +1208,7 @@ class AnswerPaper(models.Model): ############################################################################### class AssignmentUpload(models.Model): - user = models.ForeignKey(Profile) + user = models.ForeignKey(User) assignmentQuestion = models.ForeignKey(Question) assignmentFile = models.FileField(upload_to=get_assignment_dir) |