Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/priority voting visualization #76

Merged
merged 7 commits into from
Dec 19, 2023
51 changes: 41 additions & 10 deletions decide/booth/templates/booth/booth.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,34 @@
<div class="card-voting" v-if="!signup">
<h1 class="voting-title">[[ voting.name ]]</h1>
<h2 class="voting-desc">[[ voting.question.desc ]]</h2>
<form v-for="opt in voting.question.options" :key="opt.number">
<form>
<div class="form-options">
<input type="radio" v-model="selected" v-if="questionType == 'S' || questionType == 'B'"
:id="'q' + opt.number"
name="question"
:value="opt.number">
<input type="checkbox" v-model="selected" v-if="questionType == 'M'"
:id="'q' + opt.number"
name="question"
:value="opt.number">
[[ opt.option ]]
<div v-if="questionType == 'S' || questionType == 'B' || questionType == 'M'" v-for="opt in voting.question.options" :key="opt.number">
<input type="radio" v-model="selected" v-if="questionType == 'S' || questionType == 'B'"
:id="'q' + opt.number"
name="question"
:value="opt.number">
<input type="checkbox" v-model="selected" v-if="questionType == 'M'"
:id="'q' + opt.number"
name="question"
:value="opt.number">

[[ opt.option ]]
</div>
<div v-if="questionType == 'P'">
<br>
<p> Remember that 1 is the highest priority and [[voting.question.options.length]] is the lowest priority</p>
<br>
<div v-for="(opt, index) in voting.question.options">
<select v-model="selected[index]">
<option v-for="opt in voting.question.options">
[[ opt.number ]]
</option>
</select> [[opt.option]]
<div>Selected priority of [[ selected[index] ]] for [[opt.option]]</div>
<br>
</div>
</div>
</div>
</form>
<button class="btn btn-vote mt-3" v-on:click="decideSend">
Expand Down Expand Up @@ -255,6 +272,20 @@ <h2 class="voting-desc">[[ voting.question.desc ]]</h2>
token: this.token
}
}
else if (this.questionType === 'P') {
var selectedOptions = this.voting.question.options.map((opt, index) => [opt.number, this.selected[index]]);
var vote = []
for (i=0; i < selectedOptions.length; i++){
var v = this.decideEncrypt(selectedOptions[i][0].toString())
vote.push({a: v.alpha.toString(), b: v.beta.toString(), p: selectedOptions[i][1].toString()})
}
var data = {
vote: vote,
voting: this.voting.id,
voter: this.user.id,
token: this.token
}
}

this.postData("{% url "gateway" "store" "/" %}", data)
.then(data => {
Expand Down