-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.gs
127 lines (103 loc) · 3.39 KB
/
test.gs
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function testui()
{
return UI.showStep1Grading();
}
// test.gas.gs
// ===========
TESTS_QA_SHEET_ID = "0AhRtIprIrwuzdGFtUTBpb1ljWGhQYnZHcWhHcGo1Z2c";
TESTS_NUM_ROWS = 57;
TESTS_NUM_COLS = 37;
// Offset into array for submission times.
TESTS_SUBMISSION_TIME_START = 7;
TESTS_SUBMISSION_TIME_END = 51;
// runTests()
// ----------
// TODO_AJR - Ultimately we want one of these for each file/class.
unitTestFunctions =
[
testQAGradesSheet,
testDebugClass,
testNumGradedSubm
]
function runTests()
{
Debug.info("runTests()");
var passed = true;
var i = 0;
for (; i < unitTestFunctions.length; i++)
{
if (!unitTestFunctions[i]())
{
passed = false;
}
}
var result = passed ? "PASSED" : "FAILED";
Debug.info("runTests() - TESTS " + result);
Browser.msgBox("TESTS " + result + ". See trace log");
} // runTests()
// testGradesSheet()
// -----------------
//
// To test the grading feautures of Flubaroo the submission
// sheet from the "Flubaroo QA Spreadsheet" need to be copied
// into the submission sheet and the resulting grades sheet is
// compared against the manually checked results.
//
// See http://www.edcode.org/kb/flubaroo/testing-your-changes
// for details although a newer answer sheet was needed - as
// described by the ID above.
//
// When grading:
//
// Q1: 3 points
// Q10: 4 points
// Q24: Skip Grading
// Q25: 5 points
// All other questions: 1 point (except student identifiers)
// Row 3 (with Full Name of "Answer Key") is the answer key to be used in Step 2.
//
// The spreadsheet need to be set to the local timezone for the
// date comparisons to work (File>Spreadsheet settings...).
function testQAGradesSheet()
{
Debug.info("testQAGradesSheet()");
// Read in the calculated grades sheet.
var results = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName(gbl_grades_sheet_name)
.getRange(1, 1, TESTS_NUM_ROWS, TESTS_NUM_COLS)
.getValues();
// Read in the same from the QA sheet.
var answers = SpreadsheetApp.openById(TESTS_QA_SHEET_ID)
.getSheetByName(gbl_grades_sheet_name)
.getRange(1, 1, TESTS_NUM_ROWS, TESTS_NUM_COLS)
.getValues();
var expected;
var actual;
// Compare the results against the answers.
for (var i = 0, passed = true; i < TESTS_NUM_ROWS; i++)
{
for (var j = 0; j < TESTS_NUM_COLS; j++)
{
expected = answers[i][j];
actual = results[i][j];
if (j === 0 &&
(i >= TESTS_SUBMISSION_TIME_START && i <= TESTS_SUBMISSION_TIME_END))
{
// This is a submission times so ignore these as they
// are always different - some time zone stuff going on.
// TODO_AJR - Bring these tests back in.
continue;
}
if (actual !== expected)
{
Debug.info("testQAGradesSheet() - TEST FAILED: " +
"[" + (i + 1) + "]" +
"[" + (j + 1) + "] - " + " " +
"Expected: " + expected + " " +
"Actual: " + actual);
passed = false;
}
}
}
return passed;
} // testQAGradesSheet()