Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit cfb15ee

Browse files
committed
Merge pull request #52 from riknos314/logFixes
updated jsComponents to use this.logBookEvents
2 parents 4d5db5b + 47cdf8f commit cfb15ee

File tree

7 files changed

+21
-30
lines changed

7 files changed

+21
-30
lines changed

runestone/assess/js/fitb.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ function FITB (opts) {
4343
this.init(opts);
4444
}
4545
}
46+
47+
FITB.prototype = new RunestoneBase();
48+
4649
/*===================================
4750
=== Setting FITB variables ===
4851
===================================*/
4952

5053
FITB.prototype.init = function (opts) {
54+
RunestoneBase.apply(this, arguments);
5155
var orig = opts.orig; // entire <p> element
5256
this.origElem = orig;
5357
this.divid = orig.id;
@@ -241,7 +245,7 @@ FITB.prototype.checkFITBStorage = function () {
241245
this.evaluateAnswers();
242246
this.renderFITBFeedback();
243247
var answerInfo = "answer:" + this.given_arr + ":" + (this.isCorrect ? "correct" : "no");
244-
logBookEvent({"event": "fillb", "act": answerInfo, "div_id": this.divid});
248+
this.logBookEvent({"event": "fillb", "act": answerInfo, "div_id": this.divid});
245249
this.enableCompareButton.disabled = false;
246250
};
247251
FITB.prototype.evaluateAnswers = function () {

runestone/assess/js/mchoice.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ function MultipleChoice (opts) {
3434
}
3535
}
3636

37+
MultipleChoice.prototype = new RunestoneBase();
38+
3739
/*===================================
3840
=== Setting MC variables ===
3941
===================================*/
4042

4143
MultipleChoice.prototype.init = function (opts) {
44+
RunestoneBase.apply(this, arguments);
4245
var orig = opts.orig; // entire <ul> element
4346
this.origElem = orig;
4447

@@ -198,8 +201,11 @@ MultipleChoice.prototype.renderMCFormOpts = function () {
198201

199202
// Create the label for the input
200203
var label = document.createElement("label");
201-
$(label).attr("for", optid);
202-
$(label).text(this.answerList[k].content);
204+
var labelspan = document.createElement("span");
205+
label.appendChild(input);
206+
label.appendChild(labelspan);
207+
//$(label).attr("for", optid);
208+
$(labelspan).text(this.answerList[k].content);
203209

204210
// create the object to store in optionArray
205211
var optObj = {
@@ -209,7 +215,6 @@ MultipleChoice.prototype.renderMCFormOpts = function () {
209215
this.optionArray.push(optObj);
210216

211217
// add the option to the form
212-
this.optsForm.appendChild(input);
213218
this.optsForm.appendChild(label);
214219
this.optsForm.appendChild(document.createElement("br"));
215220

@@ -392,7 +397,7 @@ MultipleChoice.prototype.populateMCMALocalStorage = function () {
392397

393398
MultipleChoice.prototype.logMCMAsubmission = function () {
394399
var answerInfo = "answer:" + this.givenlog.substring(0, this.givenlog.length - 1) + ":" + (this.correctCount == this.correctList.length ? "correct" : "no");
395-
logBookEvent({"event": "mChoice", "act": answerInfo, "div_id": this.divid});
400+
this.logBookEvent({"event": "mChoice", "act": answerInfo, "div_id": this.divid});
396401
};
397402

398403

@@ -444,7 +449,7 @@ MultipleChoice.prototype.populateMCMFLocalStorage = function () {
444449

445450
MultipleChoice.prototype.logMCMFsubmission = function () {
446451
var answerInfo = "answer:" + this.givenArray[0] + ":" + (this.givenArray[0] == this.correctIndexList[0] ? "correct" : "no");
447-
logBookEvent({"event": "mChoice", "act": answerInfo, "div_id": this.divid});
452+
this.logBookEvent({"event": "mChoice", "act": answerInfo, "div_id": this.divid});
448453
};
449454

450455
MultipleChoice.prototype.renderMCMFFeedback = function (correct, feedbackText) {

runestone/assess/js/timed.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ function Timed (opts) {
1818
}
1919
}
2020

21+
Timed.prototype = new RunestoneBase();
2122

2223
/*====================================
2324
=== Setting Timed Assess Variables ===
2425
====================================*/
2526

2627
Timed.prototype.init = function (opts) {
28+
RunestoneBase.apply(this, arguments);
2729
var orig = opts.orig;
2830
this.origElem = orig; // the entire element of this timed assessment and all of its children
2931
this.divid = orig.id;
@@ -306,7 +308,7 @@ Timed.prototype.startAssessment = function () {
306308
this.running = 1;
307309
$(this.timedDiv).show();
308310
this.increment();
309-
logBookEvent({"event": "timedExam", "act": "start", "div_id": this.divid});
311+
this.logBookEvent({"event": "timedExam", "act": "start", "div_id": this.divid});
310312
localStorage.setItem(eBookConfig.email + ":" + this.divid, "started");
311313
}
312314
} else {
@@ -514,7 +516,7 @@ Timed.prototype.storeScore = function () {
514516
};
515517

516518
Timed.prototype.logScore = function () {
517-
logBookEvent({"event": "timedExam", "act": "finish", "div_id": this.divid, "correct": this.score, "incorrect": this.incorrect, "skipped": this.skipped, "time": this.timeTaken});
519+
this.logBookEvent({"event": "timedExam", "act": "finish", "div_id": this.divid, "correct": this.score, "incorrect": this.incorrect, "skipped": this.skipped, "time": this.timeTaken});
518520
};
519521

520522
Timed.prototype.restoreFromStorage = function () {

runestone/clickableArea/js/clickable.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
=== Isaiah Mayerchak ===
99
=== 7/1/15 ===
1010
==========================================*/
11-
function RunestoneBase () { // Basic parent stuff
12-
13-
}
14-
RunestoneBase.prototype.logBookEvent = function (info) {
15-
console.log("logging event " + this.divid);
16-
};
17-
RunestoneBase.prototype.logRunEvent = function (info) {
18-
console.log("running " + this.divid);
19-
};
20-
2111
var CAList = {}; // Dictionary that contains all instances of ClickableArea objects
2212

2313

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99
=== 6/8/15 ===
1010
==========================================*/
1111

12-
function RunestoneBase () { // Basic parent stuff
13-
14-
}
15-
RunestoneBase.prototype.logBookEvent = function (info) {
16-
console.log("logging event " + this.divid);
17-
};
18-
RunestoneBase.prototype.logRunEvent = function (info) {
19-
console.log("running " + this.divid);
20-
};
21-
2212
var dfList = {}; // Dictionary that contains all instances of Datafile objects
2313

2414

runestone/poll/js/poll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function submitPoll(div_id) {
1818
var eventInfo = {'event':'poll', 'act':act, 'div_id':div_id};
1919

2020
// log the response to the database
21-
logBookEvent(eventInfo); // in bookfuncs.js
21+
this.logBookEvent(eventInfo); // in bookfuncs.js
2222

2323
// log the fact that the user has answered the poll to local storage
2424
localStorage.setItem(div_id, "true");

runestone/shortanswer/js/shortanswer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function submitJournal(directive_id) {
4040
function(data) {
4141
console.log(data.message);
4242
}); */
43-
logBookEvent({'event': 'shortanswer', 'act': JSON.stringify(value), 'div_id': directive_id});
43+
this.logBookEvent({'event': 'shortanswer', 'act': JSON.stringify(value), 'div_id': directive_id});
4444
}
4545

4646

0 commit comments

Comments
 (0)