forked from apluslms/a-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sis.py
89 lines (70 loc) · 2.71 KB
/
sis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import importlib
import logging
from typing import List, Tuple
from django.conf import settings
logger = logging.getLogger('aplus.course')
class StudentInfoSystem:
"""Base class for university-specific SIS system extensions, such as SISU at Aalto."""
def get_instances(self, course: str) -> List[Tuple[str, str]]: # pylint: disable=unused-argument
"""
Get active course instances from SIS based on the course code.
Parameters
----------
course
Course code for which instances are fetched
Returns
-------
List of tuples representing instances. The first part of the tuple is an
identifier by which specific instance data can be found in the API. The second part
is an instance description shown to the user.
"""
return []
def get_course_data(self, id: str) -> dict: # pylint: disable=unused-argument redefined-builtin
"""
Get course data (teachers, start/end times) from the SIS system.
Parameters
----------
id
SIS identifier of the course instance
Returns
-------
Dictionary of course data. Currently possible keys are 'starting_time',
'ending_time' and 'teachers' (list of teacher usernames).
"""
return {}
def get_participants(self, id: str) -> List[str]: # pylint: disable=unused-argument redefined-builtin
"""
Get participating students from the SIS system.
Parameters
----------
id
SIS identifier of the course instance
Returns
-------
List of student identifiers.
"""
return []
def get_sis_configuration() -> StudentInfoSystem:
'''
Loads the proper SIS plugin based on settings.
Returns
-------
StudentInfoSystem - inherited object that implements university-specific
functionality and APIs for SIS interactions.
'''
if not hasattr(settings, 'SIS_PLUGIN_MODULE') or not hasattr(settings, 'SIS_PLUGIN_CLASS'):
logger.debug(
'"course.sis.get_sis_configuration()" called but SIS settings are missing. '
'Check "settings.SIS_PLUGIN_MODULE" and "settings.SIS_PLUGIN_CLASS".'
)
return None
mod = importlib.import_module(settings.SIS_PLUGIN_MODULE, package='course')
pluginclass = getattr(mod, settings.SIS_PLUGIN_CLASS)
if pluginclass is None:
raise NameError(
f'SIS plugin module "{settings.SIS_PLUGIN_MODULE}" does not define '
f'the class "{settings.SIS_PLUGIN_CLASS}". '
'Check "settings.SIS_PLUGIN_MODULE" and "settings.SIS_PLUGIN_CLASS".',
)
plugin = pluginclass()
return plugin