PyKubeGrader 0.1.20__py3-none-any.whl → 0.1.21__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyKubeGrader
3
- Version: 0.1.20
3
+ Version: 0.1.21
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -1,10 +1,10 @@
1
1
  pykubegrader/__init__.py,sha256=AoAkdfIjDDZGWLlsIRENNq06L9h46kDGBIE8vRmsCfg,311
2
2
  pykubegrader/initialize.py,sha256=UQ828VrueLOgrzJsYqWeQe6k0J6OWuX8AnojdU1eqFg,3167
3
- pykubegrader/telemetry.py,sha256=0nPdqvd70IACz3tz1lZmjwQhJByqLz9IUVmxKhfaWCw,5692
3
+ pykubegrader/telemetry.py,sha256=IVQISKPfJX7IJ4tCG9AOO36UlTtbVZv2rZnrv3-ZSIc,5994
4
4
  pykubegrader/utils.py,sha256=dKw6SyRYU3DWRgD3xER7wq-C9e1daWPkqr901LpcwiQ,642
5
5
  pykubegrader/validate.py,sha256=vEdNN386yFloDRcjMDrTAqfBmeCXGcDPNH_rLZScIm8,10945
6
6
  pykubegrader/build/api_notebook_builder.py,sha256=GVi6hupfQaWeFMv6Bdela3FTRHvOQYXPIcICnkaLhgA,20119
7
- pykubegrader/build/build_folder.py,sha256=Tf3eryxgDLCkVaSA0s1HKInW7IRQEQd-BfLa66TUTjg,66268
7
+ pykubegrader/build/build_folder.py,sha256=_mVEUiPwOPARBHkucAOw2bP8XzmspfL6B4-Ic_Ey3I0,66493
8
8
  pykubegrader/log_parser/parse.ipynb,sha256=F3ZWi5_AOxEnSihY0VBz4jjqo0__GggjRgFvS0QCHTg,10611
9
9
  pykubegrader/log_parser/parse.py,sha256=aON6tWj0dFJcYR9GmzXWfmZ4_t8LU1FTq6vbWCePgRs,6987
10
10
  pykubegrader/widgets/__init__.py,sha256=s3ky3eJDa1RedFVdpKxmqv6mHBYpOSL9Z6qThSH9cbs,303
@@ -19,9 +19,9 @@ pykubegrader/widgets_base/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-
19
19
  pykubegrader/widgets_base/multi_select.py,sha256=jzuK_1eLyhDOzR1jragLRBf_aO8IEaoixfozxBeMBs0,3975
20
20
  pykubegrader/widgets_base/reading.py,sha256=4uTLmlPzCwxVzufFhPjM7W19uMGguRb6y4eAV3x-zAc,5314
21
21
  pykubegrader/widgets_base/select.py,sha256=b5mmd-Cl1A2T2ePZ20-KLVyvP3bzvzYX36n3lMcrcFM,2456
22
- PyKubeGrader-0.1.20.dist-info/LICENSE.txt,sha256=YTp-Ewc8Kems8PJEE27KnBPFnZSxoWvSg7nnknzPyYw,1546
23
- PyKubeGrader-0.1.20.dist-info/METADATA,sha256=5O8j0L-1D3dOQl2QNgW9zYyzkYaA7xMRJvnsXuuFUQc,2665
24
- PyKubeGrader-0.1.20.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
25
- PyKubeGrader-0.1.20.dist-info/entry_points.txt,sha256=Kd4Bh-i3hc4qlnLU1p0nc8yPw9cC5AQGOtkk2eLGnQw,78
26
- PyKubeGrader-0.1.20.dist-info/top_level.txt,sha256=e550Klfze6higFxER1V62fnGOcIgiKRbsrl9CC4UdtQ,13
27
- PyKubeGrader-0.1.20.dist-info/RECORD,,
22
+ PyKubeGrader-0.1.21.dist-info/LICENSE.txt,sha256=YTp-Ewc8Kems8PJEE27KnBPFnZSxoWvSg7nnknzPyYw,1546
23
+ PyKubeGrader-0.1.21.dist-info/METADATA,sha256=VmZN6QwNzxfV3NOudCKAuP7KwL77Mv8v04Xa7yG4yOo,2665
24
+ PyKubeGrader-0.1.21.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
25
+ PyKubeGrader-0.1.21.dist-info/entry_points.txt,sha256=Kd4Bh-i3hc4qlnLU1p0nc8yPw9cC5AQGOtkk2eLGnQw,78
26
+ PyKubeGrader-0.1.21.dist-info/top_level.txt,sha256=e550Klfze6higFxER1V62fnGOcIgiKRbsrl9CC4UdtQ,13
27
+ PyKubeGrader-0.1.21.dist-info/RECORD,,
@@ -64,7 +64,7 @@ class NotebookProcessor:
64
64
  __name__
65
65
  ) # Create a logger instance specific to this module
66
66
  self.logger = logger # Assign the logger instance to the class for use in instance methods
67
-
67
+
68
68
  self.total_point_log = {}
69
69
 
70
70
  def process_notebooks(self):
@@ -120,10 +120,12 @@ class NotebookProcessor:
120
120
 
121
121
  # Process the notebook if it meets the criteria
122
122
  self._process_single_notebook(notebook_path)
123
-
123
+
124
124
  # Write the dictionary to a JSON file
125
125
  with open(f"{self.solutions_folder}/total_points.json", "w") as json_file:
126
- json.dump(self.total_point_log, json_file, indent=4) # `indent=4` for pretty formatting
126
+ json.dump(
127
+ self.total_point_log, json_file, indent=4
128
+ ) # `indent=4` for pretty formatting
127
129
 
128
130
  def _print_and_log(self, message):
129
131
  """
@@ -176,7 +178,7 @@ class NotebookProcessor:
176
178
  Returns:
177
179
  None
178
180
  """
179
-
181
+
180
182
  self.select_many_total_points = 0
181
183
  self.mcq_total_points = 0
182
184
  self.tf_total_points = 0
@@ -288,11 +290,16 @@ class NotebookProcessor:
288
290
  os.path.join(student_path, question_file_name_sanitized),
289
291
  os.path.join(questions_folder_jbook, question_file_name_sanitized),
290
292
  )
291
-
292
- total_points = self.select_many_total_points + self.mcq_total_points + self.tf_total_points + self.otter_total_points
293
-
294
- self.total_point_log.update({notebook_name: total_points})
295
-
293
+
294
+ total_points = (
295
+ self.select_many_total_points
296
+ + self.mcq_total_points
297
+ + self.tf_total_points
298
+ + self.otter_total_points
299
+ )
300
+
301
+ self.total_point_log.update({notebook_name: total_points})
302
+
296
303
  def free_response_parser(
297
304
  self, temp_notebook_path, notebook_subfolder, notebook_name
298
305
  ):
@@ -309,7 +316,7 @@ class NotebookProcessor:
309
316
 
310
317
  shutil.copy("./keys/.client_private_key.bin", client_private_key)
311
318
  shutil.copy("./keys/.server_public_key.bin", server_public_key)
