Skip to content

Commit 2d1f4f5

Browse files
committed
fix security check and question_json bug in async mode
1 parent ba44242 commit 2d1f4f5

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

  • bases/rsptx
    • assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/AssignmentExercisesList
    • web2py_server/applications/runestone/controllers

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/AssignmentExercisesList/AssignmentExercisesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ export const AssignmentExercisesTable = ({
365365
<Dropdown
366366
className="editable-table-dropdown"
367367
value={data.use_llm && hasApiKey ? "LLM" : "Standard"}
368-
onChange={(e) => updateAssignmentQuestions([{ ...data, use_llm: e.value === "LLM" }])}
368+
onChange={(e) => updateAssignmentQuestions([{ ...data, question_json: JSON.stringify(data.question_json), use_llm: e.value === "LLM" }])}
369369
options={[
370370
{ label: "Standard", value: "Standard" },
371371
{ label: "LLM", value: "LLM", disabled: !hasApiKey }

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ def dashboard():
155155
def toggle_async():
156156
response.headers["content-type"] = "application/json"
157157
assignment_id = request.vars.assignment_id
158+
if not assignment_id:
159+
return json.dumps({"ok": False, "error": "missing assignment_id"})
158160
assignment = db(db.assignments.id == assignment_id).select().first()
161+
if not assignment:
162+
return json.dumps({"ok": False, "error": "assignment not found"})
163+
course = db(db.courses.course_name == auth.user.course_name).select().first()
164+
if not course or assignment.course != course.id:
165+
return json.dumps({"ok": False, "error": "assignment does not belong to your course"})
159166
new_value = not (assignment.peer_async_visible or False)
160167
db(db.assignments.id == assignment_id).update(peer_async_visible=new_value)
161168
db.commit()

0 commit comments

Comments
 (0)