courseweb icon indicating copy to clipboard operation
courseweb copied to clipboard

courses: more informative data of course

Open Joshimello opened this issue 2 years ago • 2 comments

eg adding English dept ID of tags opera_utgaOYzljq

request from @Komeii

Joshimello avatar Jan 06 '24 13:01 Joshimello

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?

ImJustChew avatar Feb 06 '24 08:02 ImJustChew

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}`;
}

ImJustChew avatar Feb 06 '24 08:02 ImJustChew