Browse Source

Show quiz hint if answered wrong

master
morethanwords 4 years ago
parent
commit
b5430d88fb
  1. 11
      src/components/poll.ts

11
src/components/poll.ts

@ -160,6 +160,7 @@ export default class PollElement extends HTMLElement {
private chosingIndexes: number[] = []; private chosingIndexes: number[] = [];
private sendVotePromise: Promise<void>; private sendVotePromise: Promise<void>;
private sentVote = false;
constructor() { constructor() {
super(); super();
@ -406,6 +407,13 @@ export default class PollElement extends HTMLElement {
toggleHint.classList.remove('active'); toggleHint.classList.remove('active');
}); });
}); });
if(this.sentVote) {
const correctResult = results.results.find(r => r.pFlags.correct);
if(correctResult && !correctResult.pFlags.chosen) {
toggleHint.click();
}
}
} }
} }
@ -445,12 +453,15 @@ export default class PollElement extends HTMLElement {
}); });
this.classList.add('disable-hover'); this.classList.add('disable-hover');
this.sentVote = true;
return this.sendVotePromise = appPollsManager.sendVote(this.mid, indexes).then(() => { return this.sendVotePromise = appPollsManager.sendVote(this.mid, indexes).then(() => {
targets.forEach(target => { targets.forEach(target => {
target.classList.remove('is-voting'); target.classList.remove('is-voting');
}); });
this.classList.remove('disable-hover'); this.classList.remove('disable-hover');
}).catch(() => {
this.sentVote = false;
}).finally(() => { }).finally(() => {
this.sendVotePromise = null; this.sendVotePromise = null;
}); });

Loading…
Cancel
Save