Skip to content

Commit 48375c9

Browse files
committed
merge main branch and make async step banner more clear
1 parent ed893ae commit 48375c9

3 files changed

Lines changed: 66 additions & 5 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,25 @@ def dashboard():
143143
is_last=done,
144144
lti=is_lti,
145145
has_vote1=has_vote1,
146+
peer_async_visible=assignment.peer_async_visible or False,
146147
**course_attrs,
147148
)
148149

149150

151+
@auth.requires(
152+
lambda: verifyInstructorStatus(auth.user.course_id, auth.user),
153+
requires_login=True,
154+
)
155+
def toggle_async():
156+
response.headers["content-type"] = "application/json"
157+
assignment_id = request.vars.assignment_id
158+
assignment = db(db.assignments.id == assignment_id).select().first()
159+
new_value = not (assignment.peer_async_visible or False)
160+
db(db.assignments.id == assignment_id).update(peer_async_visible=new_value)
161+
db.commit()
162+
return json.dumps({"peer_async_visible": new_value})
163+
164+
150165
def extra():
151166
assignment_id = request.vars.assignment_id
152167
current_question, done, idx = _get_current_question(assignment_id, False)

bases/rsptx/web2py_server/applications/runestone/views/peer/dashboard.html

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ <h3>Question {{ =current_qnum }} of {{ =num_questions }}</h3>
6161
</div>
6262

6363
<div id="pi-assignment-navigation">
64+
{{ if current_qnum < num_questions: }}
6465
<button
6566
type="submit"
6667
id="nextq"
@@ -70,6 +71,19 @@ <h3>Question {{ =current_qnum }} of {{ =num_questions }}</h3>
7071
>
7172
Next Question
7273
</button>
74+
{{ else: }}
75+
<div id="asyncBtnArea" style="display:inline-block;">
76+
<button
77+
type="button"
78+
id="toggleAsyncBtn"
79+
class="btn btn-info" {{ if peer_async_visible: }}style="background-color:#a3d4ec; border-color:#a3d4ec; color:#fff;"{{ pass }}
80+
onclick="showAsyncConfirm()"
81+
style="margin-right: 4px;"
82+
>
83+
{{ if peer_async_visible: }}Undo After-Class Release{{ else: }}Release After-Class PI{{ pass }}
84+
</button>
85+
</div>
86+
{{ pass }}
7387
<button
7488
type="submit"
7589
id="restart"
@@ -349,8 +363,33 @@ <h3>Question {{ =current_qnum }} of {{ =num_questions }}</h3>
349363
var mess_count = 0;
350364
var answerCount = 0;
351365
var done = {{=is_last }}
352-
if (done) {
353-
document.getElementById("nextq").disabled = true;
366+
367+
var asyncReleased = {{=peer_async_visible}};
368+
369+
function showAsyncConfirm() {
370+
var area = document.getElementById("asyncBtnArea");
371+
var msg = asyncReleased
372+
? "Undo the after-class PI release?"
373+
: "Release after-class PI questions to students?";
374+
area.innerHTML = `
375+
<span style="margin-right:6px; font-weight:bold;">${msg}</span>
376+
<button type="button" class="btn btn-sm btn-default" onclick="confirmToggleAsync()" style="margin-right:4px;">Yes</button>
377+
<button type="button" class="btn btn-sm btn-default" onclick="cancelAsyncConfirm()">Cancel</button>
378+
`;
379+
}
380+
381+
function cancelAsyncConfirm() {
382+
var area = document.getElementById("asyncBtnArea");
383+
var label = asyncReleased ? "Undo After-Class Release" : "Release After-Class PI";
384+
var extraStyle = asyncReleased ? 'style="background-color:#a3d4ec; border-color:#a3d4ec; color:#fff; margin-right:4px;"' : 'style="margin-right:4px;"';
385+
area.innerHTML = `<button type="button" id="toggleAsyncBtn" class="btn btn-info" onclick="showAsyncConfirm()" ${extraStyle}>${label}</button>`;
386+
}
387+
388+
async function confirmToggleAsync() {
389+
var resp = await fetch("/runestone/peer/toggle_async?assignment_id={{=assignment_id}}", { method: "POST" });
390+
var data = await resp.json();
391+
asyncReleased = data.peer_async_visible;
392+
cancelAsyncConfirm();
354393
}
355394
</script>
356395
{{ end }}

bases/rsptx/web2py_server/applications/runestone/views/peer/peer_async.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ <h2>Peer Instruction Question (After Class)</h2>
5353
<ol>
5454
<li>Answer the question as best you can.</li>
5555
<li>Then, in the space provided write a justification for your answer.</li>
56-
<li>Read the dialog between two of your peers on why they answered the question the way they did.</li>
56+
{{ if llm_enabled: }}
57+
<li>Discuss the question with an AI peer — explain your reasoning and respond to their questions.</li>
58+
{{ else: }}
59+
<li>Read the discussion between other students on why they answered the question the way they did.</li>
60+
{{ pass }}
5761
<li>Answer the question <strong>again.</strong> Even if you are not changing your answer from the first time.</li>
5862
</ol>
5963
</p>
@@ -116,7 +120,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
116120
</div>
117121

118122
<p id="llmDisclaimer" style="display:none; font-size:0.8em; color:#888; margin-top:4px; margin-bottom:0;">
119-
You are chatting with an AI, not a real peer.
123+
You are chatting with an LLM, not a real peer.
120124
</p>
121125
<p id="nextStep" style="margin-top:8px; font-style:italic;"></p>
122126
</div>
@@ -142,6 +146,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
142146
{{ pass }}
143147
<script>
144148
window.DISABLE_ASYNC_EXPLAINER = true;
149+
window.PI_LLM_MODE = {{="true" if llm_enabled else "false"}};
145150
</script>
146151
<script src="/runestone/static/js/peer.js?v={{=request.peer_mtime}}"></script>
147152
<script>
@@ -192,7 +197,9 @@ <h3>Congratulations, you have completed this assignment!</h3>
192197
label = "Step 1 of 3: Answer the question";
193198
bg = "#4A9FDE";
194199
} else if (step === 2) {
195-
label = "Step 2 of 3: Explain your answer and discuss";
200+
label = window.PI_LLM_MODE
201+
? "Step 2 of 3: Explain your answer and discuss with the LLM peer"
202+
: "Step 2 of 3: Explain your answer and read the previous discussions";
196203
bg = "#2878B5";
197204
} else if (step === 3) {
198205
label = "Step 3 of 3: Vote again — you may keep or change your answer";

0 commit comments

Comments
 (0)