|
|
@ -954,7 +954,7 @@ define([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var TYPES = { // XXX insert useful charts for each of type of answer
|
|
|
|
var TYPES = { // XXX hackathon insert useful charts for each of type of answer
|
|
|
|
input: {
|
|
|
|
input: {
|
|
|
|
defaultOpts: {
|
|
|
|
defaultOpts: {
|
|
|
|
type: 'text'
|
|
|
|
type: 'text'
|
|
|
@ -988,9 +988,11 @@ define([
|
|
|
|
reset: function () { $tag.val(''); }
|
|
|
|
reset: function () { $tag.val(''); }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid) { // XXX each question format has a 'printResults' method
|
|
|
|
printResults: function (answers, uid) { // XXX hackathon each question format has a 'printResults' method
|
|
|
|
var results = [];
|
|
|
|
var results = [];
|
|
|
|
var empty = 0;
|
|
|
|
var empty = 0;
|
|
|
|
|
|
|
|
// XXX hackathon charts for text inputs are only useful if we tally duplicated answers
|
|
|
|
|
|
|
|
// XXX hackathon use horizontal bar charts https://chartscss.org/charts/bar/
|
|
|
|
Object.keys(answers).forEach(function (author) { // TODO deduplicate these?
|
|
|
|
Object.keys(answers).forEach(function (author) { // TODO deduplicate these?
|
|
|
|
var obj = answers[author];
|
|
|
|
var obj = answers[author];
|
|
|
|
var answer = obj.msg[uid];
|
|
|
|
var answer = obj.msg[uid];
|
|
|
@ -1057,6 +1059,9 @@ define([
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
var results = [];
|
|
|
|
var results = [];
|
|
|
|
var empty = 0;
|
|
|
|
var empty = 0;
|
|
|
|
|
|
|
|
// XXX hackathon like text inputs, charts are only useful if we tally duplicates
|
|
|
|
|
|
|
|
// (or if there are duplicates)
|
|
|
|
|
|
|
|
// https://chartscss.org/charts/bar/
|
|
|
|
Object.keys(answers).forEach(function (author) { // TODO deduplicate these
|
|
|
|
Object.keys(answers).forEach(function (author) { // TODO deduplicate these
|
|
|
|
var obj = answers[author];
|
|
|
|
var obj = answers[author];
|
|
|
|
var answer = obj.msg[uid];
|
|
|
|
var answer = obj.msg[uid];
|
|
|
@ -1124,6 +1129,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
|
|
|
|
// XXX hackathon radio https://chartscss.org/charts/bar/
|
|
|
|
var results = [];
|
|
|
|
var results = [];
|
|
|
|
var empty = 0;
|
|
|
|
var empty = 0;
|
|
|
|
var count = {};
|
|
|
|
var count = {};
|
|
|
@ -1218,6 +1224,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid, form) {
|
|
|
|
printResults: function (answers, uid, form) {
|
|
|
|
|
|
|
|
// XXX hackathon multiradio https://chartscss.org/components/stacked/
|
|
|
|
var structure = form[uid];
|
|
|
|
var structure = form[uid];
|
|
|
|
if (!structure) { return; }
|
|
|
|
if (!structure) { return; }
|
|
|
|
var opts = structure.opts || TYPES.multiradio.defaultOpts;
|
|
|
|
var opts = structure.opts || TYPES.multiradio.defaultOpts;
|
|
|
@ -1335,6 +1342,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
|
|
|
|
// XXX hackathon multiradio https://chartscss.org/components/stacked/
|
|
|
|
var results = [];
|
|
|
|
var results = [];
|
|
|
|
var empty = 0;
|
|
|
|
var empty = 0;
|
|
|
|
var count = {};
|
|
|
|
var count = {};
|
|
|
@ -1443,6 +1451,9 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid, form) {
|
|
|
|
printResults: function (answers, uid, form) {
|
|
|
|
|
|
|
|
// XXX hackathon
|
|
|
|
|
|
|
|
// stacked: https://chartscss.org/components/stacked/
|
|
|
|
|
|
|
|
// or multiple bars: https://chartscss.org/charts/bar/#multiple-datasets
|
|
|
|
var structure = form[uid];
|
|
|
|
var structure = form[uid];
|
|
|
|
if (!structure) { return; }
|
|
|
|
if (!structure) { return; }
|
|
|
|
var opts = structure.opts || TYPES.multicheck.defaultOpts;
|
|
|
|
var opts = structure.opts || TYPES.multicheck.defaultOpts;
|
|
|
@ -1585,6 +1596,8 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid, form) {
|
|
|
|
printResults: function (answers, uid, form) {
|
|
|
|
|
|
|
|
// XXX hackathon sortable list
|
|
|
|
|
|
|
|
// bars again? https://chartscss.org/charts/bar/
|
|
|
|
var opts = form[uid].opts || TYPES.sort.defaultOpts;
|
|
|
|
var opts = form[uid].opts || TYPES.sort.defaultOpts;
|
|
|
|
var l = (opts.values || []).length;
|
|
|
|
var l = (opts.values || []).length;
|
|
|
|
var results = [];
|
|
|
|
var results = [];
|
|
|
@ -1710,6 +1723,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid, form, content) {
|
|
|
|
printResults: function (answers, uid, form, content) {
|
|
|
|
|
|
|
|
// XXX hackathon: not really anything to do here?
|
|
|
|
var opts = form[uid].opts || TYPES.poll.defaultOpts;
|
|
|
|
var opts = form[uid].opts || TYPES.poll.defaultOpts;
|
|
|
|
var _answers = getBlockAnswers(answers, uid);
|
|
|
|
var _answers = getBlockAnswers(answers, uid);
|
|
|
|
|
|
|
|
|
|
|
@ -1755,7 +1769,7 @@ define([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var renderResults = APP.renderResults = function (content, answers, showUser) { // XXX
|
|
|
|
var renderResults = APP.renderResults = function (content, answers, showUser) { // XXX hackathon
|
|
|
|
var $container = $('div.cp-form-creator-results').empty();
|
|
|
|
var $container = $('div.cp-form-creator-results').empty();
|
|
|
|
|
|
|
|
|
|
|
|
if (!Object.keys(answers || {}).length) {
|
|
|
|
if (!Object.keys(answers || {}).length) {
|
|
|
@ -1769,6 +1783,10 @@ define([
|
|
|
|
DiffMd.apply(DiffMd.render(content.answers.msg), $desc, APP.common);
|
|
|
|
DiffMd.apply(DiffMd.render(content.answers.msg), $desc, APP.common);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// XXX hackathon display answer times as column bar chart with first and last date indicated
|
|
|
|
|
|
|
|
// https://chartscss.org/charts/column/
|
|
|
|
|
|
|
|
// XXX hackathon set column colours with the cryptpad brand color in app-form.less
|
|
|
|
|
|
|
|
|
|
|
|
var controls = h('div.cp-form-creator-results-controls');
|
|
|
|
var controls = h('div.cp-form-creator-results-controls');
|
|
|
|
var $controls = $(controls).appendTo($container);
|
|
|
|
var $controls = $(controls).appendTo($container);
|
|
|
|
var exportButton = h('button.btn.btn-secondary', Messages.form_exportCSV);
|
|
|
|
var exportButton = h('button.btn.btn-secondary', Messages.form_exportCSV);
|
|
|
|