zut自动评教

在zut评教系统中按照一定比率自动评教

目前為 2021-12-02 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         zut自动评教
// @namespace    http://zut.xx/
// @version      1.0
// @description  在zut评教系统中按照一定比率自动评教
// @author       JiGuang-2018
// @match        http://app.zut.edu.cn/jwapp/sys/jwwspj/*default/*
// @icon         https://www.google.com/s2/favicons?domain=zut.edu.cn
// @grant        GM_registerMenuCommand
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    let config = {
        step:0,
        size:0,
        goodRate:0.8
    }
    //注册的菜单和对应执行的函数
    let menus = [
    {
        name:'*0.设置好评比例',
        event:setGoodRate
    },
    {
        name:'1.读取题目数量',
        event:lookItems
    },
    {
        name:'2.开始评教',
        event:Main
    },
    ]

    //增加菜单
function addMenu(){
   for(let menu of menus){
   GM_registerMenuCommand(menu.name, menu.event)
   }
}

function setGoodRate(){
    config.goodRate = prompt('请输入好评比例',0.8) * 1
}

function lookItems(){
    try{
        config.size = document.querySelectorAll('.bh-radio-group-h').length
        if(config.size == 0) throw new Error('读取题目数量错误')
        config.step = 1
        alert('读取题目成功,共' + config.size + '道')
    }catch(err){
        alert('读取题目数量失败!')
    }
}

//const size = document.querySelectorAll('.bh-radio-group-h').length
//const goodRate = 0.8

function calcArray(size,goodRate){
    let res = []
    let goodTimes = size * goodRate
    let badTimes = size - goodTimes
    for(let i = 0; i < goodTimes; i++)
        res.push(1)
    for(let i = 0; i < badTimes - 1; i++)
        res.push(3)
    res.sort((p,n)=>{
        return (0.5 - Math.random())
    })
    return res
}

function selectOne(id,item){
    try{
        document.querySelectorAll('.bh-radio-group-h')[id].childNodes[item].click()
    }catch(err){
        console.error(`在选择题目${id}的${item}项失败`)
    }

}

function Main(){
    if(config.step != 1){
        alert('请先再设置菜单中读取题目再评教')
        return
    }
    let array = calcArray(config.size,config.goodRate)
    for(let index in array)
        selectOne(index,array[index])
    console.log('选择结束')
    alert('选择结束')
}

addMenu()
    // Your code here...
})();