Commit ed8d81d2 authored by Curtis Adam's avatar Curtis Adam

Transcript bonus: Replace the minimum stars slider with a 1- 5 stars rating

parent 78f3606e
......@@ -2842,7 +2842,7 @@ $themes: (
color: $transcript_rating_about_card_icon !important;
}
.label-transcript-rating-stars {
.label-transcript-rating-stars, .transcript-bonus-settings {
background-color: $transcript_rating_stars_label_background !important;
i, i:hover {
color: $transcript_rating_stars_icon !important;
......@@ -2855,14 +2855,14 @@ $themes: (
color: $transcript_rating_stars_card_icon !important;
}
}
.transcript-bonus-statistics-info {
.fa-star, fa-star:hover {
color: $transcript_rating_stars_icon_rated !important;
.transcript-bonus-statistics-info, .transcript-bonus-settings {
.fa-star, .fa-star:hover {
color: $transcript_rating_stars_icon !important;
}
}
.label-transcript-rating-stars {
i.rated, i.rated:hover {
.label-transcript-rating-stars, .transcript-bonus-settings {
.fa-star.rated, .fa-star.rated:hover {
color: $transcript_rating_stars_icon_rated !important;
}
}
......
......@@ -729,7 +729,7 @@
"enable": "Bonus aktivieren",
"minimum": {
"submissions": "Mitschriften für max. Bonus",
"stars": "Sterne für max. Bonus"
"stars": "Sterne für max. Bonus pro Mitschrift"
},
"lectureTimeEnd": "Freischaltung",
"deadline": {
......
......@@ -732,7 +732,7 @@
"enable": "Bonus aktivieren",
"minimum": {
"submissions": "Number of transcripts for maximum number of bonus points",
"stars": "Number of stars for maximum number of bonus points"
"stars": "Stars for max. bonus per transcript"
},
"lectureTimeEnd": "Vorlesungsende",
"deadline": {
......
......@@ -863,13 +863,13 @@ Meteor.startup(function () {
}
);
}
if (cardsets[i].transcriptBonus.minimumStars === undefined) {
if (cardsets[i].transcriptBonus.minimumStars === undefined || cardsets[i].transcriptBonus.minimumStars > 5) {
Cardsets.update({
_id: cardsets[i]._id
},
{
$set: {
"transcriptBonus.minimumStars": cardsets[i].transcriptBonus.dates.length * 5
"transcriptBonus.minimumStars": 3
}
}
);
......
......@@ -18,7 +18,7 @@ Template.cardsetIndexTranscriptItemSave.events({
let deadlineSubmission = $('#deadlineHoursSubmission').val();
let dates = $('#transcript-calendar').multiDatesPicker('getDates');
let minimumSubmissions = $('#bonusMinimumSubmissions').val();
let minimumStars = $('#bonusMinimumStars').val();
let minimumStars = Session.get('minimumBonusStars');
let newDates = [];
for (let d = 0; d < dates.length; d++) {
newDates.push(moment(dates[d], "MM/DD/YYYY").toDate());
......
......@@ -10,14 +10,21 @@
<input type="number" id="bonusPercentage" min="1" max="10" step="1" value="10" required>
<span class="unit">%</span>
<br>
<label>{{_ "transcriptForm.bonus.form.minimum.submissions"}}:&nbsp;<span id="minSubmissionsValue"></span></label>
<label>{{_ "transcriptForm.bonus.form.minimum.submissions"}}:&nbsp;<span
id="minSubmissionsValue"></span></label>
<form class="range-field">
<input id="bonusMinimumSubmissions" type="range" min="1" step="1" max="10" />
</form>
<label>{{_ "transcriptForm.bonus.form.minimum.stars"}}:&nbsp;<span id="minStarsValue"></span></label>
<form class="range-field">
<input id="bonusMinimumStars" type="range" min="1" step="1" max="7" />
<input id="bonusMinimumSubmissions" type="range" min="1" step="1" max="10"/>
</form>
<label>{{_ "transcriptForm.bonus.form.minimum.stars"}}:&nbsp;
<span class="transcript-bonus-settings">
{{#each getBonusTranscriptStars}}
<a href="" class="stars-setting" title="{{getBonusTranscriptStarsTooltip @index}}"
data-id="{{@index}}"><i
class="fas fa-star {{this.status}}"></i></a>
{{/each}}
</span>
</label>
</div>
<div class="col-xs12 col-sm-6">
<label>{{_ "transcriptForm.bonus.form.deadline.submission"}}:&nbsp;</label>
......
......@@ -7,6 +7,8 @@ import {Template} from "meteor/templating";
* ############################################################################
*/
Session.setDefault('minimumBonusStars', 1);
function adjustStarsSlider(value) {
let bonusMinimumStars = $('#bonusMinimumStars');
bonusMinimumStars.attr("min", value);
......@@ -25,8 +27,7 @@ Template.cardsetIndexTranscriptSettings.onRendered(function () {
$('#bonusMinimumSubmissions').val(this.data.transcriptBonus.minimumSubmissions);
$('#minSubmissionsValue').html(this.data.transcriptBonus.minimumSubmissions);
adjustStarsSlider(this.data.transcriptBonus.minimumSubmissions);
$('#bonusMinimumStars').val(this.data.transcriptBonus.minimumStars);
$('#minStarsValue').html(this.data.transcriptBonus.minimumStars);
Session.set('minimumBonusStars', this.data.transcriptBonus.minimumStars);
for (let d = 0; d < this.data.transcriptBonus.dates.length; d++) {
dates.push(moment(this.data.transcriptBonus.dates[d]).format("MM/DD/YYYY"));
}
......@@ -56,12 +57,36 @@ Template.cardsetIndexTranscriptSettings.onRendered(function () {
$('#transcript-calendar').multiDatesPicker(settings);
});
Template.cardsetIndexTranscriptSettings.onDestroyed(function () {
Session.set('minimumBonusStars', this.data.transcriptBonus.minimumStars);
});
Template.cardsetIndexTranscriptSettings.helpers({
getBonusTranscriptStars: function () {
let stars = Session.get('minimumBonusStars');
let starData = [];
console.log("trigger");
for (let i = 0; i < 5; i++) {
let star = {};
if (i < stars) {
star.status = "rated";
} else {
star.status = "";
}
starData.push(star);
}
return starData;
},
getBonusTranscriptStarsTooltip: function (stars) {
return TAPi18n.__('cardset.transcriptBonusRating.starsLabel.stars' + (stars + 1));
},
});
Template.cardsetIndexTranscriptSettings.events({
'input #bonusMinimumSubmissions': function (event) {
$('#minSubmissionsValue').html(event.currentTarget.value);
adjustStarsSlider(event.currentTarget.value);
},
'input #bonusMinimumStars': function (event) {
$('#minStarsValue').html(event.currentTarget.value);
'click .stars-setting': function (event) {
Session.set('minimumBonusStars', $(event.currentTarget).data('id') + 1);
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment