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

Task #15988: Overhaul of question title and QuestionToolbar title.

parent 2d76114a
......@@ -117,16 +117,11 @@ Ext.define('ARSnova.view.FreetextQuestion', {
style: "margin-top: 5px;"
});
// Setup question title and text to disply in the same field; markdown handles HTML encoding
var questionString = this.questionObj.subject.replace(/\./, "\\.")
+ '\n\n' // inserts one blank line between subject and text
+ this.questionObj.text;
// Create standard panel with framework support
var questionPanel = Ext.create('ARSnova.view.MathJaxMarkDownPanel', {
cls: "roundedBox allCapsHeader"
this.questionPanel = Ext.create('ARSnova.view.MathJaxMarkDownPanel', {
cls: "roundedBox questionPanel"
});
questionPanel.setContent(questionString, true, true);
this.updateQuestionText();
this.buttonContainer = Ext.create('Ext.Container', {
layout: {
......@@ -197,7 +192,7 @@ Ext.define('ARSnova.view.FreetextQuestion', {
xtype: 'formpanel',
scrollable: null,
submitOnAction: false,
items: [questionPanel, this.viewOnly ? {} : {
items: [this.questionPanel, this.viewOnly ? {} : {
xtype: 'fieldset',
items: [
this.markdownEditPanel,
......@@ -275,20 +270,24 @@ Ext.define('ARSnova.view.FreetextQuestion', {
}
},
getQuestionTypeMessage: function (msgAppendix) {
msgAppendix = msgAppendix ? msgAppendix : "";
var message;
switch (this.questionObj.questionType) {
case "freetext":
message = this.questionObj.questionType.toUpperCase();
break;
default:
message = Messages.QUESTION;
msgAppendix = "";
updateQuestionText: function () {
var questionString = '\n' + this.questionObj.text + '\n';
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if (screenWidth < 520 && this.viewOnly) {
this.questionPanel.addCls('allCapsHeader');
questionString = this.questionObj.subject.replace(/\./, "\\.")
+ '\n\n' // inserts one blank line between subject and text
+ this.questionObj.text;
} else {
this.questionPanel.removeCls('allCapsHeader');
}
return Messages[message + msgAppendix];
this.questionPanel.setContent(questionString, true, true);
},
getQuestionTypeMessage: function () {
return this.questionObj.subject;
},
setAnswerCount: function () {
......
......@@ -234,16 +234,11 @@ Ext.define('ARSnova.view.Question', {
}
};
// Setup question title and text to display in the same field; markdown handles HTML encoding
var questionString = this.questionObj.subject.replace(/\./, "\\.")
+ '\n\n' // inserts one blank line between subject and text
+ this.questionObj.text;
// Create standard panel with framework support
var questionPanel = Ext.create('ARSnova.view.MathJaxMarkDownPanel', {
cls: "roundedBox allCapsHeader"
this.questionPanel = Ext.create('ARSnova.view.MathJaxMarkDownPanel', {
cls: "roundedBox questionPanel"
});
questionPanel.setContent(questionString, true, true);
this.updateQuestionText();
if (this.questionObj.questionType === 'flashcard') {
var answerPanel = Ext.create('ARSnova.view.MathJaxMarkDownPanel', {
......@@ -419,7 +414,7 @@ Ext.define('ARSnova.view.Question', {
scope: this
};
this.formPanel.add([questionPanel]);
this.formPanel.add([this.questionPanel]);
if (this.questionObj.image && this.questionObj.questionType !== "grid") {
this.grid = Ext.create('ARSnova.view.components.GridImageContainer', {
......@@ -571,6 +566,22 @@ Ext.define('ARSnova.view.Question', {
this.editButtons.updateData(this.questionObj);
},
updateQuestionText: function () {
var questionString = '\n' + this.questionObj.text + '\n';
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if (screenWidth < 520 && this.viewOnly) {
this.questionPanel.addCls('allCapsHeader');
questionString = this.questionObj.subject.replace(/\./, "\\.")
+ '\n\n' // inserts one blank line between subject and text
+ this.questionObj.text;
} else {
this.questionPanel.removeCls('allCapsHeader');
}
this.questionPanel.setContent(questionString, true, true);
},
statisticButtonHandler: function (scope) {
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
this.questionObj = this.editButtons.questionObj;
......@@ -579,27 +590,8 @@ Ext.define('ARSnova.view.Question', {
ARSnova.app.getController('Statistics').prepareStatistics(scope);
},
getQuestionTypeMessage: function (msgAppendix) {
var message;
msgAppendix = msgAppendix ? msgAppendix : "";
switch (this.questionObj.questionType) {
case "vote":
message = "EVALUATION";
break;
case "flashcard":
msgAppendix = msgAppendix.length ? "" : "_SHORT";
/* fall through */
default:
message = this.questionObj.questionType.toUpperCase();
}
if (!Messages[message + msgAppendix]) {
message = "QUESTION";
msgAppendix = "";
}
return Messages[message + msgAppendix];
getQuestionTypeMessage: function () {
return this.questionObj.subject;
},
setAnswerCount: function () {
......
......@@ -17,7 +17,7 @@
* along with ARSnova Mobile. If not, see <http://www.gnu.org/licenses/>.
*/
Ext.define('ARSnova.view.components.QuestionToolbar', {
extend: 'Ext.Toolbar',
extend: 'Ext.TitleBar',
config: {
title: Messages.QUESTION,
......@@ -34,6 +34,7 @@ Ext.define('ARSnova.view.components.QuestionToolbar', {
this.backButton = Ext.create('Ext.Button', {
ui: 'back',
align: 'left',
text: Messages.BACK,
scope: this,
handler: function () {
......@@ -48,59 +49,24 @@ Ext.define('ARSnova.view.components.QuestionToolbar', {
});
this.answerCounter = Ext.create('Ext.Component', {
cls: "x-toolbar-title alignRight counterText"
cls: "x-toolbar-title alignRight counterText",
align: 'right'
});
this.statisticsButton = Ext.create('Ext.Button', {
iconCls: 'icon-chart',
style: 'padding: 0 0.4em',
handler: this.getStatisticsButtonHandler()
handler: this.getStatisticsButtonHandler(),
align: 'right'
});
this.add([
this.backButton,
{xtype: 'spacer'},
this.answerCounter,
this.statisticsButton
]);
},
setQuestionTitle: function (question) {
var questionType = question ? question.questionType : "";
if (questionType === 'abcd') {
this.setTitleOptions(Messages.QUESTION_SINGLE_CHOICE, Messages.QUESTION_SINGLE_CHOICE_SHORT);
} else if (questionType === 'freetext') {
this.setTitleOptions(Messages.QUESTION_FREETEXT, Messages.QUESTION_FREETEXT_SHORT);
} else if (questionType === 'mc') {
this.setTitleOptions(Messages.QUESTION_MC, Messages.QUESTION_MC_SHORT);
} else if (questionType === 'vote') {
this.setTitleOptions(Messages.QUESTION_RATING, Messages.QUESTION_RATING_SHORT);
} else if (questionType === 'yesno') {
this.setTitleOptions(Messages.QUESTION_YESNO, Messages.QUESTION_YESNO);
} else if (questionType === 'school') {
this.setTitleOptions(Messages.QUESTION_GRADE, Messages.QUESTION_GRADE_SHORT);
} else if (questionType === 'flashcard') {
this.setTitleOptions(Messages.FLASHCARD, Messages.FLASHCARD);
} else if (questionType === 'grid') {
this.setTitleOptions(Messages.QUESTION_GRID, Messages.QUESTION_GRID_SHORT);
}
},
setTitleOptions: function (longVersion, shortVersion) {
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if (screenWidth < 520 && this.getShowcase()) {
this.setTitle('');
} else {
if (screenWidth > 320 || this.backButton.isHidden()) {
this.setTitle(longVersion);
} else {
this.setTitle(shortVersion);
}
}
},
setAnswerCounter: function (value, option) {
if (!option) {
option = value === 1 ? Messages.ANSWER : Messages.ANSWERS;
......
......@@ -42,7 +42,6 @@ Ext.define('ARSnova.view.speaker.ShowcaseQuestionPanel', {
this.callParent(arguments);
this.on('activeitemchange', function (panel, newCard, oldCard) {
this.toolbar.setTitleOptions(this.getQuestionTitleLong(), this.getQuestionTitleShort());
if (newCard.questionObj.questionType !== 'flashcard') {
this.toolbar.statisticsButton.show();
} else {
......@@ -101,13 +100,16 @@ Ext.define('ARSnova.view.speaker.ShowcaseQuestionPanel', {
},
onItemChange: function (panel, newQuestion, oldQuestion) {
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if (newQuestion.questionObj) {
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width,
messageAppendix = screenWidth >= 500 ? "_LONG" : "",
message = screenWidth > 420 ?
newQuestion.getQuestionTypeMessage(messageAppendix) : "";
if (screenWidth >= 520) {
this.toolbar.setTitle(newQuestion.getQuestionTypeMessage());
} else {
this.toolbar.setTitle('');
}
this.toolbar.setTitle(message);
newQuestion.updateQuestionText();
}
},
......
......@@ -49,7 +49,6 @@ Ext.define('ARSnova.view.user.QuestionPanel', {
this.setLectureMode();
this.on('activeitemchange', function (panel, newCard, oldCard) {
this.toolbar.setTitleOptions(this.getQuestionTitle(), this.getQuestionTitleShort());
this.toolbar.checkStatistics(newCard.questionObj, newCard.isDisabled());
newCard.fireEvent('preparestatisticsbutton', this.toolbar.statisticsButton);
......@@ -85,11 +84,8 @@ Ext.define('ARSnova.view.user.QuestionPanel', {
onItemChange: function (panel, newQuestion, oldQuestion) {
if (newQuestion.questionObj) {
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width,
messageAppendix = screenWidth >= 500 ? "_LONG" : "",
message = newQuestion.getQuestionTypeMessage(messageAppendix);
this.toolbar.setTitle(message);
this.toolbar.setTitle(newQuestion.getQuestionTypeMessage());
newQuestion.updateQuestionText();
}
},
......
......@@ -792,6 +792,11 @@ html,body {
background-color: white;
}
.roundedBox.questionPanel {
padding-top: 20px;
padding-bottom: 20px;
}
.fontNormal {
font-weight: normal;
}
......
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