summaryrefslogtreecommitdiff
path: root/js/courses.js
blob: 7bcfc2b24e1fcc6ffcee68a52950e17da23907be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
define(['assert'], function(assert) {
    'use strict';
    // types: bc (bachelor college), major (default), bep
    // (assumption: every course is 5 ECTS and one must do 15 ECTS in a
    // quartile, filling it up with Electives)
    // for new courses without code, use "DS..."
    var courses = [
        // Bachelor college core courses
        { "id": "2WAB0", "name": "Calculus",   "type": "bc", "when": "Y1Q1" },
        { "id": "3NAB0", "name": "Physics",    "type": "bc", "when": "Y1Q2" },
        { "id": "0LEB0", "name": "Modelling",  "type": "bc", "when": "Y1Q3" },
        { "id": "0SAB0", "name": "USE Basics", "type": "bc", "when": "Y1Q4" },
        { "id": "7NXB0", "name": "Design",     "type": "bc", "when": "Y2Q1" },
        // Data Science basic courses
        { "id": "2IP90", "name": "Programming",             "when": "Y1Q1" },
        { "id": "DS001", "name": "Introduction to Data Science",    "when": "Y1Q1" },
        { "id": "2IT60", "name": "Logic and Set Theory",    "when": "Y1Q2" },
        { "id": "2IO80", "name": "DBL Hypermedia",          "when": "Y1Q3" },
        { "id": "2IC60", "name": "Computer networks and security",  "when": "Y1Q4" },
        { "id": "2ID40", "name": "Human Technology Interaction",    "when": "Y1Q4" },
        { "id": "2WF20", "name": "Linear Algebra",          "when": "Y2Q1" },
        { "id": "2IV60", "name": "Computer Graphics",       "when": "Y2Q3" },
        // Advanced courses
        { "id": "2ID50", "name": "Datamodelling and Databases", "when": "Y2Q2" },
        { "id": "2ID60", "name": "Web Technology",              "when": "Y2Q2" },
        { "id": "DS002", "name": "Workflow",                    "when": "Y2Q3" },
        { "id": "2IL50", "name": "Data Structures",             "when": "Y2Q3" },
        { "id": "2IOC0", "name": "DBL Information Systems",     "when": "Y2Q4" },
        { "id": "2DI90", "name": "Probability and Statistics",  "when": "Y2Q4" },
        { "id": "DS003", "name": "Data Visualization",          "when": "Y3Q1" },
        { "id": "2IIC0", "name": "Business Information Systems","when": "Y3Q1" },
        { "id": "2IID0", "name": "Web Analytics",               "when": "Y3Q2" },
        { "id": "2IO90", "name": "DBL Algorithms",              "when": "Y3Q2" },
        { "id": "DS004", "name": "Bachelor End Project",        "when": "Y3Q3,Y3Q4" },
    ];

    function getQuartile(when) {
        var y_q = /^Y([1-3])Q([1-4])$/.exec(when);
        assert(y_q, "Invalid when: " + when);
        var y_i = y_q[1] - 1, q_i = y_q[2] - 1;
        return schedule[y_i][q_i];
    }

    var coursesById = {};

    // 2d array from years to quartiles to courses
    var schedule = [];
    // make an empty schedule
    var years = 3, quartiles = 4;
    for (var i = 0; i < years; i++) {
        schedule[i] = [];
        for (var j = 0; j < quartiles; j++) {
            schedule[i][j] = [];
        }
    }

    // find all courses by ID and fill the schedule
    courses.forEach(function(course) {
        assert (!(course.id in coursesById),
            "Course is already known: " + course.id);
        coursesById[course.id] = course;
        course.when.split(",").forEach(function(when) {
            getQuartile(when).push(course);
        });
    });

    // fill in the remaining time slots
    schedule.forEach(function(year, year_i) {
        year.forEach(function(quartile, quartile_i) {
            while (quartile.length < 3) {
                quartile.push({
                    "id": "",
                    "name": "Elective / USE",
                    "type": "elective",
                    "when": "Y" + (year_i + 1) + "Q" + (quartile_i + 1)
                });
            }
        });
    });

    return {
        "courses": courses,
        "schedule": schedule
    };
});
/*
Packages:
Programming - Linear Algebra - Computer Graphics - Data Visualisation
Programming - Human Technology Interaction - Web Technology - Web Analytics
Programming - Data Structures - DBL Algorithms

Electives and USE:
Year 1 - 2x Elective
Year 2 - 3x Elective/USE
Year 3 - 6x Elective/USE
*/