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
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)
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)
def make_diff_filename(cls, filename): return make_safe_filename(filename) + ".diff.html"
def make_markdown_filename(cls, filename): return make_safe_filename(filename) + ".md"