package czy;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jsoup.*;
import org.jsoup.nodes.*;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class Score {
public static void main(String[] args) throws IOException {
<<<<<<< HEAD
// 瀵煎叆鎬诲垎鐨勯厤缃枃浠
=======
// 导入总分的配置文件
>>>>>>> 3a5242b... personal
Properties total = new Properties();
total.load(new FileInputStream("total.properties"));
System.out.println("aaa");
<<<<<<< HEAD
// 瀵煎叆澶у皬鐝璧勬簮
=======
// 导入大小班课资源
>>>>>>> 3a5242b... personal
File small = new File("small.html");
Document docSmall = Jsoup.parse(small, "UTF-8");
File all = new File("all.html");
Document docAll = Jsoup.parse(all, "UTF-8");
<<<<<<< HEAD
// 璇惧爞瀹屾垚閮ㄥ垎鍒嗘暟璁$畻
String totalBase = total.getProperty("base");
double baseScore = 0;
// 璇诲彇鍐呭
baseScore += getScore("璇惧爞瀹屾垚",docSmall.select(".interaction-row"));
// 璇惧爞灏忔祴閮ㄥ垎鍒嗘暟璁$畻
String totalTest = total.getProperty("test");
double testScore = 0;
// 璇诲彇鍐呭
testScore += getScore("璇惧爞灏忔祴",docAll.select(".interaction-row"));
// 璇惧墠鑷祴閮ㄥ垎鍒嗘暟璁$畻
String totalBefore = total.getProperty("before");
double beforeScore = 0;
// 璇诲彇鍐呭
beforeScore += getScore("璇惧墠鑷祴",docAll.select(".interaction-row"));
beforeScore += getScore("璇惧墠鑷祴",docSmall.select(".interaction-row"));
// 缂栫▼棰橀儴鍒嗗垎鏁拌绠
String totalProgram = total.getProperty("program");
double programScore = 0;
// 璇诲彇鍐呭
programScore += getScore("缂栫▼棰",docSmall.select(".interaction-row"));
// 闄勫姞棰橀儴鍒嗗垎鏁拌绠
String totalAdd = total.getProperty("add");
double addScore = 0;
// 璇诲彇鍐呭
addScore += getScore("闄勫姞棰",docSmall.select(".interaction-row"));
// 鏈缁堢殑鍚勯」寰楀垎
=======
// 课堂完成部分分数计算
String totalBase = total.getProperty("base");
double baseScore = 0;
// 读取内容
baseScore += getScore("课堂完成",docSmall.select(".interaction-row"));
// 课堂小测部分分数计算
String totalTest = total.getProperty("test");
double testScore = 0;
// 读取内容
testScore += getScore("课堂小测",docAll.select(".interaction-row"));
// 课前自测部分分数计算
String totalBefore = total.getProperty("before");
double beforeScore = 0;
// 读取内容
beforeScore += getScore("课前自测",docAll.select(".interaction-row"));
beforeScore += getScore("课前自测",docSmall.select(".interaction-row"));
// 编程题部分分数计算
String totalProgram = total.getProperty("program");
double programScore = 0;
// 读取内容
programScore += getScore("编程题",docSmall.select(".interaction-row"));
// 附加题部分分数计算
String totalAdd = total.getProperty("add");
double addScore = 0;
// 读取内容
addScore += getScore("附加题",docSmall.select(".interaction-row"));
// 最终的各项得分
>>>>>>> 3a5242b... personal
double sumBase = (baseScore / Integer.parseInt(totalBase)) * 100 * 0.95;
double sumTest = (testScore / Integer.parseInt(totalTest)) * 100;
double sumBefore = (beforeScore / Integer.parseInt(totalBefore)) * 100;
double sumProgram = (programScore / Integer.parseInt(totalProgram)) * 95;
double sumAdd = (addScore / Integer.parseInt(totalAdd)) * 90;
double sum = sumBase * 0.3 + sumTest * 0.2 + sumBefore * 0.25 + sumProgram * 0.1 + sumAdd * 0.05;
System.out.println(sum);
}
static int getScore(String item,Elements baseDoc) {
int Score = 0;
for (int i = 0; i < baseDoc.size(); i++) {
if (baseDoc.get(i).text().toString().contains(item)) {
<<<<<<< HEAD
// 闈炵孩鑹查儴鍒嗘墠鏈夊垎鏁
if (!baseDoc.get(i).toString().contains("#EC6941")) {
// 寰楀埌 鈥渪x 缁忛獙鈥濋儴鍒
String pattern = "\\w* 缁忛獙";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(baseDoc.get(i).text().toString());
while (m.find()) {
int sc = Integer.parseInt(m.group().replaceAll(" ", "").replaceAll("缁忛獙", "").toString());
=======
// 非红色部分才有分数
if (!baseDoc.get(i).toString().contains("#EC6941")) {
// 得到 “xx 经验”部分
String pattern = "\\w* 经验";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(baseDoc.get(i).text().toString());
while (m.find()) {
int sc = Integer.parseInt(m.group().replaceAll(" ", "").replaceAll("经验", "").toString());
>>>>>>> 3a5242b... personal
return Score += sc;
}
}
}
}
return 0;
}
<<<<<<< HEAD
}
=======
}
>>>>>>> 3a5242b... personal
一键复制
编辑
Web IDE
原始数据
按行查看
历史