예제 #1
0
 def decode_question(cls, registry: Registry, question, quiz, args):
     question_type = cls.TYPES[question['question_type']]
     if args.combine:
         raw = question_type.decode_json_raw(registry, question, args)
         raw['text'] = h2m(raw['text'])
         return raw, None, None
     local = registry.get_service(args.local_service, 'local')
     title = question['question_name']
     try:
         destination_path = local.find_existing(registry,
                                                args.title,
                                                folder_file=title)
     except FileNotFoundError:
         destination_path = local.make_markdown_filename(title)
         if args.banks:
             first_bank_path = args.banks[0].format(
                 title=make_safe_filename(title),
                 id=question['id'],
                 quiz_title=make_safe_filename(quiz['title']),
                 quiz_id=quiz['id'])
             destination_path = os.path.join(first_bank_path,
                                             destination_path)
         else:
             first_bank_path = make_safe_filename(quiz['title'])
             if args.destination:
                 destination_path = os.path.join(args.destination,
                                                 first_bank_path,
                                                 destination_path)
             else:
                 destination_path = os.path.join(first_bank_path,
                                                 destination_path)
     decoded_markdown = question_type.decode_json(registry, question, args)
     return title, destination_path, decoded_markdown
예제 #2
0
파일: local.py 프로젝트: acbart/waltz
 def make_markdown_filename(cls,
                            filename,
                            folder_file=None,
                            extension='.md'):
     start = make_safe_filename(filename)
     if folder_file is None:
         return start + extension
     return os.path.join(start, folder_file + extension)
예제 #3
0
파일: resources.py 프로젝트: russross/waltz
 def _get_disk_path(self):
     extension = self.resource_type.extension
     self.filename = make_safe_filename(self.canvas_title)+extension
     print(self.filename)
     self.is_new, self.path = self.resource_type.find_resource_on_disk(self.course.root_directory, self.filename)
예제 #4
0
파일: local.py 프로젝트: acbart/waltz
 def make_diff_filename(cls, filename):
     return make_safe_filename(filename) + ".diff.html"
예제 #5
0
파일: local.py 프로젝트: russross/waltz
 def make_markdown_filename(cls, filename):
     return make_safe_filename(filename) + ".md"