question_answer: DataTypes.STRING,
question_other_label: DataTypes.STRING,
question_other_answer: DataTypes.STRING,
- question_options: DataTypes.STRING
-
+ question_options: DataTypes.STRING,
+ index: DataTypes.INTEGER
}, {
tableName: 'report_jscripty_questions',
associate: function(models) {
foreignKey: 'questionId'
});
- // models.ReportJscriptyQuestion.addScope('questionSummary', function(projectId) {
- // return {
- // where: {
- // projectId: projectId
- // },
- // attributes: ['question_id', 'question_type', 'question_label', 'question_text', [sequelize.fn('count', sequelize.col('question_id')), 'count']],
- // group: ['question_id', 'question_type', 'question_label', 'question_text']
- // }
- //
- // });
+ models.ReportJscriptyQuestion.addScope('otherOption', function(projectId, questionId) {
+ return {
+ where: {
+ ProjectId: projectId,
+ question_id: questionId,
+ question_type: 'question',
+ question_other_answer: {
+ $ne: null
+ }
+ },
+ attributes: ['question_type', 'question_id', 'question_label', 'question_text', 'question_other_label', 'question_other_answer'],
+ }
+
+ });
models.ReportJscriptyQuestion.addScope('summary', function(projectId) {
return {
where: {