Auto grading

USTC 自动评价 tqm.ustc.edu.cn

目前為 2022-12-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Auto grading
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  USTC 自动评价 tqm.ustc.edu.cn
// @author       PRO_2684
// @match        https://tqm.ustc.edu.cn/index.html*
// @icon         https://tqm.ustc.edu.cn/favicon.ico
// @grant        none
// @license      unlicense
// ==/UserScript==

(function() {
    'use strict';
    let standard_answers = {
        '教学内容': '非常同意',
        '教学资源': '非常满意',
        '教材单列': '非常满意',
        '课程难度': '适合',
        '教学态度': '非常同意',
        '教学水平': '非常同意',
        '教学手段': '非常同意',
        '教学方法': '非常同意',
        '师生互动': '非常同意',
        '学习投入': '3-4小时',
        '知识掌握': '非常同意',
        '能力提升': '非常同意',
        '兴趣培养': '非常同意',
        '推荐度': '会',
        '整体评价': '非常好',
        '1.该助教是否随堂听课?': '全部',
        '2.该助教批改作业是否认真?': '非常认真',
        '3.该助教习题课/答疑课准备是否充分?': '非常充分',
        '4.该助教对课程知识的掌握是否扎实?': '非常扎实',
        '5.该助教习题课/答疑课互动中表达是否清晰?': '非常清晰',
        '6.该助教的综合表现': '优秀'
    };
    let menu_root;
    function append_link() {
        let auto_grade = document.createElement('a');
        auto_grade.innerText = "自动评价";
        auto_grade.onclick = grade;
        menu_root.appendChild(auto_grade);
    }
    function grade() {
        let questions = document.querySelectorAll("[class|='index_subject']");
        questions.forEach((question) => {
            let required = Boolean(question.querySelector('[class|="index_necessary"]'));
            if (!required) return;
            let tmp = question.querySelector("[class|='index_title']").querySelectorAll('p');
            let title = tmp[tmp.length - 1].innerText;
            let standard_answer = standard_answers[title];
            console.log(`[Auto grading] ${title}: ${standard_answer}`);
            if (standard_answer) {
                let options = question.querySelectorAll('[style="width: 100%;"]');
                options.forEach((option) => {
                    let is_standard_answer = (option.innerText == standard_answer);
                    if (is_standard_answer) {
                        option.firstChild.click();
                    }
                });
            }
        });
    }
    const root_node = document.getElementById('root');
    const config = { attributes: false, childList: true, subtree: true };
    const callback = function(mutations, observer) {
        menu_root = root_node.querySelector('.ant-menu-root');
        if (menu_root) {
            append_link();
            observer.disconnect();
        }
    }
    const observer = new MutationObserver(callback);
    observer.observe(root_node, config);
})();