コード例 #1
0
ファイル: course.py プロジェクト: kq2/Ricin
    def make_canvas_id(self, item, canvas_id_alias):
        item_type = item['item_type']
        if item_type in ('coursepage', 'lecture'):
            title = item['title']
            canvas_id = wiki.get_canvas_wiki_filename(title)

            # handle duplicates (same title)
            if canvas_id in canvas_id_alias:
                repeat = canvas_id_alias[canvas_id] + 1
                canvas_id_alias[canvas_id] = repeat
                canvas_id += '_{}'.format(repeat)
                if repeat == 2:
                    item['title'] = '{} {}'.format(title, 2)
                elif repeat > 2:
                    item['title'] = '{} {}'.format(title[:-2], repeat)
            else:
                canvas_id_alias[canvas_id] = 1

            # return the real canvas_id
            if item_type == 'coursepage':
                return 'wiki_' + canvas_id
            else:
                return '>-' + canvas_id
        else:
            return '{}_{}'.format(item['coursera_id'], self.part)
コード例 #2
0
ファイル: assignment.py プロジェクト: kq2/Ricin
def make_main_file(assignment, canvas_folder, canvas_id, title):
    file_name = wiki.get_canvas_wiki_filename(title)
    file_path = '{}/{}.html'.format(canvas_id, file_name)
    path = '{}/{}'.format(canvas_folder, file_path)
    args = {
        'title': title,
        'description': assignment
    }
    util.write_file(path, peer.ASSIGNMENT.format(**args))
    return file_path
コード例 #3
0
ファイル: peer.py プロジェクト: kq2/Ricin
def make_main_file(course, assignment, canvas_folder, canvas_id, title):
    file_name = wiki.get_canvas_wiki_filename(title)
    make_description_page(course, assignment, canvas_id, title, file_name)
    make_solution_page(course, assignment, canvas_id, title, file_name)

    file_path = "{}/{}.html".format(canvas_id, file_name)
    path = "{}/{}".format(canvas_folder, file_path)

    args = {"title": title, "description": DESCRIPTION.format(file_name)}
    util.write_file(path, ASSIGNMENT.format(**args))
    return file_path