-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LTI 1.3 #1023
Draft
mpiraux
wants to merge
5
commits into
UCL-INGI:master
Choose a base branch
from
mpiraux:lti1.3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
LTI 1.3 #1023
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
29067a6
Reworks the cookieless session id from path to parameters
mpiraux 9b1d6e5
Implements basic LTI 1.3
mpiraux 11ebad4
Implements LTI AGS to report grade back to the LTI Platform
mpiraux 262f9fd
Separates LTI sessions from regular sessions
mpiraux e2200fd
Misc
mpiraux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,9 @@ | |
|
||
import copy | ||
import gettext | ||
import hashlib | ||
import re | ||
from typing import List | ||
from typing import Iterable, List | ||
|
||
from inginious.frontend.user_settings.course_user_setting import CourseUserSetting | ||
from inginious.common.tags import Tag | ||
|
@@ -18,6 +19,7 @@ | |
from inginious.frontend.task_dispensers.toc import TableOfContents | ||
from inginious.frontend.tasksets import _migrate_from_v_0_6 | ||
|
||
from pylti1p3.tool_config import ToolConfDict | ||
|
||
class Course(object): | ||
""" A course with some modification for users """ | ||
|
@@ -54,7 +56,7 @@ def __init__(self, courseid, content, taskset_factory, task_factory, plugin_mana | |
self._allow_preview = self._content.get('allow_preview', False) | ||
self._is_lti = self._content.get('is_lti', False) | ||
self._lti_url = self._content.get('lti_url', '') | ||
self._lti_keys = self._content.get('lti_keys', {}) | ||
self._lti_config = self._content.get('lti_config', {}) | ||
self._lti_send_back_grade = self._content.get('lti_send_back_grade', False) | ||
self._tags = {key: Tag(key, tag_dict, self.gettext) for key, tag_dict in self._content.get("tags", {}).items()} | ||
self._course_user_setting = {key: CourseUserSetting(key, | ||
|
@@ -82,7 +84,7 @@ def __init__(self, courseid, content, taskset_factory, task_factory, plugin_mana | |
self._groups_student_choice = False | ||
self._allow_unregister = False | ||
else: | ||
self._lti_keys = {} | ||
self._lti_config = {} | ||
self._lti_url = '' | ||
self._lti_send_back_grade = False | ||
|
||
|
@@ -162,9 +164,28 @@ def is_lti(self): | |
""" True if the current course is in LTI mode """ | ||
return self._is_lti | ||
|
||
def lti_keys(self): | ||
""" {name: key} for the LTI customers """ | ||
return self._lti_keys if self._is_lti else {} | ||
def lti_config(self): | ||
""" LTI Tool config dictionary. Specs are at https://github.com/dmitry-viskov/pylti1.3/blob/master/README.rst?plain=1#L70-L98 """ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There will be documentation part of this PR on this. |
||
return self._lti_config if self._is_lti else {} | ||
|
||
def lti_tool(self) -> ToolConfDict: | ||
""" LTI Tool object. """ | ||
lti_tool = ToolConfDict(self._lti_config) | ||
for iss in self._lti_config: | ||
for client_config in self._lti_config[iss]: | ||
lti_tool.set_private_key(iss, client_config['private_key'], client_id=client_config['client_id']) | ||
lti_tool.set_public_key(iss, client_config['public_key'], client_id=client_config['client_id']) | ||
return lti_tool | ||
|
||
def lti_platform_instances_ids(self) -> Iterable[str]: | ||
""" Set of LTI Platform instance ids registered for this course. """ | ||
for iss in self._lti_config: | ||
for client_config in self._lti_config[iss]: | ||
for deployment_id in client_config['deployment_ids']: | ||
yield '/'.join([iss, client_config['client_id'], deployment_id]) | ||
|
||
def lti_keyset_hash(self, issuer: str, client_id: str) -> str: | ||
return hashlib.md5((issuer + client_id).encode('utf-8')).digest().hex() | ||
|
||
def lti_url(self): | ||
""" Returns the URL to the external platform the course is hosted on """ | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_path
should now be used in all instances whereget_homepath
was used to build an URL. Templates still have access toget_homepath
when a public URL is needed, such that I didn't have to go thru all that code (esp. layout.html) by hand.