Ejemplo n.º 1
0
    def limit_result_set(self, start, end):
        """By default, searches return all matching results.

        This method restricts the number of results by setting the start
        and end of the result set, starting from 1. The starting and
        ending results can be used for paging results when a certain
        ordering is requested. The ending position must be greater than
        the starting position.

        arg:    start (cardinal): the start of the result set
        arg:    end (cardinal): the end of the result set
        raise:  InvalidArgument - ``end`` is less than or equal to
                ``start``
        *compliance: mandatory -- This method must be implemented.*

        """
        if not isinstance(start, int) or not isinstance(end, int):
            raise errors.InvalidArgument(
                'start and end arguments must be integers.')
        if end <= start:
            raise errors.InvalidArgument('End must be greater than start.')

        # because Python is 0 indexed
        # Spec says that passing in (1, 25) should include 25 entries (1 - 25)
        # Python indices 0 - 24
        # Python [#:##] stops before the last index, but does not include it
        self._limit_result_set_start = start - 1
        self._limit_result_set_end = end
Ejemplo n.º 2
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_children(self, child_ids):
        """Sets the children.

        arg:    child_ids (osid.id.Id[]): the children``Ids``
        raise:  InvalidArgument - ``child_ids`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        *compliance: mandatory -- This method must be implemented.*

        """
        if not self._supports_simple_sequencing():
            raise AttributeError(
                'This Assessment Part does not support simple child sequencing'
            )
        if not isinstance(child_ids, list):
            raise errors.InvalidArgument()
        if self.get_children_metadata().is_read_only():
            raise errors.NoAccess()
        idstr_list = []
        for object_id in child_ids:
            if not self._is_valid_id(object_id):
                raise errors.InvalidArgument()
            if str(object_id) not in idstr_list:
                idstr_list.append(str(object_id))
        self._my_map['childIds'] = idstr_list
Ejemplo n.º 3
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_domain(self, domain):
        """Sets a domain.

        arg:    domain (string): the new domain
        raise:  InvalidArgument - ``domain`` is invalid
        raise:  NoAccess - ``domain`` cannot be modified
        raise:  NullArgument - ``domain`` is ``null``
        *compliance: mandatory -- This method must be implemented.*

        """
        if self.get_domain_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_string(domain, self.get_domain_metadata()):
            raise errors.InvalidArgument()
        self._my_map['domain']['text'] = domain
Ejemplo n.º 4
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_avatar(self, asset_id):
        """Sets the avatar asset.

        arg:    asset_id (osid.id.Id): an asset ``Id``
        raise:  InvalidArgument - ``asset_id`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.resource.ResourceForm.set_avatar_template
        if self.get_avatar_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_id(asset_id):
            raise errors.InvalidArgument()
        self._my_map['avatarId'] = str(asset_id)
Ejemplo n.º 5
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_display_label(self, display_label):
        """Seta a display label.

        arg:    display_label (string): the new display label
        raise:  InvalidArgument - ``display_label`` is invalid
        raise:  NoAccess - ``display_label`` cannot be modified
        raise:  NullArgument - ``display_label`` is ``null``
        *compliance: mandatory -- This method must be implemented.*

        """
        if self.get_display_label_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_string(display_label,
                                     self.get_display_label_metadata()):
            raise errors.InvalidArgument()
        self._my_map['displayLabel']['text'] = display_label
Ejemplo n.º 6
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_priority(self, priority):
        """Sets the priority.

        arg:    priority (osid.type.Type): the new priority
        raise:  InvalidArgument - ``priority`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        raise:  NullArgument - ``priority`` is ``null``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.logging.LogEntryForm.set_priority
        if self.get_priority_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_type(priority):
            raise errors.InvalidArgument()
        self._my_map['priority'] = str(priority)
Ejemplo n.º 7
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_group(self, group):
        """Sets the resource as a group.

        arg:    group (boolean): ``true`` if this resource is a group,
                ``false`` otherwise
        raise:  InvalidArgument - ``group`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.resource.ResourceForm.set_group_template
        if self.get_group_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_boolean(group):
            raise errors.InvalidArgument()
        self._my_map['group'] = group
Ejemplo n.º 8
0
    def set_rating(self, grade_id):
        """Sets the rating.

        arg:    grade_id (osid.id.Id): the new rating
        raise:  InvalidArgument - ``grade_id`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        raise:  NullArgument - ``grade_id`` is ``null``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.resource.ResourceForm.set_avatar_template
        if self.get_rating_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_id(grade_id):
            raise errors.InvalidArgument()
        self._my_map['ratingId'] = str(grade_id)
Ejemplo n.º 9
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_cumulative(self, cumulative):
        """Applies this rule to all previous assessment parts.

        arg:    cumulative (boolean): ``true`` to apply to all previous
                assessment parts. ``false`` to apply to the immediate
                previous assessment part
        raise:  InvalidArgument - ``cumulative`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.resource.ResourceForm.set_group_template
        if self.get_cumulative_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_boolean(cumulative):
            raise errors.InvalidArgument()
        self._my_map['cumulative'] = cumulative
Ejemplo n.º 10
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_timestamp(self, timestamp):
        """Sets the timestamp.

        arg:    timestamp (osid.calendaring.DateTime): the new timestamp
        raise:  InvalidArgument - ``timestamp`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        raise:  NullArgument - ``timestamp`` is ``null``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.assessment.AssessmentOfferedForm.set_start_time_template
        if self.get_timestamp_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_date_time(
                timestamp,
                self.get_timestamp_metadata()):
            raise errors.InvalidArgument()
        self._my_map['timestamp'] = timestamp
Ejemplo n.º 11
0
Archivo: objects.py Proyecto: UOC/dlkit
    def set_allocated_time(self, time):
        """Sets the allocated time.

        arg:    time (osid.calendaring.Duration): the allocated time
        raise:  InvalidArgument - ``time`` is invalid
        raise:  NoAccess - ``Metadata.isReadOnly()`` is ``true``
        *compliance: mandatory -- This method must be implemented.*

        """
        # Implemented from template for osid.assessment.AssessmentOfferedForm.set_duration_template
        if self.get_allocated_time_metadata().is_read_only():
            raise errors.NoAccess()
        if not self._is_valid_duration(time,
                                       self.get_allocated_time_metadata()):
            raise errors.InvalidArgument()
        map = dict()
        map['days'] = time.days
        map['seconds'] = time.seconds
        map['microseconds'] = time.microseconds
        self._my_map['allocatedTime'] = map