diff options
author | Prabhu Ramachandran | 2017-04-24 13:35:15 +0530 |
---|---|---|
committer | GitHub | 2017-04-24 13:35:15 +0530 |
commit | 7da22eb25f2bd5c0a6c5ba29d1febacb4f03f939 (patch) | |
tree | 8c439f46bf96ce695296527072dfa94c7720a041 /yaksh/models.py | |
parent | 0208f8643a80fbee52ad8ff273bdc459f00d0e89 (diff) | |
parent | 0688e71c1b20d57234ac19473a88cd8419cd8928 (diff) | |
download | online_test-7da22eb25f2bd5c0a6c5ba29d1febacb4f03f939.tar.gz online_test-7da22eb25f2bd5c0a6c5ba29d1febacb4f03f939.tar.bz2 online_test-7da22eb25f2bd5c0a6c5ba29d1febacb4f03f939.zip |
Merge pull request #268 from adityacp/download_assignments
Download assignments
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 802a1fc..6646615 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -79,7 +79,8 @@ test_status = ( def get_assignment_dir(instance, filename): return os.sep.join(( - instance.user.username, str(instance.assignmentQuestion.id), filename + instance.question_paper.quiz.description, instance.user.username, + str(instance.assignmentQuestion.id), filename )) @@ -1305,11 +1306,35 @@ class AnswerPaper(models.Model): .format(u.first_name, u.last_name, q.description) -############################################################################### +################################################################################ +class AssignmentUploadManager(models.Manager): + + def get_assignments(self, qp, que_id=None, user_id=None): + if que_id and user_id: + assignment_files = AssignmentUpload.objects.filter( + assignmentQuestion_id=que_id, user_id=user_id, + question_paper=qp + ) + file_name = User.objects.get(id=user_id).get_full_name() + else: + assignment_files = AssignmentUpload.objects.filter( + question_paper=qp + ) + + file_name = "{0}_Assignment_files".format( + assignment_files[0].question_paper.quiz.description + ) + + return assignment_files, file_name + + +################################################################################ class AssignmentUpload(models.Model): user = models.ForeignKey(User) assignmentQuestion = models.ForeignKey(Question) assignmentFile = models.FileField(upload_to=get_assignment_dir) + question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True) + objects = AssignmentUploadManager() ############################################################################### @@ -1372,7 +1397,9 @@ class HookTestCase(TestCase): mark_fraction - Float, indicating fraction of the weight to a test case 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 |