Commit 9ee724f6 authored by Andreas Gärtner's avatar Andreas Gärtner
Browse files

Task #15973: Add events and methods to (un)lock vote for all questions

Also concerned in Task #15826 and Task #15814
parent d3d9edf3
......@@ -35,7 +35,10 @@ Ext.define('ARSnova.WebSocket', {
setSessionActive: "arsnova/socket/session/active",
feedbackReset: "arsnova/socket/feedback/reset",
feedbackAverage: "arsnova/socket/feedback/average",
lockVoting: "arsnova/socket/lecturer/lockVoting",
lockVote: "arsnova/socket/lecturer/lockVote",
lockVotes: "arsnova/socket/lecturer/lockVotes",
unlockVote: "arsnova/socket/lecturer/unlockVote",
unlockVotes: "arsnova/socket/lecturer/unlockVotes",
endPiRound: "arsnova/question/lecturer/endPiRound",
resetPiRound: "arsnova/question/lecturer/resetPiRound",
cancelPiRound: "arsnova/question/lecturer/cancelPiRound",
......@@ -156,9 +159,24 @@ Ext.define('ARSnova.WebSocket', {
this.fireEvent(this.events.lecturerQuestionLocked, questions);
}, this));
this.socket.on('lockVoting', Ext.bind(function (object) {
console.debug("Socket.IO: lockVoting", object);
this.fireEvent(this.events.lockVoting, object);
this.socket.on('lockVote', Ext.bind(function (object) {
console.debug("Socket.IO: lockVote", object);
this.fireEvent(this.events.lockVote, object);
}, this));
this.socket.on('lockVotes', Ext.bind(function (object) {
console.debug("Socket.IO: lockVotes", object);
this.fireEvent(this.events.lockVotes, object);
}, this));
this.socket.on('unlockVote', Ext.bind(function (object) {
console.debug("Socket.IO: unlockVote", object);
this.fireEvent(this.events.unlockVote, object);
}, this));
this.socket.on('unlockVotes', Ext.bind(function (object) {
console.debug("Socket.IO: unlockVotes", object);
this.fireEvent(this.events.unlockVotes, object);
}, this));
this.socket.on('audQuestionAvail', Ext.bind(function (questionId) {
......
......@@ -362,14 +362,20 @@ Ext.define("ARSnova.controller.Questions", {
});
},
handleVotingLock: function (questionId, disable) {
handleVotingLock: function (lockedQuestions, disable) {
var tabPanel = ARSnova.app.mainTabPanel.tabPanel;
if (tabPanel.getActiveItem() === tabPanel.userQuestionsPanel) {
var questions = tabPanel.userQuestionsPanel.getInnerItems();
var questionIds = new Array(lockedQuestions.length);
lockedQuestions.forEach(function (q) {
questionIds.push(q._id);
});
questions.forEach(function (question) {
if (question.getItemId() === questionId) {
if (questionIds.indexOf(question.getItemId()) !== -1 &&
question.questionObj.questionType !== 'flashcard') {
question.questionObj.votingDisabled = disable;
question.countdownTimer.hide();
......
......@@ -87,7 +87,10 @@ Ext.define('ARSnova.model.Question', {
},
events: {
lockVoting: "arsnova/question/lecturer/lockVoting",
lockVote: "arsnova/question/lecturer/lockVote",
lockVotes: "arsnova/socket/lecturer/lockVotes",
unlockVote: "arsnova/socket/lecturer/unlockVote",
unlockVotes: "arsnova/socket/lecturer/unlockVotes",
endPiRound: "arsnova/question/lecturer/endPiRound",
resetPiRound: "arsnova/question/lecturer/resetPiRound",
cancelPiRound: "arsnova/question/lecturer/cancelPiRound",
......@@ -182,11 +185,32 @@ Ext.define('ARSnova.model.Question', {
this.fireEvent(this.events.resetPiRound, object);
}, this);
ARSnova.app.socket.on(ARSnova.app.socket.events.lockVoting, function (object) {
ARSnova.app.socket.on(ARSnova.app.socket.events.lockVote, function (object) {
if (ARSnova.app.questionModel === this) {
ARSnova.app.getController('Questions').handleVotingLock(object._id, object.disable, object.variant);
ARSnova.app.getController('Questions').handleVotingLock([object], true);
}
this.fireEvent(this.events.lockVoting, object);
this.fireEvent(this.events.lockVote, object);
}, this);
ARSnova.app.socket.on(ARSnova.app.socket.events.lockVotes, function (object) {
if (ARSnova.app.questionModel === this) {
ARSnova.app.getController('Questions').handleVotingLock(object, true);
}
this.fireEvent(this.events.lockVotes, object);
}, this);
ARSnova.app.socket.on(ARSnova.app.socket.events.unlockVote, function (object) {
if (ARSnova.app.questionModel === this) {
ARSnova.app.getController('Questions').handleVotingLock([object], false);
}
this.fireEvent(this.events.unlockVote, object);
}, this);
ARSnova.app.socket.on(ARSnova.app.socket.events.unlockVotes, function (object) {
if (ARSnova.app.questionModel === this) {
ARSnova.app.getController('Questions').handleVotingLock(object, false);
}
this.fireEvent(this.events.unlockVotes, object);
}, this);
ARSnova.app.socket.on(ARSnova.app.socket.events.countQuestionAnswersByQuestionId, function (object) {
......@@ -279,6 +303,10 @@ Ext.define('ARSnova.model.Question', {
return this.getProxy().disableQuestionVoting(questionId, disable, callbacks);
},
disableAllQuestionVotings: function (sessionKeyword, disable, isLecture, isPreparation, callbacks) {
return this.getProxy().disableAllQuestionVotings(sessionKeyword, disable, isLecture, isPreparation, callbacks);
},
getLectureQuestions: function (sessionKeyword, callbacks) {
return this.getProxy().getLectureQuestions(sessionKeyword, callbacks);
},
......
......@@ -63,7 +63,7 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
this.callParent(arguments);
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
var upperActionButtonCls = screenWidth < 410 ? 'smallerActionButton' : 'actionButton';
var actionButtonCls = screenWidth < 410 ? 'smallerActionButton' : 'actionButton';
this.questionStore = Ext.create('Ext.data.JsonStore', {
model: 'ARSnova.model.Question',
......@@ -174,20 +174,20 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
this.questionStatusButton = Ext.create('ARSnova.view.speaker.MultiQuestionStatusButton', {
hidden: true,
cls: upperActionButtonCls,
cls: actionButtonCls,
questionStore: this.questionList.getStore()
});
this.voteStatusButton = Ext.create('ARSnova.view.speaker.MultiVoteStatusButton', {
hidden: true,
cls: upperActionButtonCls,
cls: actionButtonCls,
questionStore: this.questionList.getStore()
});
this.showcaseActionButton = Ext.create('ARSnova.view.MatrixButton', {
text: Messages.SHOWCASE_MODE,
buttonConfig: 'icon',
cls: upperActionButtonCls,
cls: actionButtonCls,
imageCls: 'icon-presenter thm-grey',
handler: this.showcaseHandler,
hidden: true
......@@ -196,7 +196,7 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
this.newQuestionButton = Ext.create('ARSnova.view.MatrixButton', {
text: Messages.NEW_QUESTION,
buttonConfig: 'icon',
cls: upperActionButtonCls,
cls: actionButtonCls,
imageCls: 'icon-question thm-green',
handler: this.newQuestionHandler
});
......@@ -247,7 +247,7 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
buttonConfig: 'icon',
text: Messages.DELETE_ANSWERS,
imageCls: 'icon-close thm-orange',
cls: 'actionButton',
cls: actionButtonCls,
scope: this,
handler: function () {
var me = this;
......@@ -267,7 +267,7 @@ Ext.define('ARSnova.view.speaker.AudienceQuestionPanel', {
buttonConfig: 'icon',
text: Messages.DELETE_ALL_QUESTIONS,
imageCls: 'icon-close thm-red',
cls: 'actionButton',
cls: actionButtonCls,
scope: this,
handler: function () {
var msg = Messages.ARE_YOU_SURE;
......
......@@ -25,7 +25,7 @@ Ext.define('ARSnova.view.speaker.MultiVoteStatusButton', {
isPreparationMode: false,
wording: {
release: Messages.RELEASE_VOTE,
releaseAll: Messages.RELEASE_ALL_VOTES,
releaseAll: Messages.RELEASE_VOTE,
confirm: Messages.CONFIRM_CLOSE_ALL_VOTES,
confirmMessage: Messages.CONFIRM_CLOSE_ALL_VOTES_MESSAGE
}
......@@ -73,6 +73,7 @@ Ext.define('ARSnova.view.speaker.MultiVoteStatusButton', {
changeStatus: function () {
var me = this;
me.button.disable();
if (!this.getQuestionStore()) {
return;
}
......@@ -102,14 +103,17 @@ Ext.define('ARSnova.view.speaker.MultiVoteStatusButton', {
success: function () {
me.isOpen = false;
updateQuestions(true);
me.button.enable();
},
failure: function () {
Ext.Msg.alert(Messages.NOTIFICATION, Messages.QUESTION_COULD_NOT_BE_SAVED);
me.button.enable();
}
}
);
} else {
me.button.setToggleFieldValue(true);
me.button.enable();
}
}, this);
} else {
......@@ -121,9 +125,11 @@ Ext.define('ARSnova.view.speaker.MultiVoteStatusButton', {
success: function () {
me.isOpen = true;
updateQuestions(false);
me.button.enable();
},
failure: function () {
Ext.Msg.alert(Messages.NOTIFICATION, Messages.QUESTION_COULD_NOT_BE_SAVED);
me.button.enable();
}
}
);
......
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