diff --git a/src/main/webapp/app/internationalization.js b/src/main/webapp/app/internationalization.js index 8a5da757d6e1418cb9874ec3225e73352a4368dd..6cfa8e63b4e610849e6c97d830807a7afa0b2e6e 100755 --- a/src/main/webapp/app/internationalization.js +++ b/src/main/webapp/app/internationalization.js @@ -806,6 +806,9 @@ QUESTIONS_EXPORT_BUTTON: "Fragen<br>exportieren", QUESTIONS_EXPORT_MSBOX_TITLE: "Inhalte exportieren", QUESTIONS_EXPORT_MSBOX_INFO: "Die Inhalte können wahlweise als CSV-Datei oder für den Import in ARSnova-Cards als JSON-Datei exportiert werden. Fragen vom Typ \"Hot Spots\" werden übersprungen. Für den gesamten Export der Session steht der Export auf der Sessionübersichtseite zur Verfügung.", + QUESTIONS_CSV_EXPORT_ANSWERS_BUTTON: "Antworten<br>exportieren", + QUESTIONS_CSV_EXPORT_ANSWERS_TIME: "Uhrzeit", + QUESTIONS_CSV_EXPORT_ANSWERS_SUBJECT: "Antwort-Thema", ARSNOVA_CARDS: "ARSnova.cards", CSV_FILE: "CSV-Datei", @@ -1668,6 +1671,9 @@ QUESTIONS_EXPORT_BUTTON: "Export<br>content", QUESTIONS_EXPORT_MSBOX_TITLE: "Export content", QUESTIONS_EXPORT_MSBOX_INFO: "The content can be exported as a CSV file or preformatted for ARSnova.cards as a JSON file. \"Hot Spots\" questions won't be exported. For exporting the whole session please use the export function on the session overview.", + QUESTIONS_CSV_EXPORT_ANSWERS_BUTTON: "Export<br>answers", + QUESTIONS_CSV_EXPORT_ANSWERS_TIME: "Time", + QUESTIONS_CSV_EXPORT_ANSWERS_SUBJECT: "Answer-Subject", ARSNOVA_CARDS: "ARSnova.cards", CSV_FILE: "CSV file", diff --git a/src/main/webapp/app/view/FreetextAnswerPanel.js b/src/main/webapp/app/view/FreetextAnswerPanel.js index a495e23eed4c03660aaa77bfcec7da7b64c60b93..03559c3ad7047d0f5efa12355b334dd3fe01bc8c 100644 --- a/src/main/webapp/app/view/FreetextAnswerPanel.js +++ b/src/main/webapp/app/view/FreetextAnswerPanel.js @@ -124,7 +124,35 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', { docked: 'top', ui: 'light', title: Ext.util.Format.htmlEncode(this.questionObj.subject), - items: [this.backButton] + items: [this.backButton + ,{ + xtype: 'button', + text: Messages.QUESTIONS_CSV_EXPORT_ANSWERS_BUTTON, + align: 'right', + handler: function(){ + //Format + var exp="data:text/csv;charset=utf-8,"; + //Subject and Question + exp+=Messages.QUESTION_SUBJECT+": "+self.questionObj.subject+";"+Messages.QUESTION+": "+self.questionObj.text; + //Table header + exp+="\n"+Messages.QUESTION_DATE+";"+Messages.QUESTIONS_CSV_EXPORT_ANSWERS_TIME+";"+Messages.QUESTIONS_CSV_EXPORT_ANSWERS_SUBJECT+";"+Messages.FREETEXT_DETAIL_ANSWER+";Timestamp"; + + //Table contents (answers) + self.freetextAnswerStore._data.all.forEach(function(item){ + exp+="\n"+item._data.groupDate+";"+item._data.formattedTime+";"+item._data.answerSubject+";"+item._data.answerText+";"+item._data.timestamp; + }); + + //Download file + //stackoverflow.com/questions/14964035/ + var encodedUri = encodeURI(exp); + var link = document.createElement("a"); + link.setAttribute("href", encodedUri); + link.setAttribute("download", self.questionObj.subject+"_"+self.questionObj.text+"-Answers.csv"); + document.body.appendChild(link); // Required for FF + link.click(); + }, + hidden: (ARSnova.app.userRole === ARSnova.app.USER_ROLE_STUDENT) + }] }); // Create standard panel with framework support @@ -400,4 +428,4 @@ Ext.define('ARSnova.view.FreetextAnswerPanel', { } }, -1, -1); } -}); +}); \ No newline at end of file diff --git a/src/main/webapp/app/view/speaker/QuestionStatisticChart.js b/src/main/webapp/app/view/speaker/QuestionStatisticChart.js index ec4757415b3c272adc20aaed6fd8581ad379811d..729c04134e8f5e08b012dcaa3fe30a6da04226d3 100755 --- a/src/main/webapp/app/view/speaker/QuestionStatisticChart.js +++ b/src/main/webapp/app/view/speaker/QuestionStatisticChart.js @@ -154,9 +154,8 @@ Ext.define('ARSnova.view.speaker.QuestionStatisticChart', { docked: 'top', ui: 'light', title: Ext.util.Format.htmlEncode(this.questionObj.subject), - items: [ - this.backButton, - this.answerCounter, { + items: [this.backButton, + this.answerCounter, { xtype: 'button', align: 'right', iconCls: 'icon-check', @@ -165,7 +164,36 @@ Ext.define('ARSnova.view.speaker.QuestionStatisticChart', { handler: this.toggleCorrectHandler, hidden: !hasCorrectAnswers() || this.questionObj.questionType === 'grid' || (ARSnova.app.userRole === ARSnova.app.USER_ROLE_STUDENT && !this.questionObj.showAnswer) - }] + },{ + xtype: 'button', + text: Messages.QUESTIONS_CSV_EXPORT_ANSWERS_BUTTON, + align: 'right', + handler: function(){ + //Format + var exp="data:text/csv;charset=utf-8,"; + //Subeject and Question + exp+=Messages.QUESTION_SUBJECT+": "+me.questionObj.subject+";"+Messages.QUESTION+": "+me.questionObj.text; + //Table header + exp+="\n"+Messages.ANSWERS+";" + +Messages.FIRST_ROUND+" "+Messages.GRID_LABEL_RELATIVE+";"+Messages.FIRST_ROUND+" "+Messages.GRID_LABEL_ABSOLUTE+";" + +Messages.SECOND_ROUND+" "+Messages.GRID_LABEL_RELATIVE+";"+Messages.SECOND_ROUND+" "+Messages.GRID_LABEL_ABSOLUTE; + //Table contents (answers) + me.questionStore.each(function (record) { + exp+="\n"+record.get('text')+";"+record.get('percent-round1')+";"+record.get('value-round1')+";"+record.get('percent-round2')+";"+record.get('value-round2'); + }); + + //Download file + //stackoverflow.com/questions/14964035/ + var encodedUri = encodeURI(exp); + var link = document.createElement("a"); + link.setAttribute("href", encodedUri); + link.setAttribute("download", me.questionObj.subject+"_"+me.questionObj.text+"-Answers.csv"); + document.body.appendChild(link); // Required for FF + link.click(); + }, + hidden: (ARSnova.app.userRole === ARSnova.app.USER_ROLE_STUDENT||me.questionObj.questionType==='grid') + } + ] }); this.piToolbar = Ext.create('Ext.Toolbar', { @@ -981,4 +1009,4 @@ Ext.define('ARSnova.view.speaker.QuestionStatisticChart', { return lighterColors; } -}); +}); \ No newline at end of file