diff options
author | Palaparthy Adityachandra | 2021-03-04 21:35:21 +0530 |
---|---|---|
committer | GitHub | 2021-03-04 21:35:21 +0530 |
commit | 85a2b6b61c74e2ed42d6c78f6b502a3c72dcf9ca (patch) | |
tree | dc8b56154af6981894a798c6f7c209cc90b39191 /yaksh/models.py | |
parent | b2bf7b9fef33d59cd1e55776a51577d66a252322 (diff) | |
parent | 0697dc314471a2bde90d52b1726914c85a360470 (diff) | |
download | online_test-85a2b6b61c74e2ed42d6c78f6b502a3c72dcf9ca.tar.gz online_test-85a2b6b61c74e2ed42d6c78f6b502a3c72dcf9ca.tar.bz2 online_test-85a2b6b61c74e2ed42d6c78f6b502a3c72dcf9ca.zip |
Merge pull request #820 from adityacp/fix_upload_marks
Refactor upload marks for a quiz
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 11ddf8a..77b3684 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -2267,7 +2267,7 @@ class AnswerPaper(models.Model): ans_data = None if not df.empty: ans_data = df.groupby("question_id").tail(1) - for que_summary, que_id in question_ids: + for que_summary, que_id, que_comments in question_ids: if ans_data is not None: ans = ans_data['question_id'].to_list() marks = ans_data['marks'].to_list() @@ -2278,6 +2278,7 @@ class AnswerPaper(models.Model): que_data[que_summary] = 0 else: que_data[que_summary] = 0 + que_data[que_comments] = "NA" return que_data def current_question(self): @@ -2576,25 +2577,17 @@ class AnswerPaper(models.Model): self.user, self.question_paper.quiz.description, question_id ) - return False, msg + 'Question not in the answer paper.' + return False, f'{msg} Question not in the answer paper.' user_answer = self.answers.filter(question=question).last() - if not user_answer: - return False, msg + 'Did not answer.' + if not user_answer or not user_answer.answer: + return False, f'{msg} Did not answer.' if question.type in ['mcc', 'arrange']: try: answer = literal_eval(user_answer.answer) if type(answer) is not list: - return (False, - msg + '{0} answer not a list.'.format( - question.type - ) - ) + return (False, f'{msg} {question.type} answer not a list.') except Exception: - return (False, - msg + '{0} answer submission error'.format( - question.type - ) - ) + return (False, f'{msg} {question.type} answer submission error') else: answer = user_answer.answer json_data = question.consolidate_answer_data(answer) \ |