Exemplo n.º 1
0
def work_type_category(t, lang, sem, category, allcourses):
    # 學士班課程、研究所課程
    data = {}
    # 學院列表
    collages = api.get_college(t, lang, sem, category)

    for collage, collage_name in collages.items():
        data[collage_name] = {}
        logging.debug("Fetch " + collage_name)
        deps = api.get_dep(t, lang, sem, category, collage)

        for dep, dep_name in deps.items():
            data[collage_name][dep_name] = {}
            logging.debug("Fetch " + dep_name)
            grades = api.get_grade(t, lang, sem, category, collage, dep)
            if len(grades) == 0:
                courses = api.get_cos_list(sem, dep)
                allcourses.extend(api.course_pipe(courses))
                courses = api.course_id_pipe(courses)
                data[collage_name][dep_name]['all'] = courses
            else:
                for level in grades:
                    courses = api.get_cos_list(sem, dep, str(level))
                    allcourses.extend(api.course_pipe(courses))
                    courses = api.course_id_pipe(courses)
                    data[collage_name][dep_name][level] = (courses)
    return data
def quiz_methods(quiz_name):
    if request.method == 'GET':
        return api.get_questions(quiz_name)
    elif request.method == 'POST':
        answers = request.get_json()
        return api.get_grade(quiz_name, answers)
    else:
        return "The Quiz API only supports GET and POST requests"
Exemplo n.º 3
0
def quiz_methods(quiz_name):
    if request.method == 'GET':
        return api.get_questions(quiz_name)
    elif request.method == 'POST':
        answers = request.get_json()
        return api.get_grade(quiz_name, answers)
    else:
        return "The Quiz API only supports GET and POST requests"