Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Fix peer ratings for larger groups
Browse files Browse the repository at this point in the history
* Bug fix on students that do not answer
  • Loading branch information
bnmnetp committed Feb 16, 2022
1 parent 55d1fd2 commit cbfe623
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
11 changes: 6 additions & 5 deletions controllers/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def _get_n_answers(num_answer, div_id, course_name, start_time):
df = df.dropna(subset=["answer"])
logger.debug(df.head())
# FIXME: this breaks for multiple answer mchoice!
df = df[df.answer != ""]
df["answer"] = df.answer.astype("int64")

return df
Expand Down Expand Up @@ -248,7 +249,7 @@ def make_pairs():
response.headers["content-type"] = "application/json"
div_id = request.vars.div_id
df = _get_n_answers(1, div_id, auth.user.course_name, request.vars.start_time)
group_size = request.vars.get("group_size", 2)
group_size = int(request.vars.get("group_size", 2))
logger.debug(f"STARTING to make pairs for {auth.user.course_name}")
# answers = list(df.answer.unique())
correct = df[df.correct == "T"][["sid", "answer"]]
Expand Down Expand Up @@ -345,10 +346,10 @@ def publish_message():
def log_peer_rating():
response.headers["content-type"] = "application/json"
current_question = request.vars.div_id
peer_sid = request.vars.peer_id
r = redis.from_url(os.environ.get("REDIS_URI", "redis://redis:6379/0"))
peer_sid = r.hget(f"partnerdb_{auth.user.course_name}", auth.user.username)
retmess = "Error: no peer to rate"
if peer_sid:
peer_sid = peer_sid.decode("utf8")
db.useinfo.insert(
course_id=auth.user.course_name,
sid=auth.user.username,
Expand All @@ -357,6 +358,6 @@ def log_peer_rating():
act=f"{peer_sid}:{request.vars.rating}",
timestamp=datetime.datetime.utcnow(),
)
return json.dumps("success")
retmess = "success"

return json.dumps("Error: no peer to rate")
return json.dumps(retmess)
7 changes: 7 additions & 0 deletions static/js/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ function connect(event) {
let currAnswer = String.fromCharCode(ordA + parseInt(mess.answer));
newpeer.innerHTML = `Your partner, ${mess.from}, answered ${currAnswer}`;
peerlist.appendChild(newpeer);
let peersel = document.getElementById("peersel");
let peeropt = document.createElement("option");
peeropt.value = mess.from;
peeropt.innerHTML = mess.from;
peersel.appendChild(peeropt);
break;
default:
console.log("unknown control message");
Expand Down Expand Up @@ -269,10 +274,12 @@ async function ratePeer(radio) {
"Content-type": "application/json; charset=utf-8",
Accept: "application/json",
});
let peerToRate = document.getElementById("peersel").value;
let eventInfo = {
sid: eBookConfig.username,
div_id: currentQuestion,
event: "ratepeer",
peer_id: peerToRate,
course_id: eBookConfig.course,
rating: radio.value,
};
Expand Down
2 changes: 1 addition & 1 deletion views/peer/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2>Peer Instruction Dashboard</h2>
</select>
<br/>
<button type="button" id="vote1" class="btn btn-info" onclick="warnAndStopVote(event)">Stop Vote 1</button>
<button type="button" id="makep" class="btn btn-info" onclick="makePartners(event)">Make Partners</button>
<button type="button" id="makep" class="btn btn-info" onclick="makePartners(event)">Enable Discussion</button>
<button type="button" id="vote2" class="btn btn-info" onclick="startVote2(event)">Start Vote 2</button>
<button type="button" id="vote3" class="btn btn-info" onclick="warnAndStopVote(event)">Stop Vote 2</button>
<button type="submit" id="nextq" class="btn btn-info" name="next" value="Next">Next
Expand Down
3 changes: 2 additions & 1 deletion views/peer/peer_question.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ <h2>Peer Instruction Question</h2>
</div>
<form>
<div class="form-group">
Please provide a confidential rating of your peer's explanation<br />
Please provide a confidential rating of <select id="peersel" name="peercel"></select>
peer's explanation<br />
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="poor"
onclick="ratePeer(this)">
<label class="form-check-label" for="inlineRadio1">Poor</label>
Expand Down

0 comments on commit cbfe623

Please sign in to comment.