ladok3 4.11__py3-none-any.whl → 4.13__py3-none-any.whl

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.
doc/ltxobj/ladok3.pdf CHANGED
Binary file
ladok3/__init__.py CHANGED
@@ -4462,13 +4462,20 @@ class CourseInstance(LadokRemoteData):
4462
4462
  self.__pull_attributes()
4463
4463
 
4464
4464
  def __assign_attr(self, data):
4465
+ self.__components = []
4465
4466
  if "IngaendeMoment" in data:
4466
- self.__components = [
4467
+ self.__components += [
4467
4468
  CourseComponent(ladok=self.ladok, course=self, **component)
4468
4469
  for component in data["IngaendeMoment"]
4469
4470
  ]
4470
- else:
4471
- self.__components = []
4471
+ try:
4472
+ course_component_data = data.copy()
4473
+ course_component_data["ladok"] = self.ladok
4474
+ self.__components.append(
4475
+ CourseComponent(course=self, **course_component_data)
4476
+ )
4477
+ except KeyError:
4478
+ pass
4472
4479
 
4473
4480
  self.__name = data.pop("Benamning")
4474
4481
  self.__code = data.pop("Utbildningskod")
@@ -4493,13 +4500,20 @@ class CourseInstance(LadokRemoteData):
4493
4500
  self.__pull_attributes()
4494
4501
 
4495
4502
  def __assign_faux(self, data):
4503
+ self.__components = []
4496
4504
  if "IngaendeMoment" in data:
4497
- self.__components = [
4505
+ self.__components += [
4498
4506
  CourseComponent(ladok=self.ladok, course=self, **component)
4499
4507
  for component in data["IngaendeMoment"]
4500
4508
  ]
4501
- else:
4502
- self.__components = []
4509
+ try:
4510
+ course_component_data = data.copy()
4511
+ course_component_data["ladok"] = self.ladok
4512
+ self.__components.append(
4513
+ CourseComponent(course=self, **course_component_data)
4514
+ )
4515
+ except KeyError:
4516
+ pass
4503
4517
 
4504
4518
  self.__name = data.pop("Benamning", None)
4505
4519
  self.__code = data.pop("Utbildningskod", None)
@@ -4748,8 +4762,8 @@ class CourseRegistration(CourseInstance):
4748
4762
  self.__student.ladok_id, self.education_id
4749
4763
  )["Kursversioner"][0]
4750
4764
 
4751
- # self.__results_id = response["Uid"]
4752
4765
  self.__results = []
4766
+
4753
4767
  for result in response["VersionensModuler"]:
4754
4768
  try:
4755
4769
  self.__results.append(
@@ -4762,6 +4776,17 @@ class CourseRegistration(CourseInstance):
4762
4776
  )
4763
4777
  except TypeError:
4764
4778
  pass
4779
+ try:
4780
+ self.__results.append(
4781
+ CourseResult(
4782
+ ladok=self.ladok,
4783
+ components=self.components(),
4784
+ student=self.__student,
4785
+ **response["VersionensKurs"],
4786
+ )
4787
+ )
4788
+ except TypeError:
4789
+ pass
4765
4790
  for component in self.components():
4766
4791
  if not list(filter_on_keys(self.__results, component=component.code)):
4767
4792
  self.__results.append(
ladok3/api.nw CHANGED
@@ -889,6 +889,9 @@ Note that since this is a new result, we must provide the [[StudieresultatUID]]
889
889
  where we want to add the result.
890
890
  When we've done this, we'll get a [[ResultatUID]] back in the response.
891
891
  From then on, it's the [[ResultatUID]] that's interesting.
892
+
893
+ Note also that we can use [[course_instance_id]] as [[component_id]], this will
894
+ set the result on the whole course.
892
895
  <<LadokSession data methods>>=
893
896
  def create_result_JSON(self,
894
897
  student_id, course_instance_id, component_id,
ladok3/cli.nw CHANGED
@@ -570,7 +570,7 @@ try:
570
570
  "username": os.environ["LADOK_USER"],
571
571
  "password": os.environ["LADOK_PASS"]
572
572
  }
573
- if institution and vars:
573
+ if institution and vars["username"] and vars["password"]:
574
574
  return institution, vars
575
575
  except:
576
576
  pass
@@ -585,7 +585,9 @@ try:
585
585
  vars = {}
586
586
  for key in vars_keys.split(":"):
587
587
  try:
588
- vars[key] = os.environ[key]
588
+ value = os.environ[key]
589
+ if value:
590
+ vars[key] = value
589
591
  except KeyError:
590
592
  <<print warning about missing variable in [[LADOK_VARS]]>>
591
593
 
ladok3/cli.py CHANGED
@@ -255,7 +255,7 @@ def load_credentials(filename="config.json"):
255
255
  "username": os.environ["LADOK_USER"],
256
256
  "password": os.environ["LADOK_PASS"],
257
257
  }
258
- if institution and vars:
258
+ if institution and vars["username"] and vars["password"]:
259
259
  return institution, vars
260
260
  except:
261
261
  pass
@@ -265,7 +265,9 @@ def load_credentials(filename="config.json"):
265
265
  vars = {}
266
266
  for key in vars_keys.split(":"):
267
267
  try:
268
- vars[key] = os.environ[key]
268
+ value = os.environ[key]
269
+ if value:
270
+ vars[key] = value
269
271
  except KeyError:
270
272
  warn(f"Variable {key} not set, ignoring.")
271
273
 
ladok3/ladok3.nw CHANGED
@@ -1122,12 +1122,8 @@ By trial-and-error, it seems like the faux courses has none of the attributes
1122
1122
  that the real courses have.
1123
1123
  However, we try our best.
1124
1124
  <<assign common CourseInstance data to private attributes>>=
1125
- if "IngaendeMoment" in data:
1126
- self.__components = [CourseComponent(
1127
- ladok=self.ladok, course=self,
1128
- **component) for component in data["IngaendeMoment"]]
1129
- else:
1130
- self.__components = []
1125
+ self.__components = []
1126
+ <<add course components to [[self.__components]]>>
1131
1127
  <<assign CourseInstance data to private attributes>>=
1132
1128
  <<assign common CourseInstance data to private attributes>>
1133
1129
 
@@ -1203,6 +1199,33 @@ def components(self, /, **kwargs):
1203
1199
  @
1204
1200
 
1205
1201
 
1202
+ \subsection{Course components}
1203
+
1204
+ We need to add the courses components to the course instance.
1205
+ That is things like LAB1 or EXA1 that make up the course in LADOK.
1206
+ <<add course components to [[self.__components]]>>=
1207
+ if "IngaendeMoment" in data:
1208
+ self.__components += [CourseComponent(
1209
+ ladok=self.ladok, course=self,
1210
+ **component) for component in data["IngaendeMoment"]]
1211
+ @
1212
+
1213
+ We also add the course itself as a component.
1214
+ This is to handle the grade on the course itself.
1215
+ Once all the components have a grade, the course itself will get a grade.
1216
+ This component represents that grade.
1217
+ It will get the course code as its code.
1218
+ <<add course components to [[self.__components]]>>=
1219
+ try:
1220
+ course_component_data = data.copy()
1221
+ course_component_data["ladok"] = self.ladok
1222
+ self.__components.append(CourseComponent(course=self,
1223
+ **course_component_data))
1224
+ except KeyError:
1225
+ pass
1226
+ @
1227
+
1228
+
1206
1229
  \section{Course components}
1207
1230
 
1208
1231
  The [[CourseComponent]] class will make the attributes available.
@@ -1415,13 +1438,15 @@ We can pull these from LADOK as well.
1415
1438
  We construct [[CourseResult]] objects using a [[CourseRegistration]] object.
1416
1439
  From the response we get from LADOK, we construct [[CourseResult]] objects that
1417
1440
  deal with the details.
1441
+ (It's a bit unclear why [[Kursversioner]] is a list, so far it has always
1442
+ worked to take the first.)
1418
1443
  <<pull existing CourseResult objects from LADOK>>=
1419
1444
  response = self.ladok.student_results_JSON(
1420
1445
  self.__student.ladok_id, self.education_id
1421
1446
  )["Kursversioner"][0]
1422
1447
 
1423
- #self.__results_id = response["Uid"]
1424
1448
  self.__results = []
1449
+
1425
1450
  for result in response["VersionensModuler"]:
1426
1451
  try:
1427
1452
  self.__results.append(CourseResult(ladok=self.ladok,
@@ -1432,6 +1457,20 @@ for result in response["VersionensModuler"]:
1432
1457
  pass
1433
1458
  @
1434
1459
 
1460
+ As with the components, the course grade itself is a special case.
1461
+ That data is not in [[VersionensModuler]], but in [[VersionensKurs]].
1462
+ But we can do the same with it, just as we could with the components.
1463
+ (And this works since it's a component in [[self.components()]].)
1464
+ <<pull existing CourseResult objects from LADOK>>=
1465
+ try:
1466
+ self.__results.append(CourseResult(ladok=self.ladok,
1467
+ components=self.components(),
1468
+ student=self.__student,
1469
+ **response["VersionensKurs"]))
1470
+ except TypeError:
1471
+ pass
1472
+ @
1473
+
1435
1474
  Now we can see which components from [[self.components]] are missing from
1436
1475
  [[self.__results]] and just add empty results for those.
1437
1476
  <<add new CourseResult objects for missing components>>=
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ladok3
3
- Version: 4.11
3
+ Version: 4.13
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,21 +1,21 @@
1
- doc/ltxobj/ladok3.pdf,sha256=WZ3PoQ8-IPNLUNiOwv9P0pxsFHaRx2vTTgbQjtfGajo,1407824
1
+ doc/ltxobj/ladok3.pdf,sha256=6JSedbZ1ut-2s25sn8xay3S3dRUbaxlowGTeE56_xsM,1414854
2
2
  ladok3/.gitignore,sha256=QOcCshtjIsFasi4vaqFcooBWPJkxVWaoYEWOBBtdY_w,81
3
3
  ladok3/Makefile,sha256=Jy6OFjoVLU9YivnVxctxI_zrUOK9ysEOiistJ3ST6Nw,557
4
- ladok3/__init__.py,sha256=3z1Lys2ygnuDyYFvm4O4Um6vgYud470W3xX4gYJ4bMc,245725
5
- ladok3/api.nw,sha256=pHFU8T2tr2N4kJfyo7uKzNd1lpkd7KICK8lHzV6b1-Y,43304
6
- ladok3/cli.nw,sha256=cwooD_hc9ZpgnRhQ9TebbeWp_ZjKDTWjcV9Qqiqxu28,22378
7
- ladok3/cli.py,sha256=pLAVt2XhaGJ50knOlRNX_lcS3NFExu5ChHPgItRRGvI,12093
4
+ ladok3/__init__.py,sha256=9bZ_ktF7mg8QvQZcdN3t2AzY_k7g-9Zm-pPh-edMB3Y,246543
5
+ ladok3/api.nw,sha256=P5MQa3AqaUVv-xL3R-AHcFnBWTpAAvzfwlCDKoNFw-M,43422
6
+ ladok3/cli.nw,sha256=SD75vD-uSn-0yo6aOIUY4lgx9EjQf4M-HPHFZrNHMG0,22449
7
+ ladok3/cli.py,sha256=1oUlrI9N7ooGfB-pYt1rkCCX9YKatb4MwP9ivGniK00,12186
8
8
  ladok3/data.nw,sha256=3o6-kmeMtCGoSJ5yL8qFCuIINQeym_WtW_2mhItuR-s,11785
9
9
  ladok3/data.py,sha256=kPRO9l5DTQb9lGnN2kU-YYPSyg31t0bq5HCw986hbPk,6747
10
10
  ladok3/ladok.bash,sha256=zGfTFdtos2zLjV13pzfK-1uCy2b_lF2qUKMoL2ExW7c,1441
11
- ladok3/ladok3.nw,sha256=6er9_eF1ErShimmpmNh4UkC-EHoLn0HGK8NjzEz_fVM,52289
11
+ ladok3/ladok3.nw,sha256=QIpTOOGC-2p4_RUDJP_j-nMXM6DeSzWp3hJbWH_dq_k,53766
12
12
  ladok3/report.nw,sha256=Bp0-yNVb3NZ0WIj5xn9cpsnY6M60MWMzpX3BC9mXqN0,8972
13
13
  ladok3/report.py,sha256=1K7cRaedemiOGDDAMI9wqnctLeic5ZlMYHw5hzhnvQw,5627
14
14
  ladok3/student.nw,sha256=zayn9_b9jCKeMnZxSGS_EuSmF3ojOBHQDMUMMkpRssI,3747
15
15
  ladok3/student.py,sha256=TaYn2rpbQnzummB-8xz-sUEV31Gh0CUmU0QkF6VgEic,1703
16
16
  ladok3/undoc.nw,sha256=NyHuVIzrRqJPM39MyAlZNEE7PbXdUDJFQ2kJ0NfdwQI,180333
17
- ladok3-4.11.dist-info/LICENSE,sha256=s_C5qznXAvDRrzU7vRd4eqzshyIkAfPwGyVBihGeOdM,1155
18
- ladok3-4.11.dist-info/METADATA,sha256=b_1jNYsFOsiXR11udNkWFRzBZepydHwWfRAu9PTRlFo,8822
19
- ladok3-4.11.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
20
- ladok3-4.11.dist-info/entry_points.txt,sha256=pi-KKP5Obo0AyuDjXQUpadS9kIvAY2_5ORhPgEYlJv8,41
21
- ladok3-4.11.dist-info/RECORD,,
17
+ ladok3-4.13.dist-info/LICENSE,sha256=s_C5qznXAvDRrzU7vRd4eqzshyIkAfPwGyVBihGeOdM,1155
18
+ ladok3-4.13.dist-info/METADATA,sha256=5RRL2nWeocO_vqBUIaAhSyjOCQf7Egszw15-fb5lPns,8822
19
+ ladok3-4.13.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
20
+ ladok3-4.13.dist-info/entry_points.txt,sha256=pi-KKP5Obo0AyuDjXQUpadS9kIvAY2_5ORhPgEYlJv8,41
21
+ ladok3-4.13.dist-info/RECORD,,
File without changes
File without changes