예제 #1
0
    def is_block_complete_for_assignments(self, completion_service):
        """
        Considers a block complete only if all scored & graded leaf blocks are complete.

        This is different from the normal `complete` flag because children of the block that are informative (like
        readings or videos) do not count. We only care about actual homework content.

        Compare with is_block_structure_complete_for_assignments in course_experience/utils.py, which does the same
        calculation, but for a BlockStructure node and its children.

        Returns:
            True if complete
            False if not
            None if no assignments present or no completion info present (don't show any past-due or complete info)
        """
        if not completion_service or not completion_service.completion_tracking_enabled(
        ):
            return None

        children = completion_service.get_completable_children(self)
        children_locations = [child.scope_ids.usage_id for child in children]
        completions = completion_service.get_completions(children_locations)

        all_complete = None
        for child in children:
            complete = completions[child.scope_ids.usage_id] == 1
            if is_xblock_an_assignment(child):
                if not complete:
                    return False
                all_complete = True

        return all_complete
예제 #2
0
    def _is_block_shiftable(cls, xblock, category):
        """
        Test if the xblock would be solvable if we were to shift dates.

        Only xblocks with an is_past_due method (e.g. capa and LTI) will be considered possibly shiftable.
        """
        if not hasattr(xblock, 'is_past_due'):
            return False

        if hasattr(xblock, 'attempts') and hasattr(xblock, 'max_attempts'):
            can_attempt = xblock.max_attempts is None or xblock.attempts < xblock.max_attempts
        else:
            can_attempt = True

        if callable(xblock.is_past_due):
            is_past_due = xblock.is_past_due()
        else:
            PersonalizedLearnerScheduleCallToAction._log_past_due_warning(type(xblock).__name__)
            is_past_due = xblock.is_past_due

        can_shift = xblock.self_paced and can_attempt and is_past_due

        # Note: we will still show the CTA at the xblock level (next to the submit button) regardless
        # of if the xblock is an assignment (meaning graded *and* scored)
        if category == cls.VERTICAL_BANNER:
            can_shift = can_shift and is_xblock_an_assignment(xblock)

        return can_shift
예제 #3
0
def _has_assignment_blocks(item):
    """
    Check if a given block contains children that are assignments.
    Assignments have graded, has_score and nonzero weight attributes.
    """
    return any(
        is_xblock_an_assignment(block)
        for block in traverse_pre_order(item, get_children, leaf_filter))