-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpMakeAssignment.py
More file actions
executable file
·60 lines (46 loc) · 2.22 KB
/
cpMakeAssignment.py
File metadata and controls
executable file
·60 lines (46 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# ----------------------------------------------------------------------
# cpMakeAssignment.py
# Dave Reed
# 02/14/2020
# ----------------------------------------------------------------------
from argparse import ArgumentParser
from CPAPI import *
from FileUtils import *
from cpAddRubric import makeRubric
# ----------------------------------------------------------------------
def main():
parser = ArgumentParser(description='make a codepost.io assignment for a course')
parser.add_argument('--course-prefix', dest='coursePrefix', default='CS',
help='''directory prefix for course names (i.e., if all your codepost.io course names and
local directories start with CS such as CS160 then use the default
''')
parser.add_argument('-c', '--course-name', dest='course', default=None,
help='''name of course, if no name supplied, will try to find directory with coursePrefix in
the current working directory's parent directories
''')
parser.add_argument('-p', '--points', dest='points', default=100,
help='''number of points for assignment, defaults to 100''')
parser.add_argument("assignment",
help='''name of assignment to create''')
parser.add_argument("rubricFilename", nargs='?', default=None,
help='''name of file containing rubric to add to the assignment''')
options = parser.parse_args()
if options.course is None:
course, _, _, _ = FileInfo.infoForFilePath(os.getcwd())
else:
course = options.course
if options.assignment is None:
assignment = input("enter assignment name: ")
else:
assignment = options.assignment
print(f"make assignment {options.assignment} for {course}")
CP.init()
c = CP.course(course)
a = c.makeAssignment(assignment, options.points)
if options.rubricFilename is not None:
print(f"add rubric from {options.rubricFilename}")
makeRubric(a, options.rubricFilename)
# ----------------------------------------------------------------------
if __name__ == '__main__':
main()