PyKubeGrader 0.2.22__py3-none-any.whl → 0.2.24__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.2.22
3
+ Version: 0.2.24
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -5,7 +5,7 @@ pykubegrader/utils.py,sha256=T3GYnLnTL9VXjTZNPr00sUgMgobQYsNTGwynMyXdvHk,696
5
5
  pykubegrader/validate.py,sha256=2KLSB3wfFZbBh1NGgmrOV073paKAgrQz4AgA6LmCIj4,11076
6
6
  pykubegrader/build/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
7
7
  pykubegrader/build/api_notebook_builder.py,sha256=IzzU_jh6SYSA2wtjtlhxa4t9WM8-JqWnWsV8e3UPwdo,20305
8
- pykubegrader/build/build_folder.py,sha256=y5hrxkZgqVr0MRXL3AkihaJQmtm70F4umyVT8--uYTk,81820
8
+ pykubegrader/build/build_folder.py,sha256=Zd0E_R_UciK61wrUprrFSqw6Ara8EGzoa4TP2WmmOIQ,82944
9
9
  pykubegrader/build/clean_folder.py,sha256=8N0KyL4eXRs0DCw-V_2jR9igtFs_mOFMQufdL6tD-38,1323
10
10
  pykubegrader/graders/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
11
11
  pykubegrader/graders/late_assignments.py,sha256=_2-rA5RqO0BWY9WAQA_mbCxxPKTOiJOl-byD2CYWaE0,1393
@@ -27,9 +27,9 @@ pykubegrader/widgets_base/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-
27
27
  pykubegrader/widgets_base/multi_select.py,sha256=Cl0IN21wXLZuFu-zC65aS9tD4jMfzCRJ2DPjHao5_Ak,4044
28
28
  pykubegrader/widgets_base/reading.py,sha256=_vjUPynqmJe_R4vf-7hVhGnQR726S9GL6qT8bflBXBM,5383
29
29
  pykubegrader/widgets_base/select.py,sha256=Fw3uFNOIWo1a3CvlzSx23bvi6bSmA3TqutuRbhD4Dp8,2525
30
- PyKubeGrader-0.2.22.dist-info/LICENSE.txt,sha256=YTp-Ewc8Kems8PJEE27KnBPFnZSxoWvSg7nnknzPyYw,1546
31
- PyKubeGrader-0.2.22.dist-info/METADATA,sha256=dPgcV3VFD4CAMAFJ2kQR8dw3ZY9wu1qls8k5gstiKJw,2779
32
- PyKubeGrader-0.2.22.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
33
- PyKubeGrader-0.2.22.dist-info/entry_points.txt,sha256=UPMdTT46fQwTYJWtrUwIWIbXbwyOPfNQgBFRa0frWzw,138
34
- PyKubeGrader-0.2.22.dist-info/top_level.txt,sha256=e550Klfze6higFxER1V62fnGOcIgiKRbsrl9CC4UdtQ,13
35
- PyKubeGrader-0.2.22.dist-info/RECORD,,
30
+ PyKubeGrader-0.2.24.dist-info/LICENSE.txt,sha256=YTp-Ewc8Kems8PJEE27KnBPFnZSxoWvSg7nnknzPyYw,1546
31
+ PyKubeGrader-0.2.24.dist-info/METADATA,sha256=iv1P7l0ln6yI66lxzwYBV7DUa-uLMcz_l8pa8HFzToA,2779
32
+ PyKubeGrader-0.2.24.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
33
+ PyKubeGrader-0.2.24.dist-info/entry_points.txt,sha256=UPMdTT46fQwTYJWtrUwIWIbXbwyOPfNQgBFRa0frWzw,138
34
+ PyKubeGrader-0.2.24.dist-info/top_level.txt,sha256=e550Klfze6higFxER1V62fnGOcIgiKRbsrl9CC4UdtQ,13
35
+ PyKubeGrader-0.2.24.dist-info/RECORD,,
@@ -60,6 +60,7 @@ class NotebookProcessor:
60
60
  verbose: bool = False
61
61
  log: bool = True
62
62
  require_key: bool = False
63
+ bonus_points: float = 0
63
64
 
64
65
  def __post_init__(self):
