Skip to content

Commit 6f2d091

Browse files
authored
Merge pull request #77 from Learnosity/LRN-44310/docs/add-authoraide-api-quickstart-demo
[DOC] Add Author Aide API to the quickstart demo - LRN-44310
2 parents c51fff4 + 10bfeed commit 6f2d091

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
## [v0.3.8] - 2024-05-28
11+
### Added
12+
- Added a quickstart demo for Authoraide API.
13+
1014
## [v0.3.7] - 2024-05-28
1115
### Fixed
1216
- Added the authoraide key in the services array of Init class.

docs/quickstart/assessment/standalone_assessment.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
"domain": host,
3333
}
3434

35+
# Author Aide does not accept user_id so we need a separate security object
36+
authorAideSecurity = {
37+
"consumer_key": config.consumer_key,
38+
# Change to the domain used in the browser, e.g. 127.0.0.1, learnosity.com
39+
"domain": host,
40+
}
41+
3542
# Items API configuration parameters.
3643
items_request = {
3744
# Unique student identifier, a UUID generated above.
@@ -261,6 +268,16 @@
261268
}
262269
}
263270

271+
# Author Aide API configuration parameters.
272+
author_aide_request = {
273+
"user": {
274+
"id": 'python-demo-user',
275+
"firstname": 'Demos',
276+
"lastname": 'User',
277+
"email": 'demos@learnosity.com'
278+
}
279+
}
280+
264281
# Set up Learnosity initialization data.
265282
initItems = Init(
266283
"items", security, config.consumer_secret,
@@ -287,12 +304,18 @@
287304
request = question_editor_request
288305
)
289306

307+
initAuthorAide = Init(
308+
"authoraide", authorAideSecurity, config.consumer_secret,
309+
request = author_aide_request
310+
)
311+
290312
# Generated request(initOptions) w.r.t all apis
291313
generated_request_Items = initItems.generate()
292314
generated_request_Questions = initQuestions.generate()
293315
generated_request_Author = initAuthor.generate()
294316
generated_request_Reports = initReports.generate()
295317
generated_request_QuestionEditor = initQuestionEditor.generate()
318+
generated_request_AuthorAide = initAuthorAide.generate()
296319

297320
# - - - - - - Section 2: your web page configuration - - - - - -#
298321

@@ -348,6 +371,10 @@ def do_GET(self):
348371
<td>Question Editor API</td>
349372
<td><a href="/questioneditorapi">Here</a></td>
350373
</tr>
374+
<tr>
375+
<td>Author Aide API</td>
376+
<td><a href="/authoraideapi">Here</a></td>
377+
</tr>
351378
</table>
352379
</body>
353380
</html>
@@ -492,6 +519,29 @@ def do_GET(self):
492519
response = template.render(name='Standalone Question Editor API Example', generated_request=generated_request_QuestionEditor)
493520
self.createResponse(response)
494521

522+
if self.path.endswith("/authoraideapi"):
523+
# Define the page HTML, as a Jinja template, with {{variables}} passed in.
524+
template = Template("""<!DOCTYPE html>
525+
<html>
526+
<body>
527+
<h1>{{ name }}</title></h1>
528+
<!-- Author Aide API will render into this div. -->
529+
<div id="aiApp"></div>
530+
<!-- Load the Author Aide API library. -->
531+
<script src=\"https://authoraide.learnosity.com\"></script>
532+
<!-- Initiate Author Aide API -->
533+
<script>
534+
var authorAideApp = LearnosityAuthorAide.init( {{ generated_request }}, '#aiApp' );
535+
</script>
536+
</body>
537+
</html>
538+
""")
539+
540+
# Render the page template and grab the variables needed.
541+
response = template.render(name='Author Aide API Example', generated_request=generated_request_AuthorAide)
542+
543+
self.createResponse(response)
544+
495545
def main():
496546
web_server = HTTPServer((host, port), LearnosityServer)
497547
print("Server started http://%s:%s. Press Ctrl-c to quit." % (host, port))

learnosity_sdk/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = 'v0.3.7'
1+
__version__ = 'v0.3.8'

0 commit comments

Comments
 (0)