-
Notifications
You must be signed in to change notification settings - Fork 0
/
work.js
94 lines (75 loc) · 2.68 KB
/
work.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//Handy exists() function
jQuery.fn.exists = function(){return this.length>0;}
$(document).ready(function() {
//Remove pointless pi button
var $eq = $("#eqEditorDiv");
$eq.remove();
//Calculate the score
doScore();
})
var doScore = function() {
//Total questions on the page
var totalQuestions = 0;
//Get num of questions
var enumeratedQuestions = new Array();
var $questions = $("input[id^='AnSwEr']")
for (var i = 0; i < $questions.length; i++) {
var id = parseInt($questions.eq(i).attr("id").substr(6, 10));
enumeratedQuestions[id] = true;
}
//Set the total questions to the enum q length
totalQuestions = enumeratedQuestions.length - 1;
console.log(totalQuestions)
//Now, find the unanswered questions amount from the text
var resultsAlertIndex = $(".resultsAlert").text().indexOf("of");
var unansweredQuestions = parseInt($(".resultsAlert").text().substr(0, resultsAlertIndex));
var text = $(".scoreSummary p").text();
var begin = text.indexOf("of") + 3;
var end = text.indexOf("%");
var scorePercent = parseInt(text.substr(begin, end-begin));
var result = Math.round(totalQuestions * (scorePercent / 100));
if (!isNaN(result)) {
//Iffy math
var possibleQuestions = totalQuestions - result;
console.log("and the possible questions are " + possibleQuestions)
var wrongQuestions = possibleQuestions - unansweredQuestions;
console.log("which means the wrong questions are " + wrongQuestions)
$(".resultsAlert").append("<br>Questions wrong: " + wrongQuestions + " out of the " + (totalQuestions - unansweredQuestions) + " answered.");
}
}
//magic?
$table = $("table[border=1]");
$("form").attr("autocomplete", "off");
$firstRow = $table.find("tr").eq(0).find("td");
$firstRow.attr('unselectable','on')
.css({'-moz-user-select':'-moz-none',
'-moz-user-select':'none',
'-o-user-select':'none',
'-khtml-user-select':'none', /* you could also put this in a class */
'-webkit-user-select':'none',/* and add the CSS class here instead */
'-ms-user-select':'none',
'user-select':'none'
}).bind('selectstart', function(){ return false; });
$firstRow.css("cursor", "pointer")
$firstRow.click(function(){
if ($(this).hasClass("_hidden"))
{
$(this).removeClass("_hidden");
var col = $(this).index();
$table.find("tr").each(function(){
$column = $(this).find("td").eq(col);
$column.css("opacity", 1)
$column.css("color", "black")
});
}
else
{
$(this).addClass("_hidden");
var col = $(this).index();
$table.find("tr").each(function(){
$column = $(this).find("td").eq(col);
$column.css("opacity", .05)
$column.css("color", "white")
});
}
});