Fetch the repository succeeded.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Score {
public static void main(String[] args) throws FileNotFoundException, IOException {
Properties pps = new Properties();
pps.load(new FileInputStream("total.properties"));
Enumeration fileName = pps.propertyNames();
int totalbefore = Integer.parseInt(pps.getProperty("before"));
int totalbase = Integer.parseInt(pps.getProperty("base"));
int totaltest = Integer.parseInt(pps.getProperty("test"));
int totalprogram = Integer.parseInt(pps.getProperty("program"));
int totaladd = Integer.parseInt(pps.getProperty("add"));
double program=0,base=0,before=0,add=0,test=0;
Document small = Jsoup.parse(new File("small.html"), "utf-8");
Elements titleItems = small.getElementsByClass("interaction-row");
for (Element titleItem : titleItems) {
//每题的标题 都是由title属性的span标签
Element title = titleItem.select("span[title]").first();
if(title.text().contains("编程题")) {
program = count(program, titleItem);
}
if(title.text().contains("课堂小测")) {
test = count(test, titleItem);
}
if(title.text().contains("课堂完成")) {
base = count(base, titleItem);
}
if(title.text().contains("附加题")) {
add = count(add, titleItem);
}
if(title.text().contains("课前自测")) {
before = count(before, titleItem);
}
}
Document all = Jsoup.parse(new File("all.html"), "utf-8");
Elements titleItems2 = small.getElementsByClass("interaction-row");
for (Element titleItem : titleItems2) {
//每题的标题 都是由title属性的span标签
Element title = titleItem.select("span[title]").first();
if(title.text().contains("编程题")) {
program = count(program, titleItem);
}
if(title.text().contains("课堂小测")) {
test = count(test, titleItem);
}
if(title.text().contains("课堂完成")) {
base = count(base, titleItem);
}
if(title.text().contains("附加题")) {
add = count(add, titleItem);
}
if(title.text().contains("课前自测")) {
before = count(before, titleItem);
}
}
double beforeexam = before/totalbefore;
double testexam = test/totaltest;
double baseexam = base/totalbase * 0.95;
double programexam = program/totalprogram *0.95;
double addexam = add/totaladd * 0.9;
double sum=(beforeexam*0.3+testexam*0.2+baseexam*0.25+programexam*0.1+addexam*0.05)*100+6;
System.out.println(sum);
}
private static double count(double n, Element titleItem) {
Elements exs = titleItem.select("span[style='color:#8FC31F;']");
//用循环解决互评的可能性
for (Element ex : exs) {
String str = ex.text().trim();
String str2 = "";
if (str != null && !"".equals(str)) {
for (int i = 0; i < str.length(); i ++) {
if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
str2 += str.charAt(i);
}
}
}
if(!"".equals(str2)) n += Integer.parseInt(str2);
}
return n;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。