Commit 0ea10301 authored by Andreas Gärtner's avatar Andreas Gärtner
Browse files

Task #15866: Seperate answer count in AudienceQuestionPanel by pi round.

parent fdf657f3
......@@ -87,6 +87,10 @@ Ext.define("ARSnova.controller.Questions", {
question.getTotalAnswerCountByQuestion.apply(question, arguments);
},
getAllRoundAnswerCountByQuestion: function (questionId, callbacks) {
ARSnova.app.questionModel.getAllRoundAnswerCountByQuestion(questionId, callbacks);
},
listFeedbackQuestions: function (animation) {
ARSnova.app.mainTabPanel.tabPanel.animateActiveItem(ARSnova.app.mainTabPanel.tabPanel.feedbackQuestionsPanel, animation || 'slide');
},
......
......@@ -351,6 +351,10 @@ Ext.define('ARSnova.model.Question', {
return this.getProxy().getTotalAnswerCountByQuestion(questionId, callbacks);
},
getAllRoundAnswerCountByQuestion: function (questionId, callbacks) {
return this.getProxy().getAllRoundAnswerCountByQuestion(questionId, callbacks);
},
getAnsweredFreetextQuestions: function (sessionKeyword, questionId, callbacks) {
return this.getProxy().getAnsweredFreetextQuestions(sessionKeyword, questionId, callbacks);
},
......
......@@ -716,6 +716,14 @@ Ext.define('ARSnova.proxy.RestProxy', {
});
},
getAllRoundAnswerCountByQuestion: function (questionId, callbacks) {
this.arsjax.request({
url: "lecturerquestion/" + questionId + "/allroundanswercount",
success: callbacks.success,
failure: callbacks.failure
});
},
getTotalAnswerCountByQuestion: function (questionId, callbacks) {
this.arsjax.request({
url: "lecturerquestion/" + questionId + "/totalanswercount",
......
......@@ -85,7 +85,6 @@ Ext.define('ARSnova.view.LearningProgressPanel', {
var options = ARSnova.app.getController('Sessions').getLearningProgressOptions();
if (field.getValue() === options.questionVariant) {
field.check();
console.log(field.getValue(), options);
}
this.showProgress(options);
};
......
......@@ -88,14 +88,36 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
},
itemCls: 'forwardListButton',
itemTpl:
'<tpl if="!active"><div class="isInactive buttontext noOverflow">{text:htmlEncode}</div>' +
'<tpl else>' +
'<tpl if="votingDisabled"><div class="isVoteInactive buttontext noOverflow">{text:htmlEncode}</div>' +
'<tpl else><div class="buttontext noOverflow">{text:htmlEncode}</div></tpl>' +
'</tpl>' +
'<div class="x-button x-hasbadge audiencePanelListBadge">' +
'<tpl if="numAnswers &gt; 0"><span class="answersBadgeIcon badgefixed">{numAnswers}</span></tpl></div>',
itemTpl: Ext.create('Ext.XTemplate',
'<tpl if="!active"><div class="isInactive buttontext noOverflow">{text:htmlEncode}</div>',
'<tpl else>',
'<tpl if="votingDisabled"><div class="isVoteInactive buttontext noOverflow">{text:htmlEncode}</div>',
'<tpl else><div class="buttontext noOverflow">{text:htmlEncode}</div></tpl>',
'</tpl>',
'<div class="x-button x-hasbadge audiencePanelListBadge">',
'<tpl if="this.hasAnswers(values.numAnswers)"><span class="answersBadgeIcon badgefixed">',
'{[this.getFormattedCount(values)]}</span>',
'</tpl></div>',
{
hasAnswers: function (numAnswers) {
if (!!numAnswers) {
return numAnswers.reduce(function(ro, rt) {
return ro + rt;
}, 0) > 0;
}
return false;
},
getFormattedCount: function (questionObj) {
if (questionObj.piRound === 2) {
return questionObj.numAnswers[0] + ' | ' + questionObj.numAnswers[1];
} else {
return questionObj.numAnswers[0];
}
}
}
),
grouped: true,
store: this.questionStore,
......@@ -373,12 +395,14 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
getQuestionAnswers: function () {
var me = this;
var getAnswerCount = function (questionRecord, promise) {
me.getController().getTotalAnswerCountByQuestion(questionRecord.get('_id'), {
me.getController().getAllRoundAnswerCountByQuestion(questionRecord.get('_id'), {
success: function (response) {
var numAnswers = Ext.decode(response.responseText);
questionRecord.set('numAnswers', numAnswers);
promise.resolve({
hasAnswers: numAnswers > 0
hasAnswers: numAnswers.reduce(function(ro, rt) {
return ro + rt;
}, 0) > 0
});
},
failure: function () {
......
......@@ -98,7 +98,7 @@ code {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding-right: 40px;
padding-right: 55px;
}
.x-item-disabled input,
......
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