ladok3 3.7__tar.gz → 3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ladok3 might be problematic. Click here for more details.

Files changed (33) hide show
  1. {ladok3-3.7 → ladok3-3.8}/PKG-INFO +1 -1
  2. {ladok3-3.7 → ladok3-3.8}/pyproject.toml +1 -1
  3. {ladok3-3.7 → ladok3-3.8}/src/ladok3/report.nw +48 -17
  4. {ladok3-3.7 → ladok3-3.8}/src/ladok3/student.nw +19 -6
  5. {ladok3-3.7 → ladok3-3.8}/LICENSE +0 -0
  6. {ladok3-3.7 → ladok3-3.8}/README.md +0 -0
  7. {ladok3-3.7 → ladok3-3.8}/doc/Makefile +0 -0
  8. {ladok3-3.7 → ladok3-3.8}/doc/abstract.tex +0 -0
  9. {ladok3-3.7 → ladok3-3.8}/doc/ladok3.tex +0 -0
  10. {ladok3-3.7 → ladok3-3.8}/doc/preamble.tex +0 -0
  11. {ladok3-3.7 → ladok3-3.8}/makefiles/doc.mk +0 -0
  12. {ladok3-3.7 → ladok3-3.8}/makefiles/exam.mk +0 -0
  13. {ladok3-3.7 → ladok3-3.8}/makefiles/haskell.mk +0 -0
  14. {ladok3-3.7 → ladok3-3.8}/makefiles/miun.course.mk +0 -0
  15. {ladok3-3.7 → ladok3-3.8}/makefiles/miun.depend.mk +0 -0
  16. {ladok3-3.7 → ladok3-3.8}/makefiles/miun.docs.mk +0 -0
  17. {ladok3-3.7 → ladok3-3.8}/makefiles/miun.port.mk +0 -0
  18. {ladok3-3.7 → ladok3-3.8}/makefiles/miun.pub.mk +0 -0
  19. {ladok3-3.7 → ladok3-3.8}/makefiles/noweb.mk +0 -0
  20. {ladok3-3.7 → ladok3-3.8}/makefiles/pkg.mk +0 -0
  21. {ladok3-3.7 → ladok3-3.8}/makefiles/portability.mk +0 -0
  22. {ladok3-3.7 → ladok3-3.8}/makefiles/pub.mk +0 -0
  23. {ladok3-3.7 → ladok3-3.8}/makefiles/results.mk +0 -0
  24. {ladok3-3.7 → ladok3-3.8}/makefiles/subdir.mk +0 -0
  25. {ladok3-3.7 → ladok3-3.8}/makefiles/tex.mk +0 -0
  26. {ladok3-3.7 → ladok3-3.8}/makefiles/transform.mk +0 -0
  27. {ladok3-3.7 → ladok3-3.8}/src/ladok3/.gitignore +0 -0
  28. {ladok3-3.7 → ladok3-3.8}/src/ladok3/Makefile +0 -0
  29. {ladok3-3.7 → ladok3-3.8}/src/ladok3/api.nw +0 -0
  30. {ladok3-3.7 → ladok3-3.8}/src/ladok3/cli.nw +0 -0
  31. {ladok3-3.7 → ladok3-3.8}/src/ladok3/data.nw +0 -0
  32. {ladok3-3.7 → ladok3-3.8}/src/ladok3/ladok3.nw +0 -0
  33. {ladok3-3.7 → ladok3-3.8}/src/ladok3/undoc.nw +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ladok3
3
- Version: 3.7
3
+ Version: 3.8
4
4
  Summary: Python wrapper and CLI for the LADOK3 REST API.
5
5
  Home-page: https://github.com/dbosk/ladok3
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ladok3"
3
- version = "3.7"
3
+ version = "3.8"
4
4
  description = "Python wrapper and CLI for the LADOK3 REST API."
