Update students.py
redacted personally identifying data wait this is in a git repo oh no
This commit is contained in:
229
students.py
229
students.py
@@ -1,123 +1,108 @@
|
|||||||
import logging
|
import logging
|
||||||
from random import choice as random_choice
|
from random import choice as random_choice
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
ID_TO_NAME: dict[int, str] = {
|
# Redacted
|
||||||
620319269233885226 : "Devan",
|
ID_TO_NAME: dict[int, str] = {
|
||||||
957378132061618217 : "CJ",
|
|
||||||
1077533292687007794 : "Connor",
|
}
|
||||||
964563429190930465 : "Michael",
|
|
||||||
909865829313683536 : "Bea",
|
# Redacted
|
||||||
821891090411421747 : "Mika",
|
STUDENT_IDS: set = ()
|
||||||
1093276870688133171 : "Daniel",
|
|
||||||
625861445833457694 : "Paul",
|
try:
|
||||||
1336780587662446593: "Mr. Jacobs"
|
ASSIGNED_ESSAY: dict = pickle.load(open("./data/assigned_essay.pkl", "rb"))
|
||||||
}
|
except FileNotFoundError:
|
||||||
|
logger.warning("No assigned essays found/saved, creating new dictionary.")
|
||||||
STUDENT_IDS: set = (620319269233885226, 957378132061618217, 1077533292687007794, 964563429190930465, 909865829313683536, 821891090411421747, 1093276870688133171, 625861445833457694)
|
ASSIGNED_ESSAY: dict[int, str] = {}
|
||||||
|
with open("./data/assigned_essay.pkl", "xb"):
|
||||||
try:
|
pass
|
||||||
ASSIGNED_ESSAY: dict = pickle.load(open("./data/assigned_essay.pkl", "rb"))
|
except EOFError:
|
||||||
except FileNotFoundError:
|
logger.warning("Assigned essays file is empty, creating new dictionary.")
|
||||||
logger.warning("No assigned essays found/saved, creating new dictionary.")
|
ASSIGNED_ESSAY: dict[int, str] = {}
|
||||||
ASSIGNED_ESSAY: dict[int, str] = {}
|
finally:
|
||||||
with open("./data/assigned_essay.pkl", "xb"):
|
logger.debug(f"Assigned essays: {ASSIGNED_ESSAY}")
|
||||||
pass
|
|
||||||
except EOFError:
|
# Redacted
|
||||||
logger.warning("Assigned essays file is empty, creating new dictionary.")
|
STUDENTS: dict[int, str] = {}
|
||||||
ASSIGNED_ESSAY: dict[int, str] = {}
|
|
||||||
finally:
|
ESSAY_TOPICS = ("why to not throw rocks during a fire drill",
|
||||||
logger.debug(f"Assigned essays: {ASSIGNED_ESSAY}")
|
"how to sit in a chair properly",
|
||||||
|
"how to keep your hands to yourself",
|
||||||
STUDENTS: dict[int, str] = {
|
"how to be on time",
|
||||||
620319269233885226 : "Devan\nWhile he's not super far ahead of the class, he's still ahead enough that he isn't forced to be on top of things like the rest of the class. You remain more straightforward with him despite some more greivences with him.",
|
"how to take accountability",
|
||||||
1077533292687007794 : "Connor\nYou are particularly scrutinizing to all of his behavior, especially whenever you find him 1. Playing chess. 2. On YouTube. 3. Listening to music on Spotify. Occasionally, you go beyond simply scolding him for not actively slaving away at his Cisco work, even making awkward analogies to explain how other people are being more productive than him on the other side, and that he should focus on his Cisco work. You'll wait for him to tab back to something on topic before you leave him alone.",
|
"why you shouldn't be wrong (be right!!!)",
|
||||||
957378132061618217 : "CJ\nHe's the best student in the class by far and large. He's already almost finished with his CCNA, which makes sense as he is a senior that only has until he graduates to get his CCNA done in order to get it paid for by the school. He's a really good kid, and you treat him as such. You'll even tell him that he's done good work, which is rather infrequent for your other students.",
|
"why picking cherries is healthy for mental health",
|
||||||
964563429190930465 : "Michael\nFor the most part you disregard him if he's not working on Cisco, occasionally requesting that he get back on track and then quickly disregarding him again and moving on. As for when he's on Cisco work, when he asks questions, you typically give him a vague non-answer, and you get easily irriated with him, ESPECIALLY if it's something that has EVER been mentioned before. Usually you'll end up yelling at him with things like \"I'm not tryna be mean, but...you should know this already.\" and then walking away.",
|
"why losing is bad, actually",
|
||||||
909865829313683536 : "Bea\nA student from Graphic Commerical Arts with blue hair and is not in the Computer Networking and Cybersecurity. Because of that, you can't really be mad at them for not focusing on Cisco. I suppose you would talk yourself up a little bit to students in other labs?",
|
"why you should be responsable when the bell rings and GET OUT because i'm HUNGRY",
|
||||||
821891090411421747 : "Mika\nA student from Animal Care and is not in the Computer Networking and Cybersecurity. Because of that, you can't really be mad at them for not focusing on Cisco. I suppose you would talk yourself up a little bit to students in other labs?",
|
"why you shouldn't hitlerpost in the public discord chat",
|
||||||
1093276870688133171 : "Daniel\nA student from Biotech and is not in the Computer Networking and Cybersecurity. Because of that, you can't really be mad at them for not focusing on Cisco. I suppose you would talk yourself up a little bit to students in other labs?",
|
"why having your professionalism packet is essential for your future career",
|
||||||
625861445833457694 : "Paul\nIt's PAUL!, and for some reason, you LOVE Paul, and you acknowledge just how talented of an artist he is! For some reason, you randomly walk up to him with 'How we doing Paul!?' You've even given him his own opurtnities ",
|
"why playing rock-paper-scissors over text is very productive",
|
||||||
1336780587662446593: "Mr. Jacobs\nYourself."
|
"why steak is the best food for my lunch break",
|
||||||
}
|
)
|
||||||
|
|
||||||
ESSAY_TOPICS = ("why to not throw rocks during a fire drill",
|
def get_essay_topic() -> str:
|
||||||
"how to sit in a chair properly",
|
return random_choice(ESSAY_TOPICS)
|
||||||
"how to keep your hands to yourself",
|
|
||||||
"how to be on time",
|
def assign_essay(student_id: int, essay: str = get_essay_topic()) -> str:
|
||||||
"how to take accountability",
|
"""Assigns a student an essay
|
||||||
"why you shouldn't be wrong (be right!!!)",
|
|
||||||
"why picking cherries is healthy for mental health",
|
Args:
|
||||||
"why losing is bad, actually",
|
student_id (int): The Discord ID of the student getting the essay.
|
||||||
"why you should be responsable when the bell rings and GET OUT because i'm HUNGRY",
|
essay (str, optional): The topic of the essay being assigned. Defaults to get_essay_topic().
|
||||||
"why you shouldn't hitlerpost in the public discord chat",
|
|
||||||
"why having your professionalism packet is essential for your future career",
|
Raises:
|
||||||
"why playing rock-paper-scissors over text is very productive",
|
ValueError: If the student ID is not in STUDENT_IDS.
|
||||||
"why steak is the best food for my lunch break",
|
|
||||||
)
|
Returns:
|
||||||
|
str: The topic of the essay assigned.
|
||||||
def get_essay_topic() -> str:
|
"""
|
||||||
return random_choice(ESSAY_TOPICS)
|
if student_id in STUDENT_IDS:
|
||||||
|
ASSIGNED_ESSAY[student_id] = essay
|
||||||
def assign_essay(student_id: int, essay: str = get_essay_topic()) -> str:
|
pickle.dump(ASSIGNED_ESSAY, open("./data/assigned_essay.pkl", "wb"))
|
||||||
"""Assigns a student an essay
|
return essay
|
||||||
|
else:
|
||||||
Args:
|
raise ValueError(f"Student ID {student_id} is not a valid student ID.")
|
||||||
student_id (int): The Discord ID of the student getting the essay.
|
|
||||||
essay (str, optional): The topic of the essay being assigned. Defaults to get_essay_topic().
|
def get_essay(student_id: int = None) -> str:
|
||||||
|
"""Gets the assigned essay for a student
|
||||||
Raises:
|
|
||||||
ValueError: If the student ID is not in STUDENT_IDS.
|
Args:
|
||||||
|
student_id (int): The Discord ID of the student to get the essay for.
|
||||||
Returns:
|
|
||||||
str: The topic of the essay assigned.
|
Raises:
|
||||||
"""
|
ValueError: If the student ID is not in STUDENT_IDS.
|
||||||
if student_id in STUDENT_IDS:
|
|
||||||
ASSIGNED_ESSAY[student_id] = essay
|
Returns:
|
||||||
pickle.dump(ASSIGNED_ESSAY, open("./data/assigned_essay.pkl", "wb"))
|
str: The topic of the essay assigned to the student.
|
||||||
return essay
|
"""
|
||||||
else:
|
if student_id:
|
||||||
raise ValueError(f"Student ID {student_id} is not a valid student ID.")
|
if student_id in STUDENT_IDS:
|
||||||
|
return ASSIGNED_ESSAY.get(student_id, "No essay assigned.")
|
||||||
def get_essay(student_id: int = None) -> str:
|
else:
|
||||||
"""Gets the assigned essay for a student
|
essays: str = ""
|
||||||
|
for essay in ASSIGNED_ESSAY:
|
||||||
Args:
|
essays += f"<@{essay}>: {ASSIGNED_ESSAY[essay]}\n"
|
||||||
student_id (int): The Discord ID of the student to get the essay for.
|
return essays if essays else "No essays assigned."
|
||||||
|
|
||||||
Raises:
|
|
||||||
ValueError: If the student ID is not in STUDENT_IDS.
|
def clear_essay(student_id):
|
||||||
|
"""Clears an assigned essay from a student
|
||||||
Returns:
|
|
||||||
str: The topic of the essay assigned to the student.
|
Args:
|
||||||
"""
|
student_id (int): The Discord ID of the student to clear the essay from.
|
||||||
if student_id:
|
|
||||||
if student_id in STUDENT_IDS:
|
Raises:
|
||||||
return ASSIGNED_ESSAY.get(student_id, "No essay assigned.")
|
ValueError: If the student ID is not in STUDENT_IDS.
|
||||||
else:
|
"""
|
||||||
essays: str = ""
|
if student_id in STUDENT_IDS:
|
||||||
for essay in ASSIGNED_ESSAY:
|
ASSIGNED_ESSAY.pop(student_id)
|
||||||
essays += f"<@{essay}>: {ASSIGNED_ESSAY[essay]}\n"
|
pickle.dump(ASSIGNED_ESSAY, open("./data/assigned_essay.pkl", "wb"))
|
||||||
return essays if essays else "No essays assigned."
|
else:
|
||||||
|
raise ValueError(f"Student ID {student_id} is not a valid student ID.")
|
||||||
|
|
||||||
def clear_essay(student_id):
|
|
||||||
"""Clears an assigned essay from a student
|
if __name__ == "__main__":
|
||||||
|
|
||||||
Args:
|
|
||||||
student_id (int): The Discord ID of the student to clear the essay from.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
ValueError: If the student ID is not in STUDENT_IDS.
|
|
||||||
"""
|
|
||||||
if student_id in STUDENT_IDS:
|
|
||||||
ASSIGNED_ESSAY.pop(student_id)
|
|
||||||
pickle.dump(ASSIGNED_ESSAY, open("./data/assigned_essay.pkl", "wb"))
|
|
||||||
else:
|
|
||||||
raise ValueError(f"Student ID {student_id} is not a valid student ID.")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print(get_essay())
|
print(get_essay())
|
||||||
Reference in New Issue
Block a user