|
32 | 32 | "domain": host,
|
33 | 33 | }
|
34 | 34 |
|
| 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 | + |
35 | 42 | # Items API configuration parameters.
|
36 | 43 | items_request = {
|
37 | 44 | # Unique student identifier, a UUID generated above.
|
|
261 | 268 | }
|
262 | 269 | }
|
263 | 270 |
|
| 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 | + |
264 | 281 | # Set up Learnosity initialization data.
|
265 | 282 | initItems = Init(
|
266 | 283 | "items", security, config.consumer_secret,
|
|
287 | 304 | request = question_editor_request
|
288 | 305 | )
|
289 | 306 |
|
| 307 | +initAuthorAide = Init( |
| 308 | + "authoraide", authorAideSecurity, config.consumer_secret, |
| 309 | + request = author_aide_request |
| 310 | +) |
| 311 | + |
290 | 312 | # Generated request(initOptions) w.r.t all apis
|
291 | 313 | generated_request_Items = initItems.generate()
|
292 | 314 | generated_request_Questions = initQuestions.generate()
|
293 | 315 | generated_request_Author = initAuthor.generate()
|
294 | 316 | generated_request_Reports = initReports.generate()
|
295 | 317 | generated_request_QuestionEditor = initQuestionEditor.generate()
|
| 318 | +generated_request_AuthorAide = initAuthorAide.generate() |
296 | 319 |
|
297 | 320 | # - - - - - - Section 2: your web page configuration - - - - - -#
|
298 | 321 |
|
@@ -348,6 +371,10 @@ def do_GET(self):
|
348 | 371 | <td>Question Editor API</td>
|
349 | 372 | <td><a href="/questioneditorapi">Here</a></td>
|
350 | 373 | </tr>
|
| 374 | + <tr> |
| 375 | + <td>Author Aide API</td> |
| 376 | + <td><a href="/authoraideapi">Here</a></td> |
| 377 | + </tr> |
351 | 378 | </table>
|
352 | 379 | </body>
|
353 | 380 | </html>
|
@@ -492,6 +519,29 @@ def do_GET(self):
|
492 | 519 | response = template.render(name='Standalone Question Editor API Example', generated_request=generated_request_QuestionEditor)
|
493 | 520 | self.createResponse(response)
|
494 | 521 |
|
| 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 | + |
495 | 545 | def main():
|
496 | 546 | web_server = HTTPServer((host, port), LearnosityServer)
|
497 | 547 | print("Server started http://%s:%s. Press Ctrl-c to quit." % (host, port))
|
|
0 commit comments