5
5
  authors = [
6
6
  "Daniel Bosk <dbosk@kth.se>",
@@ -129,8 +129,8 @@ them.
129
129
  <<check that we got all positional arguments>>
130
130
  try:
131
131
  student = ladok.get_student(args.student_id)
132
- course = student.courses(code=args.course_code)[0]
133
- result = course.results(component=args.component_code)[0]
132
+ <<look up [[course]] from [[student]]>>
133
+ <<look up [[result]] from [[course]]>>
134
134
  result.set_grade(args.grade, args.date)
135
135
  if args.finalize:
136
136
  result.finalize()
@@ -139,9 +139,25 @@ except Exception as err:
139
139
  print(f"{student}: {err}")
140
140
  except ValueError as verr:
141
141
  print(f"{verr}: {args.student_id}: {err}")
142
- @ This means that we need the following command-line arguments.
143
- The option [[args.finalize]] is already set above, so we don't need to add that
144
- one here.
142
+ @ The option [[args.finalize]] is already set above, so we don't need to add
143
+ that one here.
144
+
145
+ Both looking up the course and the component can yield index errors.
146
+ We'd like to distinguish these.
147
+ We will catch the exception, the reraise the same exception but with a better
148
+ error message.
149
+ <<look up [[course]] from [[student]]>>=
150
+ try:
151
+ course = student.courses(code=args.course_code)[0]
152
+ except IndexError:
153
+ raise Exception("f{args.course_code}: No such course for {student}")
154
+ <<look up [[result]] from [[course]]>>=
155
+ try:
156
+ result = course.results(component=args.component_code)[0]
157
+ except IndexError:
158
+ raise Exception(f"{args.component_code}: "
159
+ f"No such component for {args.course_code}")
160
+ @
145
161
 
146
162
 
147
163
  \section{Report many results given in standard input}
@@ -180,23 +196,14 @@ try:
180
196
  try:
181
197
  course = student.courses(code=course_code)[0]
182
198
  except IndexError:
183
- raise Exception(f"{course_code}: no such course.")
199
+ raise Exception(f"{course_code}: No such course for {student}")
184
200
 
185
201
  try:
186
202
  component = course.results(component=component_code)[0]
187
203
  except IndexError:
188
- raise Exception(f"{course_code} has no component {component_code}.")
204
+ raise Exception(f"{component_code}: no such component for {course_code}")
189
205
 
190
- if not component.attested and component.grade != grade:
191
- component.set_grade(grade, date)
192
- component.finalize()
193
- if args.verbose:
194
- print(f"{course_code} {student}: reported "
195
- f"{component.component} = {component.grade} ({date}).")
196
- elif component.grade != grade:
197
- print(f"{course_code} {student}: attested {component.component} "
198
- f"result {component.grade} ({component.date}) "
199
- f"is different from {grade} ({date}).")
206
+ <<set [[grade]] to [[component]], output if verbose>>
200
207
  except Exception as err:
201
208
  try:
202
209
  print(f"{course_code} {component_code}={grade} ({date}) {student}: {err}",
@@ -207,6 +214,30 @@ except Exception as err:
207
214
  file=sys.stderr)
208
215
  @
209
216
 
217
+ Now, when we set the grade, there are a few cases that should be handled.
218
+ If the grade isn't attested, we try to change it.
219
+ (This might still fail if the grade is finalized but not attested.)
220
+ If we've selected the verbose option, then we print what we have reported.
221
+
222
+ If the grade was attested, then we check if it's different.
223
+ If it's different, we output this.
224
+ If it's the same, we silently ignore it.
225
+ This is best for bulk reporting, because then we can always try to report for
226
+ all students.
227
+ <<set [[grade]] to [[component]], output if verbose>>=
228
+ if not component.attested and component.grade != grade:
229
+ component.set_grade(grade, date)
230
+ if args.finalize:
231
+ component.finalize()
232
+ if args.verbose:
233
+ print(f"{course_code} {student}: reported "
234
+ f"{component.component} = {component.grade} ({date}).")
235
+ elif component.grade != grade:
236
+ print(f"{course_code} {student}: attested {component.component} "
237
+ f"result {component.grade} ({component.date}) "
238
+ f"is different from {grade} ({date}).")
239
+ @
240
+
210
241
 
211
242
  \section{Determine which function to run}
212
243
 
@@ -63,6 +63,17 @@ student_parser.add_argument("-c", "--course",
63
63
  )
64
64
  @
65
65
 
66
+ \subsection{A results flag}
67
+
68
+ We also want a flag for specifying whether or not to include the results of
69
+ each course.
70
+ <<add student command arguments to student parser>>=
71
+ student_parser.add_argument("-r", "--results",
72
+ action="store_true", default=False,
73
+ help="Set to include results for each course listed."
74
+ )
75
+ @
76
+
66
77
  \section{Print the student data}
67
78
 
68
79
  Now that we have the student identifier, we can simply use that to fetch the
@@ -80,7 +91,7 @@ print_student_data(student)
80
91
 
81
92
  if args.course:
82
93
  print()
83
- print_course_data(student, args.course)
94
+ print_course_data(student, args)
84
95
  @
85
96
 
86
97
  \subsection{Printing personal student data}
@@ -102,13 +113,15 @@ def print_student_data(student):
102
113
 
103
114
  To print the student's course data, we simply filter the courses on the option
104
115
  that the user supplies.
105
- We then print all results for each course.
116
+ We then print all courses and, if the flag is set, we also print the results
117
+ for each course.
106
118
  <<functions>>=
107
- def print_course_data(student, course):
119
+ def print_course_data(student, args):
108
120
  """Prints the courses"""
109
121
  print("Courses:")
110
- for course in student.courses(code=course):
122
+ for course in student.courses(code=args.course):
111
123
  print(f"{course}")
112
- for result in course.results():
113
- print(f" {result}")
124
+ if args.results:
125
+ for result in course.results():
126
+ print(f" {result}")
114
127
  @
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes