-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubject-knowledge-2023.html
More file actions
executable file
·144 lines (117 loc) · 4.61 KB
/
subject-knowledge-2023.html
File metadata and controls
executable file
·144 lines (117 loc) · 4.61 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html><html>
<head>
<meta charset="utf-8" />
<link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,....==" />
<title>Subject Knowledge Audit</title>
<link rel="stylesheet" href="_base.css">
<style>
td .title {
font-weight: bold;
}
td .description {
color: grey;
font-size: smaller;
}
th:nth-child(n+4) {
writing-mode: vertical-lr;
padding: 1em;
}
</style>
<script src="https://unpkg.com/showdown/dist/showdown.min.js"></script>
</head>
<body>
<div id="navigation"></div>
<div id="description"></div>
<div class="page_break"></div>
<h1>Subject Knowledge Tracker 2023</h1>
<div id="main"></div>
<div class="page_break"></div>
<div id="additional"></div>
<script type="module">
// Consts ----------------------------------------------------------------------
const navigationElement = document.getElementById('navigation');
const mainElement = document.getElementById('main') || document.getElementsByTagName('body').item(0);
// Utils -----------------------------------------------------------------------
export function* range(target, start=0, step=1) {
for (let i=start ; i<target ; i+=step) {yield i;}
}
export function* enumerate(iterable) {
let count = 0;
for (let item of iterable) {
//yield (item[Symbol.iterator]) ? [count++, ...item] : [count++, item];
yield [count++, item];
}
}
export const hasIterationProtocol = variable => variable !== null && Symbol.iterator in Object(variable);
export function h(type, params, children) {
const el = document.createElement(type)
for (let [k,v] of Object.entries(params)) {el[k] = v}
if (typeof(children)==="string") {el.appendChild(document.createTextNode(children))}
else if (hasIterationProtocol(children)) {
for (let c of children) {el.append(c)}
}
else if (children) {el.appendChild(children)}
return el
}
// Markdown --------------------------------------------------------------------
function renderMarkdownFileToElement(url, $el) {
fetch(url)
.then(response => response.text())
.then((markdown_data) => {
const converter = new showdown.Converter(); // https://github.com/showdownjs/showdown
$el.innerHTML = converter.makeHtml(markdown_data);
})
.catch(err => console.error(err));
}
renderMarkdownFileToElement(`subject_knowledge-2023.md`, document.getElementById("description"));
renderMarkdownFileToElement(`level_descriptors.md`, document.getElementById("additional"));
// Main ------------------------------------------------------------------------
let _data;
window.onhashchange = function() {
renderData(_data);
}
const URL_PREFIX = {
'nc': 'https://www.gov.uk/government/publications/national-curriculum-in-england-computing-programmes-of-study/national-curriculum-in-england-computing-programmes-of-study#',
'aqa': 'https://www.aqa.org.uk/subjects/computer-science-and-it/gcse/computer-science-8525/subject-content#',
'ocr': 'https://www.ocr.org.uk/Images/558027-specification-gcse-computer-science-j277.pdf#page=',
'ocr_imedia': 'https://www.ocr.org.uk/Images/115888-specification.pdf#page=',
}
function renderData(data) {
// Clear existing html
navigationElement.innerHTML = '';
mainElement.innerHTML = '';
const tags = data.reduce(
(acc, item) => {
for (let tag of item.tags || []) {acc.add(tag);}
return acc;
},
new Set(),
);
//console.log(tags);
const headings = ["", "", "Tags", "Links", "Pre-course", "December", "April", "June"]
mainElement.appendChild(h('table',{},[
h('thead',{},[...headings.map(heading=>h('th',{},heading))]),
...[...enumerate(data)].map(([item_count, item])=>h('tr',{},[
h('td',{},`${item_count}`),
h('td',{},[
h('p',{className: 'title'},item.title),
h('p',{className: 'description'},item.description),
]),
h('td',{},h('ul',{},(item.tags||[]).map(tag=>
h('li',{className:`tag_${tag}`},tag)
))),
h('td',{},h('ul',{},[...Object.entries(item.url || {}).map(([key,url])=>
h('li',{},h('a',{href: `${URL_PREFIX[key] || ''}${url || ''}`}, key))
)])),
...[...range(4)].map(i=>h('td',{},''))
]))
]))
}
fetch(`subject-knowledge-2023.json`)
.then(response => response.json())
.then((data)=>_data=data)
.then(renderData)
.catch(err => console.error(err));
</script>
</body>
</html>