2: 2021-07-14 (水) 16:28:08 iseki |
3: 2021-07-14 (水) 18:33:46 iseki |
| ** Hack for Moodle LTI [#w4c22429] | | ** Hack for Moodle LTI [#w4c22429] |
- | *** Moodle が JupyterHub に送るデータ [#uff7064e] | + | *** [[JupyterHub]] の Swapner での受け取り処理 [#vd91a1e1] |
- | - args | + | - jupyterhub_config.py |
| + | import os |
| + | os.environ['JUPYTERHUB_CRYPT_KEY'] = 'c283a5e73c8f74cdc8c6fef5415f1c97948a5a5450b5dc7524b9939093a2bd1d' |
| + | ....... |
| + | ....... |
| + | def userdata_hook(self, auth_state): |
| + | print("AURTH") |
| + | print(auth_state) |
| + | ....... |
| + | ....... |
| + | c.Spawner.auth_state_hook = ProjectDockerSpawner.userdata_hook |
| + | c.Authenticator.enable_auth_state = True |
| + | |
| + | - 環境変数 の設定が必要 |
| + | -- キーは openssl rand -hex 32 で生成 |
| + | |
| + | AUTH |
| + | { |
| + | 'user_id': '3185', |
| + | 'lis_person_sourcedid': '', |
| + | 'roles': 'Learner', |
| + | 'context_id': '98', |
| + | 'context_label': 'TEST2_1', |
| + | 'context_title': 'TEST2 コピー 1', |
| + | 'resource_link_title': 'JupyterHub', |
| + | 'resource_link_description': '', |
| + | 'resource_link_id': '10', |
| + | 'context_type': 'CourseSection', |
| + | 'lis_course_section_sourcedid': '', |
| + | 'lis_result_sourcedid': '{ |
| + | "data":{ |
| + | "instanceid":"10", |
| + | "userid":"3185", |
| + | "typeid":"2", |
| + | "launchid":2017829967 |
| + | }, |
| + | "hash":"308a29656cd8db974c65870ad7f75070c2fc34404b12536ee45c5a06b4e1f5f8" |
| + | }', |
| + | 'lis_outcome_service_url': 'https://el.mml.tuis.ac.jp/moodle/mod/lti/service.php', |
| + | 'lis_person_name_given': 'j19344', |
| + | 'lis_person_name_family': 'j19344', |
| + | 'lis_person_name_full': 'j19344 j19344', |
| + | 'ext_user_username': 'j19344hn', |
| + | 'lis_person_contact_email_primary': 'j19344hn@edu.tuis.ac.jp', |
| + | 'launch_presentation_locale': 'ja', |
| + | 'ext_lms': 'moodle-2', |
| + | 'tool_consumer_info_product_family_code': 'moodle', |
| + | 'tool_consumer_info_version': '2020110902', |
| + | 'lti_version': 'LTI-1p0', |
| + | 'lti_message_type': 'basic-lti-launch-request', |
| + | 'tool_consumer_instance_guid': '5384b0f81508b987c188b1985f5cd4e0', |
| + | 'tool_consumer_instance_name': 'EL MML', |
| + | 'tool_consumer_instance_description': 'e-Learning of MML', |
| + | 'launch_presentation_document_target': 'window', |
| + | 'launch_presentation_return_url': 'https://el.mml.tuis.ac.jp/moodle/mod/lti/return.php?course=98&launch_container=4&instanceid=10&sesskey=3KFd8j8MPC' |
| + | } |
| + | |
| + | **** JupyterHub へのパラメータ送信 [#h7f6bcb7] |
| + | - Moodleの外部ツールの設定で,「一般」の「さらに表示する」でカスタムパラメータを指定すると,JupyterHub に任意のパラメータを送れる. |
| + | -- ''XXX=ZZZ'' と入力すると,上記方法で ''{'costom_xxx': 'ZZZ'}'' として受け取れる(キーは小文字化される). |
| + | |
| + | |
| + | - 予約語 |
| + | -- next= |
| + | #br |
| + | |
| + | *** [[JupyterHub]] が [[Moodle]] から受け取ったデータ [#uff7064e] |
| + | - 一般的に認証モジュールが引数として受け取る値 |
| { | | { |
| 'oauth_version': '1.0', | | 'oauth_version': '1.0', |
| 'oauth_signature': 't+ctcGhvev5hDh/Tz21NOYFBw8s=' | | 'oauth_signature': 't+ctcGhvev5hDh/Tz21NOYFBw8s=' |
| } | | } |
- | #br | |
- | *** Jupyter 側での受け取り [#vd91a1e1] | |
| #br | | #br |