Skip to content

Commit f5d8f1c

Browse files
committed
add comments to functions
1 parent 73e5d21 commit f5d8f1c

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

bases/rsptx/web2py_server/applications/runestone/controllers/peer.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ def get_async_explainer():
802802
logger.debug(f"Get message for {div_id}")
803803
return json.dumps({"mess": mess, "user": "", "answer": "", "responses": {}})
804804

805-
805+
#get question text, code, and answer choices for an MCQ
806806
def _get_mcq_context(div_id):
807807
q = db(db.questions.name == div_id).select().first()
808808
if not q:
@@ -824,6 +824,9 @@ def _get_mcq_context(div_id):
824824
logger.warning(f"Could not parse choices for {div_id}: {e}")
825825
return question, code, choices
826826

827+
828+
#handle async peer instruction reflection using an LLM:
829+
#logs student messages and return an LLM peer-style reply
827830
@auth.requires_login()
828831
def get_async_llm_reflection():
829832
logger.warning("LLM REFLECTION CALLED")
@@ -948,9 +951,9 @@ def get_async_llm_reflection():
948951
try:
949952
db.useinfo.insert(
950953
course_id=auth.user.course_name,
951-
sid="llm_peer",
954+
sid=auth.user.username,
952955
div_id=div_id,
953-
event="sendmessage",
956+
event="llm_peer_sendmessage",
954957
act=f"to: student:{reply}",
955958
timestamp=datetime.datetime.utcnow(),
956959
)
@@ -981,7 +984,7 @@ def _get_user_answer(div_id, s):
981984
return ans.act.split(":")[1]
982985
else:
983986
return ""
984-
987+
#check if the student has already submitted a reflection for the question
985988
def _has_reflection(div_id, sid):
986989
row = (
987990
db(
@@ -1041,11 +1044,11 @@ def send_lti_scores():
10411044
return json.dumps("success")
10421045

10431046

1044-
1047+
#determine whether LLM-based async peer discussion is enabled for this course based on coursewide api key
10451048
def _llm_enabled():
10461049
return bool(_get_course_openai_key())
10471050

1048-
1051+
#fetch the course-wide openai API key used to enable LLM-based async peer discussion (only works for openai currently)
10491052
def _get_course_openai_key():
10501053
try:
10511054
token_record = asyncio.get_event_loop().run_until_complete(
@@ -1057,6 +1060,8 @@ def _get_course_openai_key():
10571060
logger.exception("Failed to fetch course-wide OpenAI token for peer LLM")
10581061
return ""
10591062

1063+
1064+
#call the openai chat completion API using the course-wide token and return the model reply
10601065
def _call_openai(messages):
10611066
"""
10621067
Minimal HTTP call using the instructor-provided course-wide OpenAI token.

bases/rsptx/web2py_server/applications/runestone/static/js/peer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ qq.enableInteraction();
757757
}
758758
}
759759

760-
760+
//re-enable interaction so the student can submit their second vote (async PI)
761761
function enableSecondVoteAsync() {
762762
console.log("Enabling second vote (async)");
763763

@@ -848,6 +848,7 @@ async function setupPeerGroup() {
848848

849849
}
850850

851+
//insert the "Ready for Vote 2" button into the discussion area (async PI only)
851852
function insertReadyVote2Button() {
852853
if (document.getElementById("readyVote2Btn")) return;
853854

docker-compose.override.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
services:
2-
runestone:
3-
env_file:
4-
- .env
5-
volumes:
6-
- ./bases/rsptx/web2py_server/applications/runestone/controllers:/usr/local/lib/python3.10/site-packages/rsptx/web2py_server/applications/runestone/controllers
7-
- ./bases/rsptx/web2py_server/applications/runestone/views:/usr/local/lib/python3.10/site-packages/rsptx/web2py_server/applications/runestone/views
8-
- ./bases/rsptx/web2py_server/applications/runestone/static/js:/usr/local/lib/python3.10/site-packages/rsptx/web2py_server/applications/runestone/static/js

0 commit comments

Comments
 (0)