65
66
  """
@@ -80,6 +81,7 @@ class NotebookProcessor:
80
81
  assignment = data.get("assignment", {})
81
82
  week_num = assignment.get("week")
82
83
  self.assignment_type = assignment.get("assignment_type")
84
+ self.bonus_points = assignment.get("bonus_points", 0)
83
85
  else:
84
86
  self.assignment_type = self.assignment_tag.split("-")[0].lower()
85
87
  week_num = self.assignment_tag.split("-")[-1]
@@ -218,7 +220,6 @@ class NotebookProcessor:
218
220
  print(f"Error parsing due_date: {e}")
219
221
 
220
222
  title = f"Week {week} - {assignment_type}"
221
-
222
223
  # Return the extracted details as a dictionary
223
224
  return {
224
225
  "title": title,
@@ -226,7 +227,7 @@ class NotebookProcessor:
226
227
  "week_number": week,
227
228
  "assignment_type": assignment_type,
228
229
  "due_date": due_date,
229
- "max_score": int(self.assignment_total_points),
230
+ "max_score": self.assignment_total_points - self.bonus_points,
230
231
  }
231
232
 
232
233
  def build_payload_notebook(self, yaml_content, notebook_title, total_points):
@@ -575,7 +576,7 @@ class NotebookProcessor:
575
576
 
576
577
  if self.require_key:
577
578
  # Add an additional line for validate_token()
578
- validate_token_line = "from pykubegrader.submit.submit_assignment import validate_token\nvalidate_token()\n"
579
+ validate_token_line = "from pykubegrader.tokens.validate_token import validate_token\nvalidate_token()\n"
579
580
 
580
581
  # Define the Code cell
581
582
  code_cell = nbformat.v4.new_code_cell(
@@ -723,6 +724,38 @@ class NotebookProcessor:
723
724
  with open(notebook_path, "w", encoding="utf-8") as f:
724
725
  nbformat.write(notebook, f)
725
726
 
727
+ def add_validate_token_cell(notebook_path: str, require_key: bool) -> None:
728
+ """
729
+ Adds a new code cell at the top of a Jupyter notebook if require_key is True.
730
+
731
+ Args:
732
+ notebook_path (str): The path to the notebook file to modify.
733
+ require_key (bool): Whether to add the validate_token cell.
734
+
735
+ Returns:
736
+ None
737
+ """
738
+ if not require_key:
739
+ print("require_key is False. No changes made to the notebook.")
740
+ return
741
+
742
+ # Load the notebook
743
+ with open(notebook_path, "r", encoding="utf-8") as f:
744
+ notebook = nbformat.read(f, as_version=4)
745
+
746
+ # Create the new code cell
747
+ new_cell = nbformat.v4.new_code_cell(
748
+ "from pykubegrader.tokens.validate_token import validate_token\n"
749
+ "validate_token('type the key provided by your instructor here')\n"
750
+ )
751
+
752
+ # Add the new cell to the top of the notebook
753
+ notebook.cells.insert(0, new_cell)
754
+
755
+ # Save the modified notebook
756
+ with open(notebook_path, "w", encoding="utf-8") as f:
757
+ nbformat.write(notebook, f)
758
+
726
759
  @staticmethod
727
760
  def add_initialization_code(
728
761
  notebook_path, week, assignment_type, require_key=False
@@ -732,15 +765,13 @@ class NotebookProcessor:
732
765
  cell = cell["source"]
733
766
  import_text = "# You must make sure to run all cells in sequence using shift + enter or you might encounter errors\n"
734
767
  import_text += "from pykubegrader.initialize import initialize_assignment\n"
735
- if require_key:
736
- import_text += (
737
- "from pykubegrader.token.validate_token import validate_token\n"
738
- )
739
- import_text += "validate_token('type the key provided by your TA here')\n"
740
768
  import_text += f'\nresponses = initialize_assignment("{os.path.splitext(os.path.basename(notebook_path))[0]}", "{week}", "{assignment_type}" )\n'
741
769
  cell = f"{import_text}\n" + cell
742
770
  replace_cell_source(notebook_path, index, cell)
743
771
 
772
+ if require_key:
773
+ NotebookProcessor.add_validate_token_cell(notebook_path, require_key)
774
+
744
775
  def multiple_choice_parser(self, temp_notebook_path, new_notebook_path):
745
776
  ### Parse the notebook for multiple choice questions
746
777
  if self.has_assignment(temp_notebook_path, "# BEGIN MULTIPLE CHOICE"):