MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / startAssessment

Function startAssessment

tests/testHomework.js:151–297  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 var res, page, elemList;
150
151 var startAssessment = function() {
152
153 describe('the locals object', function() {
154 it('should be cleared', function() {
155 for (var prop in locals) {
156 delete locals[prop];
157 }
158 });
159 it('should be initialized', function() {
160 locals.siteUrl = 'http://localhost:' + config.serverPort;
161 locals.baseUrl = locals.siteUrl + '/pl';
162 locals.courseInstanceBaseUrl = locals.baseUrl + '/course_instance/1';
163 locals.questionBaseUrl = locals.courseInstanceBaseUrl + '/instance_question';
164 locals.assessmentsUrl = locals.courseInstanceBaseUrl + '/assessments';
165 locals.isStudentPage = true;
166 locals.totalPoints = 0;
167 });
168 });
169
170 describe('the questions', function() {
171 it('should have cleared data', function() {
172 questionsArray.forEach(function(question) {
173 for (var prop in question) {
174 if (prop != 'qid' && prop != 'type' && prop != 'maxPoints') {
175 delete question[prop];
176 }
177 }
178 question.points = 0;
179 });
180 });
181 });
182
183 describe('the database', function() {
184 it('should contain HW1', function(callback) {
185 sqldb.queryOneRow(sql.select_hw1, [], function(err, result) {
186 if (ERR(err, callback)) return;
187 locals.assessment_id = result.rows[0].id;
188 callback(null);
189 });
190 });
191 });
192
193 describe('GET ' + locals.assessmentsUrl, function() {
194 it('should load successfully', function(callback) {
195 request(locals.assessmentsUrl, function (error, response, body) {
196 if (error) {
197 return callback(error);
198 }
199 if (response.statusCode != 200) {
200 return callback(new Error('bad status: ' + response.statusCode));
201 }
202 res = response;
203 page = body;
204 callback(null);
205 });
206 });
207 it('should parse', function() {
208 locals.$ = cheerio.load(page);

Callers 1

testHomework.jsFile · 0.70

Calls 2

itFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected