Skip to content

Commit b7f1796

Browse files
authored
Merge pull request #52 from SoryRawyer/rds/add-event-types
feat: add event types to populate instructor dashboard (FC-0033)
2 parents b010d4c + 747a1a4 commit b7f1796

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

xapi_db_load/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Scripts to generate fake xAPI data against various backends.
33
"""
44

5-
__version__ = "0.7"
5+
__version__ = "0.8"

xapi_db_load/generate_load.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,40 @@
1212
from .xapi.xapi_navigation import LinkClicked, NextNavigation, PreviousNavigation, TabSelectedNavigation
1313
from .xapi.xapi_problem import BrowserProblemCheck, ServerProblemCheck
1414
from .xapi.xapi_registration import Registered, Unregistered
15-
from .xapi.xapi_video import LoadedVideo, PausedVideo, PlayedVideo, PositionChangedVideo, StoppedVideo
15+
from .xapi.xapi_video import (
16+
CompletedVideo,
17+
LoadedVideo,
18+
PausedVideo,
19+
PlayedVideo,
20+
PositionChangedVideo,
21+
StoppedVideo,
22+
TranscriptDisabled,
23+
TranscriptEnabled,
24+
)
1625

1726
# This is the list of event types to generate, and the proportion of total xapi
1827
# events that should be generated for each. Should total roughly 100 to keep
1928
# percentages simple.
2029
EVENT_LOAD = (
2130
(Registered, 1.138),
2231
(Unregistered, 0.146),
32+
(CompletedVideo, 5.124),
2333
(LoadedVideo, 7.125),
24-
(PlayedVideo, 27.519),
25-
(PausedVideo, 17.038),
34+
(PlayedVideo, 24.519),
35+
(PausedVideo, 14.912),
2636
(StoppedVideo, 3.671),
2737
(PositionChangedVideo, 13.105),
28-
(BrowserProblemCheck, 8.776),
29-
(ServerProblemCheck, 8.643),
38+
(BrowserProblemCheck, 8.726),
39+
(ServerProblemCheck, 8.593),
3040
(NextNavigation, 6.05),
3141
(PreviousNavigation, 0.811),
3242
(TabSelectedNavigation, 0.001),
3343
(LinkClicked, 0.001),
3444
(FirstTimePassed, 0.031),
3545
(ShowHint, 0.076),
3646
(ShowAnswer, 1.373),
47+
(TranscriptEnabled, 0.05),
48+
(TranscriptDisabled, 0.05),
3749
)
3850

3951
EVENTS = [i[0] for i in EVENT_LOAD]

xapi_db_load/xapi/xapi_problem.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Fake xAPI statements for various problem_check events.
33
"""
44
import json
5+
import random
56
from uuid import uuid4
67

78
from .xapi_common import XAPIBase
@@ -57,6 +58,9 @@ def get_randomized_event(
5758
}
5859
}
5960

61+
success = random.choice([True, False])
62+
response = "A correct answer" if success else "An incorrect answer"
63+
6064
server_object = {
6165
"object": {
6266
"definition": {
@@ -71,9 +75,9 @@ def get_randomized_event(
7175
"objectType": "Activity",
7276
},
7377
"result": {
74-
"response": "A correct answer",
78+
"response": response,
7579
"score": {"max": 1, "min": 0, "raw": 0, "scaled": 0},
76-
"success": False,
80+
"success": success,
7781
},
7882
}
7983

@@ -120,6 +124,6 @@ class BrowserProblemCheck(BaseProblemCheck):
120124

121125

122126
class ServerProblemCheck(BaseProblemCheck):
123-
verb = "http://adlnet.gov/expapi/verbs/evaluated"
127+
verb = "https://w3id.org/xapi/acrossx/verbs/evaluated"
124128
verb_display = "evaluated"
125129
problem_type = "server"

xapi_db_load/xapi/xapi_video.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class BaseVideo(XAPIBase):
1212
Base xAPI class for video events.
1313
"""
1414

15+
enabled = False
16+
1517
def get_data(self):
1618
"""
1719
Generate and return the event dict, including xAPI statement as "event".
@@ -80,6 +82,9 @@ def get_randomized_event(self, event_id, account, course, video_id, create_time)
8082
"version": "1.0.3",
8183
}
8284

85+
if self.verb_display == "interacted":
86+
event["result"]["extensions"]["https://w3id.org/xapi/video/extensions/cc-enabled"] = self.enabled
87+
8388
return json.dumps(event)
8489

8590

@@ -93,7 +98,7 @@ class PlayedVideo(BaseVideo):
9398
verb_display = "played"
9499

95100

96-
# TODO: These three technically need different structures, though we're not using them now. Update!
101+
# TODO: These four technically need different structures, though we're not using them now. Update!
97102
class StoppedVideo(BaseVideo):
98103
verb = "http://adlnet.gov/expapi/verbs/terminated"
99104
verb_display = "terminated"
@@ -107,3 +112,19 @@ class PausedVideo(BaseVideo):
107112
class PositionChangedVideo(BaseVideo):
108113
verb = "https://w3id.org/xapi/video/verbs/seeked"
109114
verb_display = "seeked"
115+
116+
117+
class CompletedVideo(BaseVideo):
118+
verb = "http://adlnet.gov/expapi/verbs/completed"
119+
verb_display = "completed"
120+
121+
122+
class TranscriptEnabled(BaseVideo):
123+
verb = "http://adlnet.gov/expapi/verbs/interacted"
124+
verb_display = "interacted"
125+
enabled = True
126+
127+
128+
class TranscriptDisabled(BaseVideo):
129+
verb = "http://adlnet.gov/expapi/verbs/interacted"
130+
verb_display = "interacted"

0 commit comments

Comments
 (0)