courseweb
courseweb copied to clipboard
courses: more informative data of course
eg adding English dept ID of tags
request from @Komeii
Class code is as follows [year][B-bachelors, M-masters, D-phd][A~D for class 清,華,梅]
as for the shortened chinese text, might be a bit of a hassle to translate?
function makeReadable(code) {
// Define mappings for degree types and class letters
const degreeTypes = { 'B': '大學部', 'M': '碩士班', 'D': '博士班' };
const classLetters = { 'A': '清班', 'B': '華班', 'C': '梅班', 'D': '班' }; // Assuming 'D' stands for a general class
// Parse the input string
const match = code.match(/(^[^\d]+)(\d+)([BMD])([A-D]?)/);
if (!match) {
return 'Invalid format';
}
// Extract components
const [, deptName, year, degreeType, classLetter] = match;
// Translate components
const readableYear = year + '年';
const readableDegreeType = degreeTypes[degreeType] || '';
const readableClassLetter = classLetters[classLetter] || '';
// Construct the output
return `${deptName}${readableYear}${readableDegreeType}${readableClassLetter}`;
}