lms.model.groupsets

  1import typing
  2
  3import lms.model.base
  4import lms.model.groups
  5import lms.model.query
  6import lms.model.users
  7
  8class GroupSetQuery(lms.model.query.BaseQuery):
  9    """
 10    A class for the different ways one can attempt to reference an LMS group set.
 11    In general, a group set can be queried by:
 12     - LMS Group Set ID (`id`)
 13     - Full Name (`name`)
 14     - f"{name} ({id})"
 15    """
 16
 17    _include_email = False
 18
 19class ResolvedGroupSetQuery(lms.model.query.ResolvedBaseQuery, GroupSetQuery):
 20    """
 21    A GroupSetQuery that has been resolved (verified) from a real group set instance.
 22    """
 23
 24    _include_email = False
 25
 26    def __init__(self,
 27            group_set: 'GroupSet',
 28            **kwargs: typing.Any) -> None:
 29        super().__init__(id = group_set.id, name = group_set.name, **kwargs)
 30
 31class GroupSet(lms.model.base.BaseType):
 32    """
 33    A collection of groups with a common purpose
 34    (e.g., a set of student groups for an assignment).
 35    """
 36
 37    CORE_FIELDS = [
 38        'id', 'name',
 39    ]
 40
 41    def __init__(self,
 42            id: typing.Union[str, int, None] = None,
 43            name: typing.Union[str, None] = None,
 44            **kwargs: typing.Any) -> None:
 45        super().__init__(**kwargs)
 46
 47        if (id is None):
 48            raise ValueError("Group sets must have an id.")
 49
 50        self.id: str = str(id)
 51        """ The LMS's identifier for this group set. """
 52
 53        self.name: typing.Union[str, None] = name
 54        """ The display name of this group set. """
 55
 56    def to_query(self) -> ResolvedGroupSetQuery:
 57        """ Get a query representation of this group set. """
 58
 59        return ResolvedGroupSetQuery(self)
 60
 61class GroupSetMembership(lms.model.base.BaseType):
 62    """
 63    An instance of a user being in a group set.
 64    """
 65
 66    CORE_FIELDS = [
 67        'groupset', 'group', 'user',
 68    ]
 69
 70    def __init__(self,
 71            user: lms.model.users.UserQuery,
 72            groupset: GroupSetQuery,
 73            group: lms.model.groups.GroupQuery,
 74            **kwargs: typing.Any) -> None:
 75        super().__init__(**kwargs)
 76
 77        self.groupset: GroupSetQuery = groupset
 78        """ The group set the group belongs to. """
 79
 80        self.group: lms.model.groups.GroupQuery = group
 81        """ The group the user belongs to. """
 82
 83        self.user: lms.model.users.UserQuery = user
 84        """ The user in a group. """
 85
 86    def update_queries(self,
 87            groupset: typing.Union[ResolvedGroupSetQuery, None] = None,
 88            users: typing.Union[typing.Dict[str, lms.model.users.ResolvedUserQuery], None] = None,
 89            groups: typing.Union[typing.Dict[str, lms.model.groups.ResolvedGroupQuery], None] = None,
 90            ) -> None:
 91        """
 92        Update the queries with resolved variants.
 93        The maps should be keyed by respective ids.
 94        """
 95
 96        if (groupset is not None):
 97            self.groupset = groupset
 98
 99        if ((users is not None) and (self.user.id in users)):
100            self.user = users[self.user.id]
101
102        if ((groups is not None) and (self.group.id in groups)):
103            self.group = groups[self.group.id]
class GroupSetQuery(lms.model.query.BaseQuery):
 9class GroupSetQuery(lms.model.query.BaseQuery):
10    """
11    A class for the different ways one can attempt to reference an LMS group set.
12    In general, a group set can be queried by:
13     - LMS Group Set ID (`id`)
14     - Full Name (`name`)
15     - f"{name} ({id})"
16    """
17
18    _include_email = False

A class for the different ways one can attempt to reference an LMS group set. In general, a group set can be queried by:

  • LMS Group Set ID (id)
  • Full Name (name)
  • f"{name} ({id})"
class ResolvedGroupSetQuery(lms.model.query.ResolvedBaseQuery, GroupSetQuery):
20class ResolvedGroupSetQuery(lms.model.query.ResolvedBaseQuery, GroupSetQuery):
21    """
22    A GroupSetQuery that has been resolved (verified) from a real group set instance.
23    """
24
25    _include_email = False
26
27    def __init__(self,
28            group_set: 'GroupSet',
29            **kwargs: typing.Any) -> None:
30        super().__init__(id = group_set.id, name = group_set.name, **kwargs)

A GroupSetQuery that has been resolved (verified) from a real group set instance.

ResolvedGroupSetQuery(group_set: GroupSet, **kwargs: Any)
27    def __init__(self,
28            group_set: 'GroupSet',
29            **kwargs: typing.Any) -> None:
30        super().__init__(id = group_set.id, name = group_set.name, **kwargs)
class GroupSet(lms.model.base.BaseType):
32class GroupSet(lms.model.base.BaseType):
33    """
34    A collection of groups with a common purpose
35    (e.g., a set of student groups for an assignment).
36    """
37
38    CORE_FIELDS = [
39        'id', 'name',
40    ]
41
42    def __init__(self,
43            id: typing.Union[str, int, None] = None,
44            name: typing.Union[str, None] = None,
45            **kwargs: typing.Any) -> None:
46        super().__init__(**kwargs)
47
48        if (id is None):
49            raise ValueError("Group sets must have an id.")
50
51        self.id: str = str(id)
52        """ The LMS's identifier for this group set. """
53
54        self.name: typing.Union[str, None] = name
55        """ The display name of this group set. """
56
57    def to_query(self) -> ResolvedGroupSetQuery:
58        """ Get a query representation of this group set. """
59
60        return ResolvedGroupSetQuery(self)

