Esempio n. 1
0
def update_minimap(node, current_elements, cur_header, cur_href):
    current_course = node['data']['id']
    try:
        return graph.get_elements(
            graph.learning_path(
                current_course, graph.bfs_tree)), infos[current_course][
                    'name'], infos[current_course]['link'], False, ''
    except Exception as e:
        return current_elements, cur_header, cur_href, True, repr(
            e) + f"There's no course called {current_course}. " + error_message
Esempio n. 2
0
def update_course(n, sub, filters, course, cur_options):
    ctx = dash.callback_context
    if ctx.triggered:
        latest_trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
        try:
            new_graph = graph.learning_path(course, graph.dfs_tree)
            if latest_trigger_id == 'filter_list': # If filter value changes, we change the current graph without recalculating subjects
                return graph.get_elements(new_graph, set(filters)), False, '', cur_options
            
            new_subjects = graph.subjects_in_graph(new_graph)
            options_list = [{'label': sub, 'value': sub} for sub in new_subjects]

            return graph.get_elements(new_graph), False, ' ', options_list
        except Exception as e:
            return [], True, f"There's no course called {course}. "+error_message, cur_options
Esempio n. 3
0
def get_course_path_graph(show_preq=False):
    course_path_graph = cyto.Cytoscape(
        id='course_path_graph',
        layout={'name':'cose'},
        style={
            'width': '100%',
            'height': '650px',
        },
        zoom= 1.2,
        minZoom= 0.3,
        maxZoom= 1.5,
        stylesheet=course_path_stylesheet,
        # If we're asking for the preq graph, use graph.preq_tree instead of graph.dfs_tree
        elements=graph.get_elements(graph.learning_path(
            'comp 302', (graph.preq_tree if show_preq else graph.dfs_tree)))
    )
    return course_path_graph
Esempio n. 4
0
    )
    return course_path_graph

mini_map = cyto.Cytoscape(
    id='mini_map',
    layout={'name': 'concentric', 'equidistant': False,
            'mindNodeSpacing': 10, 'spacingFactor': 1.1},
    style={
        'width': '100%',
        'height': '250px',
    },
    zoom=1.2,
    minZoom=0.5,
    maxZoom=1.5,
    stylesheet=minimap_stylesheet,
    elements=graph.get_elements(graph.learning_path('comp 202', graph.bfs_tree))
)

guide_content=dcc.Markdown(
    """
    * "Overview" shows all courses from the subject you search
    * "Path by course" shows which courses you can take after the course you search
    * You can zoom in/out and drag nodes to change their positions inside the graph
    ---
    * Path mode:
        * "Filters": Filter out subjects you want to ignore
        * "Layout": Change the layout of nodes in the graph
    * Overview mode:
        * The mini-map(only available in overview mode) on the left corner shows which courses are JUST after the one you click
    ---
    For bugs/enhancements: