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

Commit 07706e8

Browse files
committed
Fix: Make logRunEvent consistent with logBookEvent.
1 parent d406bf4 commit 07706e8

3 files changed

Lines changed: 39 additions & 30 deletions

File tree

runestone/activecode/js/activecode_js.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default class JSActiveCode extends ActiveCode {
5555
this.addErrorMessage(e);
5656
einfo = e;
5757
}
58+
// Note that, since this isn't awaited, the request may not be complete when this function returns.
5859
this.logRunEvent({
5960
div_id: this.divid,
6061
code: this.editor.getValue(),
@@ -64,6 +65,6 @@ export default class JSActiveCode extends ActiveCode {
6465
prefix: this.pretext,
6566
suffix: this.suffix,
6667
partner: this.partner,
67-
}); // Log the run event
68+
});
6869
}
6970
}

runestone/common/js/runestonebase.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ export default class RunestoneBase {
5757
}
5858
}
5959

60-
// This function sends the provided ``eventInfo`` to the ``hsblog`` endpoint of the server. Awaiting this function returns either ``undefined`` (if Runestone services are not available) or the data returned by the server as a JavaScript object (already JSON-decoded).
60+
// .. _logBookEvent:
61+
//
62+
// logBookEvent
63+
// ------------
64+
// This function sends the provided ``eventInfo`` to the `hsblog endpoint` of the server. Awaiting this function returns either ``undefined`` (if Runestone services are not available) or the data returned by the server as a JavaScript object (already JSON-decoded).
6165
async logBookEvent(eventInfo) {
6266
if (this.graderactive) {
6367
return;
@@ -95,8 +99,14 @@ export default class RunestoneBase {
9599
}
96100
return post_return;
97101
}
102+
103+
// .. _logRunEvent:
104+
//
105+
// logRunEvent
106+
// -----------
107+
// This function sends the provided ``eventInfo`` to the `runlog endpoint`. When awaited, this function returns the data (decoded from JSON) the server sent back.
98108
async logRunEvent(eventInfo) {
99-
let post_promise = Promise.resolve("done");
109+
let post_promise = "done";
100110
if (this.graderactive) {
101111
return;
102112
}
@@ -116,11 +126,11 @@ export default class RunestoneBase {
116126
headers: headers,
117127
body: JSON.stringify(eventInfo),
118128
});
119-
post_promise = await fetch(request);
120-
post_promise = await fetch(request);
121-
if (!post_promise.ok) {
129+
let response = await fetch(request);
130+
if (!response.ok) {
122131
throw new Error("Failed to log the run");
123132
}
133+
post_promise = await response.json();
124134
}
125135
console.log("running " + JSON.stringify(eventInfo));
126136
if (

runestone/overview.rst

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ Consistent Component API
33

44
A standardized API will make the Runestone Components easier to work on and more maintainable. For example in trying to find out how to JUST score a component in a timed exam (not render any feedback) I found the following methods:
55

6-
* processXXXSubmissions - mchoice
7-
* startEvaluation - fitb
8-
* dragEval - dragndrop
9-
* checkMe - parsons
10-
* clickableEval - clickaablearea
11-
* activecode - runProg
12-
* submitJournal - short answer
6+
* processXXXSubmissions - mchoice
7+
* startEvaluation - fitb
8+
* dragEval - dragndrop
9+
* checkMe - parsons
10+
* clickableEval - clickaablearea
11+
* activecode - runProg
12+
* submitJournal - short answer
1313

1414
All of the above mix the scoring of the component with rendering the feedback. I would like to separate those two things and standardize on some names for doing so.
1515

1616
Base Class Provides
1717
-------------------
18-
* shouldUseServer
19-
* checkServer
20-
* logRunEvent
21-
* logBookEvent
22-
* loadData
23-
* repopulateFromStorage
24-
* localStorageKey
25-
* addCaption
26-
* constructor that takes opts
18+
* shouldUseServer
19+
* checkServer
20+
* `logRunEvent` - send the results of executing an ActiveCode exercise to the `runlog endpoint`.
21+
* `logBookEvent` - send the results of answering a question to the `hsblog endpoint`.
22+
* loadData
23+
* repopulateFromStorage
24+
* localStorageKey
25+
* addCaption
26+
* constructor that takes opts
2727

2828
All Components
2929
--------------
@@ -33,14 +33,12 @@ All Components
3333
* setLocalStorage
3434
* checkLocalStorage
3535
* hasUserActivity
36-
*
37-
Gradable
38-
--------
3936

37+
Gradable
38+
--------
4039
Each Gradable should provide these three functions as an external API. We want to separate checking, from logging and providing feedback
41-
* checkCurrentAnswer - async? so that for server side grading we can await
42-
* logCurrentAnswer
43-
* renderFeedback
44-
* disableInteraction
45-
4640

41+
* checkCurrentAnswer - async? so that for server side grading we can await
42+
* logCurrentAnswer
43+
* renderFeedback
44+
* disableInteraction

0 commit comments

Comments
 (0)