summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-03-18 14:58:12 +0100
committerPeter Wu <peter@lekensteyn.nl>2015-03-18 14:58:12 +0100
commit4d2257b890d32677fc6a80152925c9c1b31fc659 (patch)
treeac9af194ca25734af7cb73aa6ec7e51e37411107 /js
parentecb378a433608254fce437a4347d830041ad85cc (diff)
downloadsite-4d2257b890d32677fc6a80152925c9c1b31fc659.tar.gz
Curriculum WIP
Diffstat (limited to 'js')
-rw-r--r--js/assert.js11
-rw-r--r--js/courses.js82
-rw-r--r--js/curriculum.js43
3 files changed, 136 insertions, 0 deletions
diff --git a/js/assert.js b/js/assert.js
new file mode 100644
index 0000000..539e5b0
--- /dev/null
+++ b/js/assert.js
@@ -0,0 +1,11 @@
+define(function() {
+ 'use strict';
+
+ function assert(cond, message) {
+ if (!(cond)) {
+ throw message;
+ }
+ }
+
+ return assert;
+});
diff --git a/js/courses.js b/js/courses.js
new file mode 100644
index 0000000..e63bce3
--- /dev/null
+++ b/js/courses.js
@@ -0,0 +1,82 @@
+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
+ // TODO continue here
+ ];
+
+ 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;
+ getQuartile(course.when).push(course);
+ });
+
+ return {
+ "courses": courses,
+ "schedule": schedule
+ };
+});
+/*
+Advanced courses:
+Year 2- Datamodelling and Databases - Prerequisite: Introduction to Data Science
+Year 2- Web Technology - Prerequisites: Human Technology Interaction & Programming
+Year 2- Workflow - Prerequisite: Introduction to Data Science
+Year 2- Data Structures - Prerequisite: Programming
+Year 2- DBL Information Systems - Prerequisite: Datamodelling and Databases
+Year 2- Probability and Statistics - Prerequisite: Calculus
+Year 3 - Data Visualisation - Prerequisites: Computer Graphics & Linear Algebra & Programming
+Year 3 - Business Information Systems - Prerequisites: Logic and Set Theory & Datamodelling and Databases
+Year 3 - Web Analytics - Prerequisite: Web Technology
+Year 3 - DBL Algorithms - Prerequisite: Data Structures
+
+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
+*/
diff --git a/js/curriculum.js b/js/curriculum.js
new file mode 100644
index 0000000..f6d6b35
--- /dev/null
+++ b/js/curriculum.js
@@ -0,0 +1,43 @@
+define(['courses'], function(courses) {
+ 'use strict';
+
+ function makeCoursesList(courseCallback) {
+ var years_list = document.createElement('ul');
+ years_list.className = 'year';
+ // courses.schedule[YEAR][quartile][coursesIdx]
+ courses.schedule.forEach(function(year) {
+ var year_item = document.createElement('li');
+ years_list.appendChild(year_item);
+ var quartiles_list = document.createElement('ul');
+ quartiles_list.className = 'quartile';
+ year_item.appendChild(quartiles_list);
+
+ // [year][QUARTILE][coursesIdx]
+ year.forEach(function(quartile) {
+ var quartile_item = document.createElement('li');
+ quartiles_list.appendChild(quartile_item);
+ var courses_list = document.createElement('ul');
+ courses_list.className = 'courses';
+ quartile_item.appendChild(courses_list);
+
+ // [year][quartile][COURSESIDX]
+ quartile.forEach(function(course) {
+ var course_item = document.createElement('li');
+ courses_list.appendChild(course_item);
+
+ // display course information
+ courseCallback(course_item, course);
+ });
+ });
+ });
+ return years_list;
+ }
+
+ return function() {
+ // navigation
+ var cmenu = document.getElementById("curriculum-menu");
+ cmenu.appendChild(makeCoursesList(function(course_item, course) {
+ course_item.textContent = course.id + ' ' + course.name;
+ }));
+ };
+});