Beispiel #1
0
 def to_public(self, resource_id):
     result = CommentedMap()
     result['title'] = self.title
     result['description'] = h2m(self.description)
     result['settings'] = CommentedMap()
     result['settings']['quiz_type'] = self.quiz_type
     result['settings']['points_possible'] = self.points_possible
     result['settings']['allowed_attempts'] = self.allowed_attempts
     result['settings']['scoring_policy'] = self.scoring_policy
     result['settings']['secrecy'] = CommentedMap()
     result['settings']['secrecy'][
         'one_question_at_a_time'] = self.one_question_at_a_time
     result['settings']['secrecy']['shuffle_answers'] = self.shuffle_answers
     result['settings']['secrecy']['time_limit'] = self.time_limit
     result['settings']['secrecy']['cant_go_back'] = self.cant_go_back
     result['settings']['secrecy'][
         'show_correct_answers'] = self.show_correct_answers
     result['settings']['secrecy'][
         'show_correct_answers_last_attempt'] = self.show_correct_answers_last_attempt
     result['settings']['secrecy'][
         'show_correct_answers_at'] = self.show_correct_answers_at
     result['settings']['secrecy'][
         'hide_correct_answers_at'] = self.hide_correct_answers_at
     result['settings']['secrecy']['hide_results'] = self.hide_results
     result['settings']['secrecy'][
         'one_time_results'] = self.one_time_results
     result['groups'] = [g.to_public() for g in self.groups]
     result['questions'] = [q.to_public() for q in self.questions]
     return result
Beispiel #2
0
    def to_disk(self, resource_id):
        '''Suitable YAML for yaml.dump'''
        result = CommentedMap()
        result['name'] = self.name
        result['url'] = self.html_url
        result['settings'] = CommentedMap()
        result['settings']['published'] = self.published
        result['settings']['points_possible'] = self.points_possible
        result['settings']['grading_type'] = self.grading_type

        result['settings']['submission'] = CommentedMap()
        if hasattr(self, 'allowed_extensions'):
            result['settings']['submission'][
                'extensions'] = self.allowed_extensions
        result['settings']['submission'][
            'submission_types'] = self.submission_types

        result['settings']['timing'] = CommentedMap()
        result['settings']['timing']['due_at'] = to_friendly_date(self.due_at)
        result['settings']['timing']['unlock_at'] = to_friendly_date(
            self.unlock_at)
        result['settings']['timing']['lock_at'] = to_friendly_date(
            self.lock_at)

        result['settings']['secrecy'] = CommentedMap()
        result['settings']['secrecy'][
            'anonymize_students'] = self.anonymize_students
        result['settings']['secrecy'][
            'anonymous_grading'] = self.anonymous_grading

        result['description'] = h2m(self.description)
        return result
Beispiel #3
0
 def to_disk(self, force=False):
     if self.bank_source and not force:
         return self.question_name
     result = CommentedMap()
     result['question_name'] = self.question_name
     result['question_type'] = self.question_type
     if self.quiz_group_name:
         result['group'] = self.quiz_group_name
     result['question_text'] = h2m(self.question_text)
     result['points_possible'] = self.points_possible
     if self.correct_comments_html:
         result['correct_comments'] = h2m(self.correct_comments_html)
     if self.incorrect_comments_html:
         result['incorrect_comments'] = h2m(self.incorrect_comments_html)
     if self.neutral_comments_html:
         result['neutral_comments'] = h2m(self.neutral_comments_html)
     return result
Beispiel #4
0
 def _parse_html(self):
     if self.text is None:
         return ""
     if self.text == "":
         return ""
     markdown = h2m(self.text)
     #markdown = re.sub(r'\n\s*\n', '\n\n', markdown)
     markdown = markdown.strip() + "\n"
     return markdown
Beispiel #5
0
 def to_public(self, force=False):
     if self.bank_source and not force:
         return self.question_name
     result = CommentedMap()
     result['question_name'] = self.question_name
     result['question_type'] = self.question_type
     result['question_text'] = h2m(self.question_text)
     if self.quiz_group_name:
         result['group'] = self.quiz_group_name
     result['points_possible'] = self.points_possible
     return result
Beispiel #6
0
 def to_disk(self, force=False):
     result = QuizQuestion.to_disk(self, force)
     result["incorrect_matches"] = self.matching_answer_incorrect_matches
     result['answers'] = []
     for answer in self.answers:
         a = CommentedMap()
         a['left'] = answer['left']
         a['right'] = answer['right']
         if 'comments' in answer and answer['comments']:
             a['comment'] = answer['comments']
         elif 'comments_html' in answer and answer['comments_html']:
             a['comment'] = h2m(answer['comments_html'])
         result['answers'].append(a)
     return result
Beispiel #7
0
 def to_disk(self, resource_id):
     '''Suitable YAML for yaml.dump'''
     result = CommentedMap()
     result['title'] = self.title
     result['url'] = self.html_url
     result['description'] = h2m(self.description)
     result['settings'] = CommentedMap()
     result['settings']['published'] = self.published
     result['settings']['quiz_type'] = self.quiz_type
     result['settings']['points_possible'] = self.points_possible
     result['settings']['allowed_attempts'] = self.allowed_attempts
     result['settings']['scoring_policy'] = self.scoring_policy
     result['settings']['timing'] = CommentedMap()
     result['settings']['timing']['due_at'] = to_friendly_date(self.due_at)
     result['settings']['timing']['unlock_at'] = to_friendly_date(
         self.unlock_at)
     result['settings']['timing']['lock_at'] = to_friendly_date(
         self.lock_at)
     result['settings']['secrecy'] = CommentedMap()
     result['settings']['secrecy'][
         'one_question_at_a_time'] = self.one_question_at_a_time
     result['settings']['secrecy']['shuffle_answers'] = self.shuffle_answers
     result['settings']['secrecy']['time_limit'] = self.time_limit
     result['settings']['secrecy']['cant_go_back'] = self.cant_go_back
     result['settings']['secrecy'][
         'show_correct_answers'] = self.show_correct_answers
     result['settings']['secrecy'][
         'show_correct_answers_last_attempt'] = self.show_correct_answers_last_attempt
     result['settings']['secrecy'][
         'show_correct_answers_at'] = self.show_correct_answers_at
     result['settings']['secrecy'][
         'hide_correct_answers_at'] = self.hide_correct_answers_at
     result['settings']['secrecy']['hide_results'] = self.hide_results
     result['settings']['secrecy'][
         'one_time_results'] = self.one_time_results
     if self.access_code:
         result['settings']['secrecy']['access_code'] = self.access_code
     if self.ip_filter:
         result['settings']['secrecy']['ip_filter'] = self.ip_filter
     result['groups'] = [g.to_disk() for g in self.groups]
     result['questions'] = [q.to_disk() for q in self.questions]
     return result
Beispiel #8
0
 def to_disk(self, resource):
     return h2m(self.body)