Skip to content

Commit e7e0e99

Browse files
committed
Add step banner to async PI and improve voting stage clarity
1 parent c76b918 commit e7e0e99

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ def peer_async():
724724
question_num = int(request.vars.question_num)
725725

726726
current_question, all_done = _get_numbered_question(assignment_id, question_num - 1)
727+
total_questions = len(_get_assignment_questions(assignment_id))
727728

728729
assignment = db(db.assignments.id == assignment_id).select().first()
729730

@@ -762,6 +763,8 @@ def peer_async():
762763
assignment_id=assignment_id,
763764
assignment_name=assignment.name,
764765
nextQnum=question_num + 1,
766+
total_questions=total_questions,
767+
is_last_question=(question_num >= total_questions),
765768
all_done=all_done,
766769
has_vote1=has_vote1,
767770
has_reflection=has_reflection,

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@
3333
</div>
3434

3535
<h2>Peer Instruction Question (After Class)</h2>
36+
37+
{{ if all_done == "false": }}
38+
<div id="stepBanner" style="
39+
background: #337ab7;
40+
color: #fff;
41+
padding: 10px 16px;
42+
border-radius: 4px;
43+
margin-bottom: 12px;
44+
font-size: 16px;
45+
font-weight: bold;
46+
">
47+
Step 1 of 3: Answer the question
48+
</div>
49+
{{ pass }}
50+
3651
<div id="imessage">
3752
<p>This page is meant for you to use <i>after</i> the inclass peer instruction is over.
3853
<ol>
@@ -42,7 +57,7 @@ <h2>Peer Instruction Question (After Class)</h2>
4257
<li>Answer the question <strong>again.</strong> Even if you are not changing your answer from the first time.</li>
4358
</ol>
4459
</p>
45-
</div>
60+
</div>
4661

4762
<div class="row">
4863
{{ if all_done == "false": }}
@@ -110,7 +125,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
110125
<form action="/peer/peer_async" style="display: inline;">
111126
<input type="hidden" name="assignment_id" value="{{=assignment_id}}" />
112127
<input type="hidden" name="question_num" value="{{=nextQnum}}" />
113-
<button type="submit" onclick="return checkVoteCount()" class="btn btn-default">Next Question</button>
128+
<button type="submit" onclick="return checkVoteCount()" class="btn btn-default">{{ if is_last_question: }}Done{{ else: }}Next Question{{ pass }}</button>
114129
</form>
115130
</div>
116131
{{ pass }}
@@ -156,6 +171,28 @@ <h3>Congratulations, you have completed this assignment!</h3>
156171
if (btn) btn.disabled = true;
157172
}
158173

174+
function updateStepBanner(step) {
175+
const banner = document.getElementById("stepBanner");
176+
if (!banner) return;
177+
if (step === 1) {
178+
banner.textContent = "Step 1 of 3: Answer the question";
179+
banner.style.background = "#337ab7";
180+
} else if (step === 2) {
181+
banner.textContent = "Step 2 of 3: Explain your answer and discuss";
182+
banner.style.background = "#f0ad4e";
183+
banner.style.color = "#333";
184+
} else if (step === 3) {
185+
banner.textContent = "Step 3 of 3: Vote again — you may keep or change your answer";
186+
banner.style.background = "#427e44";
187+
banner.style.color = "#fff";
188+
} else if (step === 4) {
189+
const hasNextQ = document.querySelector('form[action="/peer/peer_async"]');
190+
banner.textContent = hasNextQ ? "Done! Move to the next question." : "Done! You have completed this assignment.";
191+
banner.style.background = "#427e44";
192+
banner.style.color = "#fff";
193+
}
194+
}
195+
159196
function setReflectionPanelEnabled(enabled) {
160197
const panel = document.getElementById("reflectionPanel");
161198
if (!panel) return;
@@ -173,6 +210,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
173210
alert("Please submit your first vote before voting again.");
174211
return;
175212
}
213+
updateStepBanner(3);
176214

177215
window._vote2Enabled = true;
178216
window._vote1Locked = false;
@@ -630,6 +668,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
630668
if (studentVoteCount === 1 && !window._vote2Enabled) {
631669
hasVote1 = true;
632670
console.log("vote 1 submitted");
671+
updateStepBanner(2);
633672

634673
const vote2Btn = document.getElementById("readyVote2Btn");
635674
if (vote2Btn) {
@@ -647,6 +686,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
647686
studentVoteCount = 2;
648687
studentSubmittedVote2 = true;
649688
window._vote2Enabled = false;
689+
updateStepBanner(4);
650690
}
651691
if (studentSubmittedVote2) {
652692
try {

0 commit comments

Comments
 (0)