Coverage for e2xgrader/exchange/exchange.py: 83%
23 statements
« prev ^ index » next coverage.py v7.4.2, created at 2024-03-14 13:54 +0100
« prev ^ index » next coverage.py v7.4.2, created at 2024-03-14 13:54 +0100
1from textwrap import dedent
3from nbgrader.exchange.default import Exchange
4from nbgrader.utils import check_directory
5from traitlets import Bool, Unicode
8class E2xExchange(Exchange):
9 personalized_outbound = Bool(
10 False, help="Whether to use a personalized outbound directory per student"
11 ).tag(config=True)
13 personalized_inbound = Bool(
14 False, help="Whether to use a personalized inbound directory per student"
15 ).tag(config=True)
17 personalized_feedback = Bool(
18 False, help="Whether to use a personalized feedback directory per student"
19 ).tag(config=True)
21 grader = Bool(
22 False,
23 help=dedent(
24 """A flag whether the current user is grader. Used for personalized-outbound
25 to retrive the released assignment for one of the students,so that
26 lister only shows one released assignment instead of showing all
27 individualized assignments from all users
28 """
29 ),
30 ).tag(config=True)
32 outbound_directory = Unicode("outbound", help="The name of the outbound directory")
34 inbound_directory = Unicode("inbound", help="The name of the inbound directory")
36 feedback_directory = Unicode("feedback", help="The name of the feedback directory")
38 def __init__(self, coursedir=None, authenticator=None, **kwargs):
39 super().__init__(coursedir=coursedir, authenticator=authenticator, **kwargs)
41 if self.personalized_outbound:
42 self.outbound_directory = "personalized-outbound"
44 if self.personalized_inbound:
45 self.inbound_directory = "personalized-inbound"
47 if self.personalized_feedback:
48 self.feedback_directory = "personalized-feedback"
50 def ensure_root(self):
51 """
52 See if the exchange directory exists and readable, fail if not.
53 We do not need to make the exchange root writable by default.
54 """
55 if not check_directory(self.root, read=True, execute=True):
56 self.fail(
57 "Unreadable directory, please contact your instructor: {}".format(
58 self.root
59 )
60 )