Skip to content

Commit

Permalink
[DOC] Add Author Aide API to the quickstart demo - LRN-44310
Browse files Browse the repository at this point in the history
  • Loading branch information
walsh-conor committed Jul 16, 2024
1 parent c51fff4 commit 10bfeed
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v0.3.8] - 2024-05-28
### Added
- Added a quickstart demo for Authoraide API.

## [v0.3.7] - 2024-05-28
### Fixed
- Added the authoraide key in the services array of Init class.
Expand Down
50 changes: 50 additions & 0 deletions docs/quickstart/assessment/standalone_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"domain": host,
}

# Author Aide does not accept user_id so we need a separate security object
authorAideSecurity = {
"consumer_key": config.consumer_key,
# Change to the domain used in the browser, e.g. 127.0.0.1, learnosity.com
"domain": host,
}

# Items API configuration parameters.
items_request = {
# Unique student identifier, a UUID generated above.
Expand Down Expand Up @@ -261,6 +268,16 @@
}
}

# Author Aide API configuration parameters.
author_aide_request = {
"user": {
"id": 'python-demo-user',
"firstname": 'Demos',
"lastname": 'User',
"email": 'demos@learnosity.com'
}
}

# Set up Learnosity initialization data.
initItems = Init(
"items", security, config.consumer_secret,
Expand All @@ -287,12 +304,18 @@
request = question_editor_request
)

initAuthorAide = Init(
"authoraide", authorAideSecurity, config.consumer_secret,
request = author_aide_request
)

# Generated request(initOptions) w.r.t all apis
generated_request_Items = initItems.generate()
generated_request_Questions = initQuestions.generate()
generated_request_Author = initAuthor.generate()
generated_request_Reports = initReports.generate()
generated_request_QuestionEditor = initQuestionEditor.generate()
generated_request_AuthorAide = initAuthorAide.generate()

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

Expand Down Expand Up @@ -348,6 +371,10 @@ def do_GET(self):
<td>Question Editor API</td>
<td><a href="/questioneditorapi">Here</a></td>
</tr>
<tr>
<td>Author Aide API</td>
<td><a href="/authoraideapi">Here</a></td>
</tr>
</table>
</body>
</html>
Expand Down Expand Up @@ -492,6 +519,29 @@ def do_GET(self):
response = template.render(name='Standalone Question Editor API Example', generated_request=generated_request_QuestionEditor)
self.createResponse(response)

if self.path.endswith("/authoraideapi"):
# Define the page HTML, as a Jinja template, with {{variables}} passed in.
template = Template("""<!DOCTYPE html>
<html>
<body>
<h1>{{ name }}</title></h1>
<!-- Author Aide API will render into this div. -->
<div id="aiApp"></div>
<!-- Load the Author Aide API library. -->
<script src=\"https://authoraide.learnosity.com\"></script>
<!-- Initiate Author Aide API -->
<script>
var authorAideApp = LearnosityAuthorAide.init( {{ generated_request }}, '#aiApp' );
</script>
</body>
</html>
""")

# Render the page template and grab the variables needed.
response = template.render(name='Author Aide API Example', generated_request=generated_request_AuthorAide)

self.createResponse(response)

def main():
web_server = HTTPServer((host, port), LearnosityServer)
print("Server started http://%s:%s. Press Ctrl-c to quit." % (host, port))
Expand Down
2 changes: 1 addition & 1 deletion learnosity_sdk/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = 'v0.3.7'
__version__ = 'v0.3.8'

0 comments on commit 10bfeed

Please sign in to comment.