summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCruiseDevice2021-02-19 15:05:42 +0530
committerCruiseDevice2021-02-19 15:05:42 +0530
commit9a2717b662c7dd3fca54e8b8f2e526454ad72d83 (patch)
treeeb176072b82cbfd081867b489487f531a8b581d6
parentb2bf7b9fef33d59cd1e55776a51577d66a252322 (diff)
downloadonline_test-9a2717b662c7dd3fca54e8b8f2e526454ad72d83.tar.gz
online_test-9a2717b662c7dd3fca54e8b8f2e526454ad72d83.tar.bz2
online_test-9a2717b662c7dd3fca54e8b8f2e526454ad72d83.zip
Fix upload assignment issue for multiple attempts
-rw-r--r--yaksh/models.py9
-rw-r--r--yaksh/views.py6
2 files changed, 8 insertions, 7 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 11ddf8a..6a745d1 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -122,7 +122,7 @@ MOD_GROUP_NAME = 'moderator'
def get_assignment_dir(instance, filename):
folder_name = instance.course.name.replace(" ", "_")
- sub_folder_name = instance.question_paper.quiz.description.replace(
+ sub_folder_name = instance.answer_paper.question_paper.quiz.description.replace(
" ", "_")
return os.sep.join((folder_name, sub_folder_name, instance.user.username,
str(instance.assignmentQuestion.id),
@@ -2661,9 +2661,10 @@ class AssignmentUploadManager(models.Manager):
class AssignmentUpload(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
assignmentQuestion = models.ForeignKey(Question, on_delete=models.CASCADE)
- assignmentFile = models.FileField(upload_to=get_assignment_dir, max_length=255)
- question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True,
- on_delete=models.CASCADE)
+ assignmentFile = models.FileField(upload_to=get_assignment_dir,
+ max_length=255)
+ answer_paper = models.ForeignKey(AnswerPaper, blank=True, null=True,
+ on_delete=models.CASCADE)
course = models.ForeignKey(Course, null=True, blank=True,
on_delete=models.CASCADE)
objects = AssignmentUploadManager()
diff --git a/yaksh/views.py b/yaksh/views.py
index 1965191..ceebda6 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -722,7 +722,7 @@ def show_question(request, question, paper, error_message=None,
assignmentQuestion_id=question.id,
course_id=course_id,
user=request.user,
- question_paper_id=paper.question_paper_id
+ answer_paper=paper
)
files = FileUpload.objects.filter(question_id=question.id, hide=False)
course = Course.objects.get(id=course_id)
@@ -861,7 +861,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None,
assignment_files = AssignmentUpload.objects.filter(
assignmentQuestion=current_question, course_id=course_id,
assignmentFile__icontains=fname, user=user,
- question_paper=questionpaper_id)
+ answer_paper=paper.id)
if assignment_files.exists():
assign_file = assignment_files.first()
if os.path.exists(assign_file.assignmentFile.path):
@@ -870,7 +870,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None,
AssignmentUpload.objects.create(
user=user, assignmentQuestion=current_question,
course_id=course_id,
- assignmentFile=fname, question_paper_id=questionpaper_id
+ assignmentFile=fname, answer_paper_id=paper.id
)
user_answer = 'ASSIGNMENT UPLOADED'
if not current_question.grade_assignment_upload: