diff options
author | adityacp | 2017-03-15 15:38:01 +0530 |
---|---|---|
committer | adityacp | 2017-03-15 15:38:01 +0530 |
commit | f1eb06d3740eb21558576e5f5489972e45cab038 (patch) | |
tree | fc91cd312ffa9a3754a7e4bfd79e538e9d2b2e63 /yaksh/models.py | |
parent | ce7238aef6d5080d8f7ea79b96c9569bf191f0b8 (diff) | |
download | online_test-f1eb06d3740eb21558576e5f5489972e45cab038.tar.gz online_test-f1eb06d3740eb21558576e5f5489972e45cab038.tar.bz2 online_test-f1eb06d3740eb21558576e5f5489972e45cab038.zip |
Changes in Views and Models
- Add new boolean field in Question model whether to check assignment upload or not
- In views before uploading a assignment file, check if it already exists and delete previous file
- Grade assignment file with hook code
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 398f508..9134663 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, instance.assignmentQuestion.id, filename + str(instance.user.user), 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) @@ -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) |