Commit 5f51fad3 authored by Andreas Gärtner's avatar Andreas Gärtner
Browse files

Task #15900: Feature: Add timer feature to non bar chart question types.

parent 139689a8
......@@ -299,27 +299,15 @@ Ext.define("ARSnova.controller.Questions", {
},
freetextDetailAnswer: function (options) {
var parentPanel;
var isFromFreetextAnswerPanel = false;
if (typeof options.panel !== 'undefined') {
isFromFreetextAnswerPanel = ARSnova.app.mainTabPanel.getActiveItem().constructor === options.panel.constructor;
}
// This gets called either by the speaker or by a student
if (ARSnova.app.isSessionOwner && !isFromFreetextAnswerPanel) {
parentPanel = ARSnova.app.mainTabPanel.tabPanel.speakerTabPanel;
} else {
parentPanel = ARSnova.app.mainTabPanel;
}
var mainTabPanel = ARSnova.app.mainTabPanel;
options.answer.deletable = ARSnova.app.isSessionOwner;
var freetextDetailAnswerPanel = Ext.create('ARSnova.view.FreetextDetailAnswer', {
sTP: parentPanel,
sTP: mainTabPanel,
answer: options.answer
});
parentPanel.animateActiveItem(freetextDetailAnswerPanel, {
mainTabPanel.animateActiveItem(freetextDetailAnswerPanel, {
type: 'slide',
direction: 'left',
duration: 700
......
......@@ -93,7 +93,8 @@ Ext.define("ARSnova.controller.RoundManagement", {
updateQuestionOnRoundCancel: function (question, questionObj) {
if (!questionObj) {
if (question.questionObj.piRound === 1) {
if (question.questionObj.piRound === 0 ||
question.questionObj.piRound === 1) {
question.questionObj.piRoundFinished = false;
} else {
question.questionObj.piRound = 1;
......@@ -120,6 +121,10 @@ Ext.define("ARSnova.controller.RoundManagement", {
question.questionObj.piRoundFinished = false;
question.questionObj.piRoundStartTime = 0;
question.questionObj.piRoundEndTime = 0;
if (question.questionObj.questionType === 'freetext') {
question.questionObj.piRound = 0;
}
} else {
question.questionObj = questionObj;
}
......
......@@ -30,18 +30,27 @@ Ext.define("ARSnova.controller.Statistics", {
},
prepareStudentStatistics: function (panel, scope) {
panel.questionStatisticChart = Ext.create('ARSnova.view.speaker.QuestionStatisticChart', {
question: scope.questionObj
});
if (scope.questionObj.questionType === 'freetext') {
panel.questionStatisticChart = Ext.create(
scope.questionObj.imageQuestion ?
'ARSnova.view.ImageAnswerPanel' :
'ARSnova.view.FreetextAnswerPanel', {
question: scope.questionObj
});
} else {
panel.questionStatisticChart = Ext.create(
'ARSnova.view.speaker.QuestionStatisticChart', {
question: scope.questionObj
});
}
ARSnova.app.mainTabPanel.animateActiveItem(panel.questionStatisticChart, 'slide');
},
prepareSpeakerStatistics: function (panel, enterRoundManagement) {
var target, targetIndex = 0;
var targetIndex = 0;
var activePanel = panel.getActiveItem();
var questionObj = panel.getActiveItem().questionObj;
var animation = {
type: 'slide',
direction: 'left',
......@@ -62,32 +71,36 @@ Ext.define("ARSnova.controller.Statistics", {
case panel.questionDetailsPanel:
questionObj = activePanel.questionObj;
break;
default:
}
var enableRoundManagement = questionObj.questionType !== 'grid';
target = panel.questionStatisticChart = Ext.create('ARSnova.view.speaker.QuestionStatisticChart', {
question: questionObj
});
if (enableRoundManagement) {
if (!panel.statisticTabPanel) {
panel.statisticTabPanel = Ext.create('ARSnova.view.speaker.StatisticTabPanel');
}
if (questionObj.questionType === 'freetext') {
panel.questionStatisticChart = Ext.create(
questionObj.imageQuestion ?
'ARSnova.view.ImageAnswerPanel' :
'ARSnova.view.FreetextAnswerPanel', {
question: questionObj
});
} else {
panel.questionStatisticChart = Ext.create(
'ARSnova.view.speaker.QuestionStatisticChart', {
question: questionObj
});
}
panel.statisticTabPanel.insert(0, panel.questionStatisticChart);
if (!panel.statisticTabPanel) {
panel.statisticTabPanel = Ext.create('ARSnova.view.speaker.StatisticTabPanel');
}
if (enterRoundManagement) {
targetIndex = 1;
panel.statisticTabPanel.setActiveItem(0);
panel.statisticTabPanel.roundManagementPanel.setShowcaseBackButtonHandler();
}
panel.statisticTabPanel.insert(0, panel.questionStatisticChart);
panel.statisticTabPanel.roundManagementPanel.statisticChart = panel.questionStatisticChart;
panel.statisticTabPanel.setActiveItem(targetIndex);
target = panel.statisticTabPanel;
if (enterRoundManagement) {
targetIndex = 1;
panel.statisticTabPanel.setActiveItem(0);
panel.statisticTabPanel.roundManagementPanel.setShowcaseBackButtonHandler();
}
ARSnova.app.mainTabPanel.animateActiveItem(target, animation);
panel.statisticTabPanel.setActiveItem(targetIndex);
ARSnova.app.mainTabPanel.animateActiveItem(panel.statisticTabPanel, animation);
}
});
......@@ -21,6 +21,8 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', {
extend: 'Ext.Panel',
config: {
title: Messages.STATISTIC,
iconCls: 'icon-chart',
fullscreen: true,
scrollable: {
direction: 'vertical',
......@@ -40,14 +42,21 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', {
this.callParent(arguments);
this.questionObj = args.question;
this.lastPanel = args.lastPanel;
var self = this;
this.checkFreetextAnswersTask = {
name: 'check for new freetext answers',
scope: this,
run: function () {
this.checkFreetextAnswers();
var mainTabPanel = ARSnova.app.mainTabPanel;
var tP = mainTabPanel.tabPanel;
var panel = tP.userQuestionsPanel || tP.speakerTabPanel;
panel.questionStatisticChart.checkFreetextAnswers();
if (mainTabPanel.getActiveItem() === panel.statisticTabPanel) {
panel.statisticTabPanel.roundManagementPanel.updateEditButtons();
}
},
interval: 15000
};
......@@ -64,16 +73,38 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', {
ui: 'back',
scope: this,
handler: function () {
ARSnova.app.mainTabPanel.animateActiveItem(ARSnova.app.mainTabPanel.tabPanel, {
var object, me = this;
var tabPanel = ARSnova.app.mainTabPanel.tabPanel;
var speakerTabPanel = tabPanel.speakerTabPanel;
ARSnova.app.innerScrollPanel = false;
ARSnova.app.taskManager.stop(me.checkFreetextAnswersTask);
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
object = speakerTabPanel.statisticTabPanel.roundManagementPanel.editButtons.questionObj;
switch (speakerTabPanel.getActiveItem()) {
case speakerTabPanel.showcaseQuestionPanel:
var activeItem = speakerTabPanel.showcaseQuestionPanel.getActiveItem();
activeItem.questionObj = object;
break;
case speakerTabPanel.questionDetailsPanel:
speakerTabPanel.questionDetailsPanel.questionObj = object;
break;
default:
}
}
ARSnova.app.mainTabPanel.animateActiveItem(tabPanel, {
type: 'slide',
direction: 'right',
duration: 700,
listeners: {
animationend: function () {
ARSnova.app.mainTabPanel._activeItem.on('deactivate', function () {
self.destroy();
}, self, {single: self});
}, scope: self
me.destroy();
}
}
});
}
......@@ -189,19 +220,34 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', {
badgeCls: 'badgeicon'
});
this.add([this.toolbar, {
xtype: 'formpanel',
style: 'margin-top: 15px',
cls: 'roundedCorners',
height: '100%',
width: '100%',
flex: 1,
scrollable: null,
items: [questionPanel, this.noAnswersLabel, this.freetextAnswerList]
}]);
this.countdownTimer = Ext.create('ARSnova.view.components.CountdownTimer', {
style: 'margin-top: 40px',
docked: 'top',
viewOnly: true,
viewOnlyOpacity: 1,
hidden: true
});
this.add([this.toolbar,
this.countdownTimer, {
xtype: 'formpanel',
style: 'margin-top: 15px',
cls: 'roundedCorners',
height: '100%',
width: '100%',
flex: 1,
scrollable: null,
items: [
questionPanel,
this.noAnswersLabel,
this.freetextAnswerList
]
}
]);
this.on('activate', function () {
ARSnova.app.taskManager.start(this.checkFreetextAnswersTask);
this.checkPiRoundActivation();
}, this);
this.on('deactivate', function () {
......@@ -212,6 +258,19 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', {
this.on('painted', function () {
ARSnova.app.innerScrollPanel = this;
});
this.on('hide', function () {
this.countdownTimer.hide();
});
},
checkPiRoundActivation: function () {
if (this.questionObj.piRoundActive) {
this.countdownTimer.start(this.questionObj.piRoundStartTime, this.questionObj.piRoundEndTime);
this.countdownTimer.show();
} else {
this.countdownTimer.hide();
}
},
checkFreetextAnswers: function () {
......
......@@ -35,7 +35,6 @@ Ext.define('ARSnova.view.FreetextDetailAnswer', {
this.answer = args.answer;
this.sTP = args.sTP;
var self = this;
this.toolbar = Ext.create('Ext.Toolbar', {
......
......@@ -50,7 +50,8 @@ Ext.define('ARSnova.view.FreetextQuestion', {
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
this.editButtons = Ext.create('ARSnova.view.speaker.ShowcaseEditButtons', {
questionObj: this.questionObj
questionObj: this.questionObj,
buttonClass: 'smallerActionButton'
});
}
......@@ -181,7 +182,16 @@ Ext.define('ARSnova.view.FreetextQuestion', {
}, this.buttonContainer]
});
this.countdownTimer = Ext.create('ARSnova.view.components.CountdownTimer', {
docked: 'top',
hidden: true,
viewOnly: true,
viewOnlyOpacity: ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER ?
0.9 : 0.75
});
this.add([
this.countdownTimer,
Ext.create('Ext.Panel', {
items: [{
xtype: 'formpanel',
......@@ -203,18 +213,38 @@ Ext.define('ARSnova.view.FreetextQuestion', {
}), this.editButtons ? this.editButtons : {}
]);
this.on('painted', function () {
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
this.updateEditButtons();
}
});
this.on('hide', function () {
this.countdownTimer.hide();
});
this.on('activate', function () {
if (this.isDisabled()) {
this.uploadView.hide();
this.checkPiRoundActivation();
if (this.isDisabled() || this.questionObj.votingDisabled) {
this.disableQuestion();
}
if (this.viewOnly) {
this.setAnswerCount();
}
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
this.editButtons.changeHiddenState();
}
});
},
updateEditButtons: function () {
this.editButtons.questionObj = this.questionObj;
this.editButtons.updateData(this.questionObj);
},
setImage: function (image) {
this.answerImage = image;
this.gridQuestion.setImage(image);
......@@ -236,7 +266,14 @@ Ext.define('ARSnova.view.FreetextQuestion', {
this.gridQuestion.setGridIsHidden(true);
},
checkPiRoundActivation: function () {},
checkPiRoundActivation: function () {
if (this.questionObj.piRoundActive) {
this.countdownTimer.start(this.questionObj.piRoundStartTime, this.questionObj.piRoundEndTime);
this.countdownTimer.show();
} else {
this.countdownTimer.hide();
}
},
getQuestionTypeMessage: function (msgAppendix) {
msgAppendix = msgAppendix ? msgAppendix : "";
......@@ -299,16 +336,11 @@ Ext.define('ARSnova.view.FreetextQuestion', {
},
statisticButtonHandler: function (scope) {
var p = Ext.create(
!this.questionObj.imageQuestion ?
'ARSnova.view.FreetextAnswerPanel'
:
'ARSnova.view.ImageAnswerPanel',
{
question: scope.questionObj,
lastPanel: scope
});
ARSnova.app.mainTabPanel.animateActiveItem(p, 'slide');
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
this.questionObj = this.editButtons.questionObj;
}
ARSnova.app.getController('Statistics').prepareStatistics(scope);
},
abstentionHandler: function (button, event) {
......@@ -406,13 +438,30 @@ Ext.define('ARSnova.view.FreetextQuestion', {
},
disableQuestion: function () {
this.setDisabled(true);
this.mask(this.customMask);
if (ARSnova.app.userRole !== ARSnova.app.USER_ROLE_SPEAKER) {
this.setDisabled(true);
this.mask(this.customMask);
if (this.questionObj.imageQuestion) {
this.uploadView.hide();
}
if (!!this.questionObj.userAnswered) {
this.customMask.setTextMessage(Messages.MASK_ALREADY_ANSWERED, 'alreadyAnswered');
} else if (!!this.questionObj.votingDisabled) {
this.customMask.setTextMessage(Messages.MASK_VOTE_CLOSED, 'voteClosed');
if (!!this.questionObj.userAnswered) {
this.customMask.setTextMessage(Messages.MASK_ALREADY_ANSWERED, 'alreadyAnswered');
} else if (!!this.questionObj.votingDisabled) {
this.customMask.setTextMessage(Messages.MASK_VOTE_CLOSED, 'voteClosed');
}
}
},
enableQuestion: function () {
if (!this.questionObj.userAnswered) {
this.setDisabled(false);
this.setMasked(false);
if (this.questionObj.imageQuestion) {
this.uploadView.show();
}
}
},
......
......@@ -23,6 +23,8 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
config: {
layout: 'vbox',
fullscreen: true,
title: Messages.STATISTIC,
iconCls: 'icon-chart',
/**
* task for speakers in a session
......@@ -39,13 +41,22 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
this.callParent(arguments);
this.questionObj = args.question;
this.lastPanel = args.lastPanel;
var self = this;
this.checkFreetextAnswersTask = {
name: 'check for new freetext answers',
scope: this,
run: this.checkFreetextAnswers,
run: function () {
var mainTabPanel = ARSnova.app.mainTabPanel;
var tP = mainTabPanel.tabPanel;
var panel = tP.userQuestionsPanel || tP.speakerTabPanel;
panel.questionStatisticChart.checkFreetextAnswers();
if (mainTabPanel.getActiveItem() === panel.statisticTabPanel) {
panel.statisticTabPanel.roundManagementPanel.updateEditButtons();
}
},
interval: 15000
};
......@@ -61,16 +72,38 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
ui: 'back',
scope: this,
handler: function () {
ARSnova.app.mainTabPanel.animateActiveItem(ARSnova.app.mainTabPanel.tabPanel, {
var object, me = this;
var tabPanel = ARSnova.app.mainTabPanel.tabPanel;
var speakerTabPanel = tabPanel.speakerTabPanel;
ARSnova.app.innerScrollPanel = false;
ARSnova.app.taskManager.stop(me.checkFreetextAnswersTask);
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
object = speakerTabPanel.statisticTabPanel.roundManagementPanel.editButtons.questionObj;
switch (speakerTabPanel.getActiveItem()) {
case speakerTabPanel.showcaseQuestionPanel:
var activeItem = speakerTabPanel.showcaseQuestionPanel.getActiveItem();
activeItem.questionObj = object;
break;
case speakerTabPanel.questionDetailsPanel:
speakerTabPanel.questionDetailsPanel.questionObj = object;
break;
default:
}
}
ARSnova.app.mainTabPanel.animateActiveItem(tabPanel, {
type: 'slide',
direction: 'right',
duration: 700,
listeners: {
animationend: function () {
ARSnova.app.mainTabPanel._activeItem.on('deactivate', function () {
self.destroy();
}, self, {single: self});
}, scope: self
me.destroy();
}
}
});
}
......@@ -83,7 +116,6 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
items: [this.backButton]
});
//sort buttons
this.miniaturBtn = Ext.create('ARSnova.view.MatrixButton', {
text: Messages.IMAGE_QUESTION_MINIATUR_VIEW,
......@@ -191,16 +223,30 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
badgeCls: 'badgeicon'
});
this.add([this.toolbar, {
xtype: 'formpanel',
style: 'margin-top: 15px',
cls: 'roundedCorners',
height: '100%',
width: '100%',
flex: 1,
scrollable: null,
items: [this.sortPanel, this.noAnswersLabel, this.imageAnswerList]
}]);
this.countdownTimer = Ext.create('ARSnova.view.components.CountdownTimer', {
style: 'margin-top: 40px',
docked: 'top',
viewOnly: true,
viewOnlyOpacity: 1,
hidden: true
});
this.add([this.toolbar,
this.countdownTimer, {
xtype: 'formpanel',
style: 'margin-top: 15px',
cls: 'roundedCorners',
height: '100%',
width: '100%',
flex: 1,
scrollable: null,
items: [
this.sortPanel,
this.noAnswersLabel,
this.imageAnswerList
]
}
]);
this.on('activate', function () {
// This disables mouse scrolling until there are answers available.
......@@ -209,8 +255,13 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
ARSnova.app.innerScrollPanel = this.imageAnswerList;
}
ARSnova.app.taskManager.start(this.checkFreetextAnswersTask);
this.checkPiRoundActivation();
}, this);
this.on('hide', function () {
this.countdownTimer.hide();
});
this.on('deactivate', function () {
ARSnova.app.innerScrollPanel = false;
ARSnova.app.taskManager.stop(this.checkFreetextAnswersTask);
......@@ -223,6 +274,15 @@ Ext.define('ARSnova.view.ImageAnswerPanel', {
}, this);
},
checkPiRoundActivation: function () {
if (this.questionObj.piRoundActive) {
this.countdownTimer.start(this.questionObj.piRoundStartTime, this.questionObj.piRoundEndTime);
this.countdownTimer.show();
} else {
this.countdownTimer.hide();
}
},
checkFreetextAnswers: function () {
var me = this;
......
......@@ -1101,19 +1101,7 @@ Ext.define('ARSnova.view.speaker.QuestionDetailsPanel', {
cls: 'forwardListButton',
text: Messages.ANSWERS,
handler: function () {
var p;
if (self.questionObj.imageQuestion){
p = Ext.create('ARSnova.view.ImageAnswerPanel', {
question: self.questionObj,
lastPanel: self
});
} else {
p = Ext.create('ARSnova.view.FreetextAnswerPanel', {