How to use the nbgrader.apps.baseapp.NbGrader 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 / apps / fetchapp.py View on Github external
aliases.update({
    "timezone": "Exchange.timezone",
    "course": "Exchange.course_id",
})

flags = {}
flags.update(nbgrader_flags)
flags.update({
    'replace': (
        {'ExchangeFetch' : {'replace_missing_files' : True}},
        "replace missing files, even if the assignment has already been fetched"
    ),
})


class FetchApp(NbGrader):

    name = u'nbgrader-fetch'
    description = u'Fetch an assignment from the nbgrader exchange'

    aliases = aliases
    flags = flags

    examples = """
        Fetch an assignment that an instructor has released. For the usage of students.

        You can run this command from any directory, but usually, you will have a
        directory where you are keeping your course assignments.

        To fetch an assignment by name into the current directory:

            nbgrader fetch assignment1
github jupyter / nbgrader / nbgrader / apps / baseapp.py View on Github external
def _classes_default(self):
        return [NbGrader]
github jupyter / nbgrader / nbgrader / apps / fetchassignmentapp.py View on Github external
aliases.update({
    "timezone": "Exchange.timezone",
    "course": "CourseDirectory.course_id",
})

flags = {}
flags.update(nbgrader_flags)
flags.update({
    'replace': (
        {'ExchangeFetchAssignment': {'replace_missing_files': True}},
        "replace missing files, even if the assignment has already been fetched"
    ),
})


class FetchAssignmentApp(NbGrader):

    name = u'nbgrader-fetch-assignment'
    description = u'Fetch an assignment from the nbgrader exchange'

    aliases = aliases
    flags = flags

    examples = """
        Fetch an assignment that an instructor has released. For the usage of students.

        You can run this command from any directory, but usually, you will have a
        directory where you are keeping your course assignments.

        To fetch an assignment by name into the current directory:

            nbgrader fetch_assignment assignment1
github jupyter / nbgrader / nbgrader / apps / updateapp.py View on Github external
import traceback

from nbformat import current_nbformat, read as orig_read, write as orig_write
from traitlets import Bool

from .baseapp import NbGrader
from ..nbgraderformat import MetadataValidator, write, ValidationError, SchemaTooNewError
from ..utils import find_all_notebooks

aliases = {
    'log-level': 'Application.log_level',
}
flags = {}


class UpdateApp(NbGrader):

    name = u'nbgrader-update'
    description = u'Update nbgrader notebook metadata'

    aliases = aliases
    flags = flags

    validate = Bool(True, help="whether to validate metadata after updating it").tag(config=True)

    examples = """
        nbgrader stores metadata in the JSON source of the notebooks. Previously,
        we did not do a good job of validating whether this metadata was
        correctly formatted or not. Starting in version 0.4.0 of nbgrader, we
        are explicitly validating this metadata. This will require that you
        update the metadata in your old nbgrader notebooks to be consistent
        with what nbgrader expects.
github jupyter / nbgrader / nbgrader / apps / validateapp.py View on Github external
from traitlets import default

from .baseapp import NbGrader
from ..validator import Validator
from ..nbgraderformat import SchemaMismatchError

aliases = {}
flags = {
    'invert': (
        {'Validator': {'invert': True}},
        "Complain when cells pass, rather than vice versa."
    )
}

class ValidateApp(NbGrader):

    name = u'nbgrader-validate'
    description = u'Validate a notebook by running it'

    aliases = aliases
    flags = flags

    examples = """
        You can run `nbgrader validate` on just a single file, e.g.:
            nbgrader validate "Problem 1.ipynb"

        Or, you can run it on multiple files using shell globs:
            nbgrader validate "Problem Set 1/*.ipynb"

        If you want to test instead that none of the tests pass (rather than that
        all of the tests pass, which is the default), you can use --invert:
github jupyter / nbgrader / nbgrader / apps / baseapp.py View on Github external
super(NbGrader, self).load_config_file(**kwargs)


# These are the aliases and flags for nbgrader apps that inherit only from
# TransferApp
transfer_aliases = {}
transfer_aliases.update(nbgrader_aliases)
transfer_aliases.update({
    "timezone": "TransferApp.timezone",
})
transfer_flags = {}
transfer_flags.update(nbgrader_flags)
transfer_flags.update({
})

class TransferApp(NbGrader):
    """A base class for the list, release, collect, fetch, and submit apps.

    All of these apps involve transfering files between an instructor or students
    files and the nbgrader exchange.
    """

    timezone = Unicode(
        "UTC",
        help="Timezone for recording timestamps"
    ).tag(config=True)

    timestamp_format = Unicode(
        "%Y-%m-%d %H:%M:%S %Z",
        help="Format string for timestamps"
    ).tag(config=True)
github jupyter / nbgrader / nbgrader / apps / listapp.py View on Github external
),
    'cached': (
        {'ExchangeList' : {'cached': True}},
        "List cached files rather than inbound/outbound."
    ),
    'remove': (
        {'ExchangeList' : {'remove': True}},
        "Remove an assignment from the exchange."
    ),
    'json': (
        {'ExchangeList' : {'as_json': True}},
        "Print out assignments as json."
    ),
})

class ListApp(NbGrader):

    name = u'nbgrader-list'
    description = u'List assignments in the nbgrader exchange'

    aliases = aliases
    flags = flags

    examples = """
        List assignments in the nbgrader exchange. For the usage of instructors
        and students.

        Students
        ========

        To list assignments for a course, you must first know the `course_id` for
        your course. If you don't know it, ask your instructor.
github jupyter / nbgrader / nbgrader / server_extensions / formgrader / formgrader.py View on Github external
import os

from nbconvert.exporters import HTMLExporter
from traitlets import default
from tornado import web
from jinja2 import Environment, FileSystemLoader
from notebook.utils import url_path_join as ujoin

from . import handlers, apihandlers
from ...apps.baseapp import NbGrader


class FormgradeExtension(NbGrader):

    name = u'formgrade'
    description = u'Grade a notebook using an HTML form'

    @default("classes")
    def _classes_default(self):
        classes = super(FormgradeExtension, self)._classes_default()
        classes.append(HTMLExporter)
        return classes

    def build_extra_config(self):
        extra_config = super(FormgradeExtension, self).build_extra_config()
        extra_config.HTMLExporter.template_file = 'formgrade'
        extra_config.HTMLExporter.template_path = [handlers.template_path]
        return extra_config
github jupyter / nbgrader / nbgrader / apps / autogradeapp.py View on Github external
'ClearOutput': {'enabled': False}
        },
        "Don't execute notebooks and clear output when autograding."
    ),
    'force': (
        {'BaseConverter': {'force': True}},
        "Overwrite an assignment/submission if it already exists."
    ),
    'f': (
        {'BaseConverter': {'force': True}},
        "Overwrite an assignment/submission if it already exists."
    ),
})


class AutogradeApp(NbGrader):

    name = u'nbgrader-autograde'
    description = u'Autograde a notebook by running it'

    aliases = aliases
    flags = flags

    examples = """
        Autograde submitted assignments. This takes one argument for the
        assignment id, and then (by default) autogrades assignments from the
        following directory structure:

            submitted/*/{assignment_id}/*.ipynb

        and saves the autograded files to the corresponding directory in:
github jupyter / nbgrader / nbgrader / apps / releasefeedbackapp.py View on Github external
from .baseapp import NbGrader, nbgrader_aliases, nbgrader_flags
from ..exchange import Exchange, ExchangeReleaseFeedback, ExchangeError


aliases = {}
aliases.update(nbgrader_aliases)
aliases.update({
    "timezone": "Exchange.timezone",
    "course": "CourseDirectory.course_id",
})

flags = {}
flags.update(nbgrader_flags)

class ReleaseFeedbackApp(NbGrader):

    name = u'nbgrader-release-feedback'
    description = u'Release assignment feedback to the nbgrader exchange'

    aliases = aliases
    flags = flags

    examples = """
        Release feedback for an assignment to students. For the usage of instructors.

        This command is run from the top-level nbgrader folder.

        The command releases the feedback present in the `feedback` folder. To populate
        this folder use the `nbgrader generate_feedback` command.

        To release the feedback for an assignment named `assignment1` run: