How to use the nbgrader.api.InvalidEntry function in nbgrader

To help you get started, we’ve selected a few nbgrader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter / nbgrader / nbgrader / api.py View on Github external
additional keyword arguments for :class:`~nbgrader.api.GradeCell`

        Returns
        -------
        grade_cell : :class:`~nbgrader.api.GradeCell`

        """

        notebook = self.find_notebook(notebook, assignment)
        grade_cell = GradeCell(name=name, notebook=notebook, **kwargs)
        self.db.add(grade_cell)
        try:
            self.db.commit()
        except (IntegrityError, FlushError) as e:
            self.db.rollback()
            raise InvalidEntry(*e.args)
        return grade_cell
github jupyter / nbgrader / nbgrader / api.py View on Github external
additional keyword arguments for the :class:`~nbgrader.api.Assignment` object

        Returns
        -------
        assignment : :class:`~nbgrader.api.Assignment`

        """
        if 'duedate' in kwargs:
            kwargs['duedate'] = utils.parse_utc(kwargs['duedate'])
        assignment = Assignment(name=name, **kwargs)
        self.db.add(assignment)
        try:
            self.db.commit()
        except (IntegrityError, FlushError) as e:
            self.db.rollback()
            raise InvalidEntry(*e.args)
        return assignment
github jupyter / nbgrader / nbgrader / api.py View on Github external
student : string
            the name of a student

        """
        submission = self.find_submission(assignment, student)

        for notebook in submission.notebooks:
            self.remove_submission_notebook(notebook.name, assignment, student)

        self.db.delete(submission)

        try:
            self.db.commit()
        except (IntegrityError, FlushError) as e:
            self.db.rollback()
            raise InvalidEntry(*e.args)
github jupyter / nbgrader / nbgrader / api.py View on Github external
the name of a student

        """
        submission = self.find_submission_notebook(notebook, assignment, student)

        for grade in submission.grades:
            self.db.delete(grade)
        for comment in submission.comments:
            self.db.delete(comment)
        self.db.delete(submission)

        try:
            self.db.commit()
        except (IntegrityError, FlushError) as e:
            self.db.rollback()
            raise InvalidEntry(*e.args)
github jupyter / nbgrader / nbgrader / api.py View on Github external
-------
        source_cell : :class:`~nbgrader.api.SourceCell`

        """

        try:
            source_cell = self.find_source_cell(name, notebook, assignment)
        except MissingEntry:
            source_cell = self.add_source_cell(name, notebook, assignment, **kwargs)
        else:
            for attr in kwargs:
                setattr(source_cell, attr, kwargs[attr])
            try:
                self.db.commit()
            except (IntegrityError, FlushError) as e:
                raise InvalidEntry(*e.args)

        return source_cell
github jupyter / nbgrader / nbgrader / api.py View on Github external
additional keyword arguments for the :class:`~nbgrader.api.Notebook` object

        Returns
        -------
        notebook : :class:`~nbgrader.api.Notebook`

        """

        notebook = Notebook(
            name=name, assignment=self.find_assignment(assignment), **kwargs)
        self.db.add(notebook)
        try:
            self.db.commit()
        except (IntegrityError, FlushError) as e:
            self.db.rollback()
            raise InvalidEntry(*e.args)
        return notebook
github jupyter / nbgrader / nbgrader / api.py View on Github external
try:
            submission = self.find_submission(assignment, student)
        except MissingEntry:
            submission = self.add_submission(assignment, student, **kwargs)
        else:
            for attr in kwargs:
                if attr == 'timestamp':
                    setattr(submission, attr, utils.parse_utc(kwargs[attr]))
                else:
                    setattr(submission, attr, kwargs[attr])
            try:
                self.db.commit()
            except (IntegrityError, FlushError) as e:
                self.db.rollback()
                raise InvalidEntry(*e.args)

        return submission