def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) if not args.hide_answers: result['answers'] = [] for answer in data['answers']: a = CommentedMap() a['text'] = answer['text'] if answer['comments_html']: a['comment'] = h2m(answer['comments_html']) result['answers'].append(a) return result
def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) if not args.hide_answers: result['answers'] = CommentedMap() for answer in data['answers']: blank_id = answer['blank_id'] if blank_id not in result['answers']: result['answers'][blank_id] = [] a = CommentedMap() a['text'] = answer['text'] if 'comments_html' in answer and answer['comments_html']: a['comment'] = h2m(answer['comments_html']) result['answers'][blank_id].append(a) return result
def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) if not args.hide_answers: comments = CommentedMap() for answer in data['answers']: if answer['text'] == 'True': result['answer'] = True if answer['weight'] else False if answer.get('comments_html'): comments['if_true_chosen'] = h2m( answer['comments_html']) elif answer.get('comments_html'): comments['if_false_chosen'] = h2m(answer['comments_html']) if comments and any(comments.values()): result['comments'] = comments return result
def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) result['answers'] = [] for answer in data['answers']: a = CommentedMap() html = h2m(answer['html']) if args.hide_answers: a['possible'] = html else: if answer['weight']: a['correct'] = html else: a['wrong'] = html if answer['comments_html']: a['comment'] = h2m(answer['comments_html']) result['answers'].append(a) return result
def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) if not args.hide_answers: result['answers'] = [] for answer in data['answers']: a = CommentedMap() if answer['numerical_answer_type'] == 'exact_answer': a['exact'] = answer['exact'] a['margin'] = answer['margin'] elif answer['numerical_answer_type'] == 'range_answer': a['start'] = answer['start'] a['end'] = answer['end'] elif answer['numerical_answer_type'] == 'precision_answer': a['precision'] = answer['precision'] a['approximate'] = answer['approximate'] if answer.get('comments_html'): a['comment'] = h2m(answer['comments_html']) result['answers'].append(a) return result
def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) result['answers'] = CommentedMap() for answer in data['answers']: blank_id = answer['blank_id'] if blank_id not in result['answers']: result['answers'][blank_id] = [] a = CommentedMap() text = answer['text'] if args.hide_answers: a['possible'] = text else: if answer['weight']: a['correct'] = text else: a['wrong'] = text if answer['comments_html']: a['comment'] = h2m(answer['comments_html']) result['answers'][blank_id].append(a) return result
def decode_json_raw(cls, registry: Registry, data, args): result = QuizQuestion.decode_question_common(registry, data, args) if args.hide_answers: result['answers'] = CommentedMap() result['answers']['lefts'] = list( sorted(set([answer['left'] for answer in data['answers']]))) result['answers']['rights'] = ( list( sorted(set([answer['right'] for answer in data['answers']]))) + data['matching_answer_incorrect_matches'].split("\n")) else: result['answers'] = [] for answer in data['answers']: a = CommentedMap() a['left'] = answer['left'] a['right'] = answer['right'] if answer.get('comments_html'): a['comment'] = h2m(answer['comments_html']) result['answers'].append(a) result["distractors"] = data[ 'matching_answer_incorrect_matches'].split("\n") return result
def decode_json_raw(cls, registry: Registry, data, args): return QuizQuestion.decode_question_common(registry, data, args)