Skip to content

Commit

Permalink
#patch pygrader-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jagar2 committed Dec 9, 2024
1 parent 3ab4326 commit c61ef8c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pykubegrader/mc_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def MCQ(
]

radio_buttons = [
pn.widgets.RadioButtonGroup(
pn.widgets.RadioBoxGroup(
options=option,
value=value,
width=300,
Expand Down
5 changes: 5 additions & 0 deletions src/pykubegrader/seed/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Auto-generated __init__.py

from . import hash_seed

__all__ = ['hash_seed']
25 changes: 25 additions & 0 deletions src/pykubegrader/seed/hash_seed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import hashlib

def hash_to_seed(input_string):
"""
Hash a string into a small integer seed less than 500.
Parameters:
input_string (str): The string to hash.
Returns:
int: A seed value (0 <= seed < 500).
"""
# Ensure the input is a string
input_string = str(input_string)

# Create a SHA-256 hash of the string
hash_object = hashlib.sha256(input_string.encode())

# Convert the hash to an integer
large_number = int.from_bytes(hash_object.digest(), 'big')

# Reduce the number to a value less than 500
small_seed = large_number % 500

return small_seed
2 changes: 1 addition & 1 deletion src/pykubegrader/select_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(

self.layout = pn.Column(
f"# Question {self.question_number}: {title}",
*(pn.Row(desc_widget, dropdown) for desc_widget, dropdown in widget_pairs),
*(pn.Column(desc_widget, pn.Row(dropdown)) for desc_widget, dropdown in widget_pairs),
self.submit_button,
)

Expand Down

0 comments on commit c61ef8c

Please sign in to comment.