A collection of groups with a common purpose (e.g., a set of student groups for an assignment).

GroupSet( id: Union[str, int, NoneType] = None, name: Optional[str] = None, **kwargs: Any)
42    def __init__(self,
43            id: typing.Union[str, int, None] = None,
44            name: typing.Union[str, None] = None,
45            **kwargs: typing.Any) -> None:
46        super().__init__(**kwargs)
47
48        if (id is None):
49            raise ValueError("Group sets must have an id.")
50
51        self.id: str = str(id)
52        """ The LMS's identifier for this group set. """
53
54        self.name: typing.Union[str, None] = name
55        """ The display name of this group set. """
CORE_FIELDS = ['id', 'name']

The common fields shared across backends for this type that are used for comparison and other operations. Child classes should set this to define how comparisons are made.

id: str

The LMS's identifier for this group set.

name: Optional[str]

The display name of this group set.

def to_query(self) -> ResolvedGroupSetQuery:
57    def to_query(self) -> ResolvedGroupSetQuery:
58        """ Get a query representation of this group set. """
59
60        return ResolvedGroupSetQuery(self)

Get a query representation of this group set.

class GroupSetMembership(lms.model.base.BaseType):
 62class GroupSetMembership(lms.model.base.BaseType):
 63    """
 64    An instance of a user being in a group set.
 65    """
 66
 67    CORE_FIELDS = [
 68        'groupset', 'group', 'user',
 69    ]
 70
 71    def __init__(self,
 72            user: lms.model.users.UserQuery,
 73            groupset: GroupSetQuery,
 74            group: lms.model.groups.GroupQuery,
 75            **kwargs: typing.Any) -> None:
 76        super().__init__(**kwargs)
 77
 78        self.groupset: GroupSetQuery = groupset
 79        """ The group set the group belongs to. """
 80
 81        self.group: lms.model.groups.GroupQuery = group
 82        """ The group the user belongs to. """
 83
 84        self.user: lms.model.users.UserQuery = user
 85        """ The user in a group. """
 86
 87    def update_queries(self,
 88            groupset: typing.Union[ResolvedGroupSetQuery, None] = None,
 89            users: typing.Union[typing.Dict[str, lms.model.users.ResolvedUserQuery], None] = None,
 90            groups: typing.Union[typing.Dict[str, lms.model.groups.ResolvedGroupQuery], None] = None,
 91            ) -> None:
 92        """
 93        Update the queries with resolved variants.
 94        The maps should be keyed by respective ids.
 95        """
 96
 97        if (groupset is not None):
 98            self.groupset = groupset
 99
100        if ((users is not None) and (self.user.id in users)):
101            self.user = users[self.user.id]
102
103        if ((groups is not None) and (self.group.id in groups)):
104            self.group = groups[self.group.id]

An instance of a user being in a group set.

GroupSetMembership( user: lms.model.users.UserQuery, groupset: GroupSetQuery, group: lms.model.groups.GroupQuery, **kwargs: Any)
71    def __init__(self,
72            user: lms.model.users.UserQuery,
73            groupset: GroupSetQuery,
74            group: lms.model.groups.GroupQuery,
75            **kwargs: typing.Any) -> None:
76        super().__init__(**kwargs)
77
78        self.groupset: GroupSetQuery = groupset
79        """ The group set the group belongs to. """
80
81        self.group: lms.model.groups.GroupQuery = group
82        """ The group the user belongs to. """
83
84        self.user: lms.model.users.UserQuery = user
85        """ The user in a group. """
CORE_FIELDS = ['groupset', 'group', 'user']

The common fields shared across backends for this type that are used for comparison and other operations. Child classes should set this to define how comparisons are made.

groupset: GroupSetQuery

The group set the group belongs to.

The group the user belongs to.

The user in a group.

def update_queries( self, groupset: Optional[ResolvedGroupSetQuery] = None, users: Optional[Dict[str, lms.model.users.ResolvedUserQuery]] = None, groups: Optional[Dict[str, lms.model.groups.ResolvedGroupQuery]] = None) -> None:
 87    def update_queries(self,
 88            groupset: typing.Union[ResolvedGroupSetQuery, None] = None,
 89            users: typing.Union[typing.Dict[str, lms.model.users.ResolvedUserQuery], None] = None,
 90            groups: typing.Union[typing.Dict[str, lms.model.groups.ResolvedGroupQuery], None] = None,
 91            ) -> None:
 92        """
 93        Update the queries with resolved variants.
 94        The maps should be keyed by respective ids.
 95        """
 96
 97        if (groupset is not None):
 98            self.groupset = groupset
 99
100        if ((users is not None) and (self.user.id in users)):
101            self.user = users[self.user.id]
102
103        if ((groups is not None) and (self.group.id in groups)):
104            self.group = groups[self.group.id]

Update the queries with resolved variants. The maps should be keyed by respective ids.