-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubject-knowledge-2022.html
More file actions
executable file
·176 lines (138 loc) · 5.52 KB
/
subject-knowledge-2022.html
File metadata and controls
executable file
·176 lines (138 loc) · 5.52 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!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</h1>
<div id="main"></div>
<div class="page_break"></div>
<div id="additional"></div>
<script type="module">
//const QUERY_STRING_project = 'project';
//const urlParams = new URLSearchParams(window.location.search);
const navigationElement = document.getElementById('navigation');
const mainElement = document.getElementById('main') || document.getElementsByTagName('body').item(0);
// 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-2022.md`, document.getElementById("description"));
renderMarkdownFileToElement(`level_descriptors.md`, document.getElementById("additional"));
// Main ------------------------------------------------------------------------
let _data;
window.onhashchange = function() {
renderData(_data);
}
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=',
}
// 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"]
// Build Table
const table = document.createElement('table');
mainElement.appendChild(table);
// Table - Heading
const table_headings = document.createElement('thead');
table.appendChild(table_headings);
for (let heading of headings) {
const table_heading = document.createElement('th');
table_headings.appendChild(table_heading);
table_heading.textContent = heading;
}
// Table - Rows
let item_count = 0;
for (let item of data) {
const table_row = document.createElement('tr');
table.appendChild(table_row);
const el_count = document.createElement('td');
table_row.appendChild(el_count);
el_count.textContent = ++item_count;
// Item
const table_item = document.createElement('td');
const el_title = document.createElement('p');
const el_description = document.createElement('p');
el_title.className = "title";
el_description.className = "description";
table_item.appendChild(el_title);
table_item.appendChild(el_description);
el_title.textContent = item.title;
el_description.textContent = item.description;
//table_row_name.textContent = `<>`
//table_item.innerHTML = `<p>${}</p><p>${item['description']}</p>`;
table_row.appendChild(table_item);
// Tags
const el_tags = document.createElement('td');
table_row.appendChild(el_tags);
const el_tags_list = document.createElement('ul');
el_tags.appendChild(el_tags_list);
for (let tag of item.tags) {
const _li = document.createElement('li');
_li.textContent = tag;
_li.className = `tag_${tag}`;
el_tags_list.appendChild(_li);
}
// Links
const el_links = document.createElement('td')
table_row.appendChild(el_links)
const el_links_list = document.createElement('ul')
el_links.appendChild(el_links_list)
for (let [key, url] of Object.entries(item.url)) {
const _li = document.createElement('li')
el_links_list.appendChild(_li);
const _li_a = document.createElement('a')
_li.appendChild(_li_a)
_li_a.textContent = key
_li_a.href = `${URL_PREFIX[key] || ''}${url}`
}
// Create empty cells - not happy about how clumbsy this is
for (let i=0 ; i < 4 ; i++) {
table_row.appendChild(document.createElement('td'));
}
}
}
fetch(`subject-knowledge-2022.json`)
.then(response => response.json())
.then((data)=>_data=data)
.then(renderData)
.catch(err => console.error(err));
</script></body></html>