312
-
319
+
313
320
  client_private_key = os.path.join(
314
321
  notebook_subfolder,
315
322
  ".client_private_key.bin",
@@ -322,7 +329,9 @@ class NotebookProcessor:
322
329
  shutil.copy("./keys/.client_private_key.bin", client_private_key)
323
330
  shutil.copy("./keys/.server_public_key.bin", server_public_key)
324
331
 
325
- out = FastAPINotebookBuilder(notebook_path=temp_notebook_path, assignment_tag=self.assignment_tag)
332
+ out = FastAPINotebookBuilder(
333
+ notebook_path=temp_notebook_path, assignment_tag=self.assignment_tag
334
+ )
326
335
 
327
336
  debug_notebook = os.path.join(
328
337
  notebook_subfolder,
@@ -400,7 +409,6 @@ class NotebookProcessor:
400
409
  replace_cell_source(notebook_path, index, cell)
401
410
 
402
411
  def multiple_choice_parser(self, temp_notebook_path, new_notebook_path):
403
-
404
412
  ### Parse the notebook for multiple choice questions
405
413
  if self.has_assignment(temp_notebook_path, "# BEGIN MULTIPLE CHOICE"):
406
414
  self._print_and_log(
@@ -420,7 +428,9 @@ class NotebookProcessor:
420
428
 
421
429
  for data_ in data:
422
430
  # Generate the solution file
423
- self.mcq_total_points = self.generate_solution_MCQ(data, output_file=solution_path)
431
+ self.mcq_total_points = self.generate_solution_MCQ(
432
+ data, output_file=solution_path
433
+ )
424
434
 
425
435
  question_path = (
426
436
  f"{new_notebook_path.replace(".ipynb", "")}_questions.py"
@@ -460,7 +470,9 @@ class NotebookProcessor:
460
470
 
461
471
  # for data_ in data:
462
472
  # Generate the solution file
463
- self.tf_total_points = self.generate_solution_MCQ(data, output_file=solution_path)
473
+ self.tf_total_points = self.generate_solution_MCQ(
474
+ data, output_file=solution_path
475
+ )
464
476
 
465
477
  question_path = f"{new_notebook_path.replace(".ipynb", "")}_questions.py"
466
478
 
@@ -496,7 +508,9 @@ class NotebookProcessor:
496
508
 
497
509
  # for data_ in data:
498
510
  # Generate the solution file
499
- self.select_many_total_points = self.generate_solution_MCQ(data, output_file=solution_path)
511
+ self.select_many_total_points = self.generate_solution_MCQ(
512
+ data, output_file=solution_path
513
+ )
500
514
 
501
515
  question_path = f"{new_notebook_path.replace(".ipynb", "")}_questions.py"
502
516
 
@@ -702,7 +716,7 @@ class NotebookProcessor:
702
716
  solutions.update(existing_module.solutions)
703
717
  if hasattr(existing_module, "total_points"):
704
718
  total_points.extend(existing_module.total_points)
705
-
719
+
706
720
  question_points = 0
707
721
  # Process new question data and update solutions and total_points
708
722
  for question_set in data_list:
@@ -722,7 +736,7 @@ class NotebookProcessor:
722
736
  # For safety, we assume solutions are strings, but if not, repr would be safer
723
737
  f.write(f' "{key}": {repr(solution)},\n')
724
738
  f.write("}\n")
725
-
739
+
726
740
  return question_points
727
741
 
728
742
  def extract_MCQ(ipynb_file):
@@ -1439,7 +1453,9 @@ def generate_mcq_file(data_dict, output_file="mc_questions.py"):
1439
1453
  keys = []
1440
1454
  for i, (q_key, q_value) in enumerate(question_dict.items()):
1441
1455
  # Write keys
1442
- keys.append(f"q{q_value['question number']}-{q_value['subquestion_number']}-{q_value['name']}")
1456
+ keys.append(
1457
+ f"q{q_value['question number']}-{q_value['subquestion_number']}-{q_value['name']}"
1458
+ )
1443
1459
 
1444
1460
  f.write(f" keys={keys},\n")
1445
1461
 
@@ -1508,7 +1524,9 @@ def generate_select_many_file(data_dict, output_file="select_many_questions.py")
1508
1524
  keys = []
1509
1525
  for i, (q_key, q_value) in enumerate(question_dict.items()):
1510
1526
  # Write keys
1511
- keys.append(f"q{q_value['question number']}-{q_value['subquestion_number']}-{q_value['name']}")
1527
+ keys.append(
1528
+ f"q{q_value['question number']}-{q_value['subquestion_number']}-{q_value['name']}"
1529
+ )
1512
1530
 
1513
1531
  f.write(f" keys={keys},\n")
1514
1532
 
@@ -1583,7 +1601,9 @@ def generate_tf_file(data_dict, output_file="tf_questions.py"):
1583
1601
  keys = []
1584
1602
  for i, (q_key, q_value) in enumerate(question_dict.items()):
1585
1603
  # Write keys
1586
- keys.append(f"q{q_value['question number']}-{q_value['subquestion_number']}-{q_value['name']}")
1604
+ keys.append(
1605
+ f"q{q_value['question number']}-{q_value['subquestion_number']}-{q_value['name']}"
1606
+ )
1587
1607
 
1588
1608
  f.write(f" keys={keys},\n")
1589
1609
 
@@ -1671,16 +1691,18 @@ def main():
1671
1691
  parser.add_argument(
1672
1692
  "root_folder", type=str, help="Path to the root folder to process"
1673
1693
  )
1674
-
1694
+
1675
1695
  parser.add_argument(
1676
1696
  "--assignment-tag",
1677
1697
  type=str,
1678
1698
  help="assignment-tag used for calculating grades",
1679
1699
  default="Reading-Week-X",
1680
1700
  )
1681
-
1701
+
1682
1702
  args = parser.parse_args()
1683
- processor = NotebookProcessor(root_folder=args.root_folder, assignment_tag=args.assignment_tag)
1703
+ processor = NotebookProcessor(
1704
+ root_folder=args.root_folder, assignment_tag=args.assignment_tag
1705
+ )
1684
1706
  processor.process_notebooks()
1685
1707
 
1686
1708
 
pykubegrader/telemetry.py CHANGED
@@ -209,9 +209,17 @@ def score_question_improved(
209
209
  res = requests.post(url, json=payload, auth=HTTPBasicAuth("student", "capture"))
210
210
 
211
211
  res_data = res.json()
212
- max_points, points_earned = res_data["max_points"], res_data["points_earned"]
213
- log_variable(
214
- assignment_name=responses["assignment"],
215
- value=f"{points_earned}, {max_points}",
216
- info_type="score",
217
- )
212
+ # max_points, points_earned = res_data["max_points"], res_data["points_earned"]
213
+ # log_variable(
214
+ # assignment_name=responses["assignment"],
215
+ # value=f"{points_earned}, {max_points}",
216
+ # info_type="score",
217
+ # )
218
+
219
+ # res_data is now dict[str, tuple[float, float]]
220
+ for question, (points_earned, max_points) in res_data.items():
221
+ log_variable(
222
+ assignment_name=responses["assignment"],
223
+ value=f"{points_earned}, {max_points}",
224
+ info_type=question,
225
+ )