@ozguraltan/strapi-content-input 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/admin/{AnalyticsHubPage-ByOrVZCl.js → AnalyticsHubPage-CHlhvUIU.js} +2 -2
- package/dist/admin/{AnalyticsHubPage-O-7pF2E5.mjs → AnalyticsHubPage-Crz4vv46.mjs} +2 -2
- package/dist/admin/{ContentInputField-BoZHf0Ka.mjs → ContentInputField-BeKDx_bb.mjs} +64 -19
- package/dist/admin/{ContentInputField-DK97AIG0.js → ContentInputField-CNWVLuRt.js} +64 -19
- package/dist/admin/{SurveyWidgetEditor-D3KiAotu.js → SurveyWidgetEditor-BTipBBEU.js} +622 -152
- package/dist/admin/{SurveyWidgetEditor-Y5BR-NWE.mjs → SurveyWidgetEditor-GKRT3eHj.mjs} +622 -152
- package/dist/admin/{index-C5Uj5YV9.mjs → index-DSDcG4QW.mjs} +2 -2
- package/dist/admin/{index-CHtB_Fa5.js → index-DuJM60tO.js} +2 -2
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/widgets/SurveyWidgetEditor.d.ts +2 -0
- package/dist/server/index.js +132 -27
- package/dist/server/index.mjs +132 -27
- package/dist/server/src/index.d.ts +23 -0
- package/dist/server/src/services/ci-survey.d.ts +23 -0
- package/dist/server/src/services/index.d.ts +23 -0
- package/dist/server/src/utils/surveyEngine.d.ts +19 -0
- package/package.json +1 -1
|
@@ -153,7 +153,7 @@ const index = {
|
|
|
153
153
|
},
|
|
154
154
|
icon: PluginIcon,
|
|
155
155
|
components: {
|
|
156
|
-
Input: async () => import("./ContentInputField-
|
|
156
|
+
Input: async () => import("./ContentInputField-BeKDx_bb.mjs").then((mod) => ({
|
|
157
157
|
default: mod.ContentInputField
|
|
158
158
|
}))
|
|
159
159
|
},
|
|
@@ -188,7 +188,7 @@ const index = {
|
|
|
188
188
|
defaultMessage: "ContentInput Hub"
|
|
189
189
|
},
|
|
190
190
|
permissions: [],
|
|
191
|
-
Component: () => import("./AnalyticsHubPage-
|
|
191
|
+
Component: () => import("./AnalyticsHubPage-Crz4vv46.mjs").then((mod) => ({
|
|
192
192
|
default: mod.AnalyticsHubPage
|
|
193
193
|
})),
|
|
194
194
|
position: 7
|
|
@@ -156,7 +156,7 @@ const index = {
|
|
|
156
156
|
},
|
|
157
157
|
icon: PluginIcon,
|
|
158
158
|
components: {
|
|
159
|
-
Input: async () => Promise.resolve().then(() => require("./ContentInputField-
|
|
159
|
+
Input: async () => Promise.resolve().then(() => require("./ContentInputField-CNWVLuRt.js")).then((mod) => ({
|
|
160
160
|
default: mod.ContentInputField
|
|
161
161
|
}))
|
|
162
162
|
},
|
|
@@ -191,7 +191,7 @@ const index = {
|
|
|
191
191
|
defaultMessage: "ContentInput Hub"
|
|
192
192
|
},
|
|
193
193
|
permissions: [],
|
|
194
|
-
Component: () => Promise.resolve().then(() => require("./AnalyticsHubPage-
|
|
194
|
+
Component: () => Promise.resolve().then(() => require("./AnalyticsHubPage-CHlhvUIU.js")).then((mod) => ({
|
|
195
195
|
default: mod.AnalyticsHubPage
|
|
196
196
|
})),
|
|
197
197
|
position: 7
|
package/dist/admin/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-DuJM60tO.js");
|
|
4
4
|
require("react");
|
|
5
5
|
exports.default = index.index;
|
package/dist/admin/index.mjs
CHANGED
|
@@ -29,6 +29,8 @@ export interface CISurveyQuestionDef {
|
|
|
29
29
|
validation?: string;
|
|
30
30
|
allowOther?: boolean;
|
|
31
31
|
otherLabel?: Record<string, string> | string;
|
|
32
|
+
allowNoOpinion?: boolean;
|
|
33
|
+
noOpinionLabel?: Record<string, string> | string;
|
|
32
34
|
shuffleOptions?: boolean;
|
|
33
35
|
inline?: boolean;
|
|
34
36
|
minSelections?: number;
|
package/dist/server/index.js
CHANGED
|
@@ -4744,7 +4744,7 @@ function slugifyIdentifier$1(text) {
|
|
|
4744
4744
|
ü: "u",
|
|
4745
4745
|
Ü: "u"
|
|
4746
4746
|
};
|
|
4747
|
-
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
4747
|
+
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/_{2,}/g, "_").replace(/^[-_]+|[-_]+$/g, "");
|
|
4748
4748
|
}
|
|
4749
4749
|
function stripHtmlTags(html) {
|
|
4750
4750
|
return String(html || "").replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /gi, " ").replace(/&/gi, "&").replace(/"/gi, '"').replace(/'/gi, "'").replace(/\s+/g, " ").trim();
|
|
@@ -5568,6 +5568,20 @@ const ciFormService = ({ strapi }) => ({
|
|
|
5568
5568
|
}
|
|
5569
5569
|
});
|
|
5570
5570
|
const XLSX = XLSXNs__namespace?.utils ? XLSXNs__namespace : XLSXNs__namespace?.default || XLSXNs__namespace;
|
|
5571
|
+
const NO_OPINION_VALUE = "__na__";
|
|
5572
|
+
function resolveNoOpinionLabels(raw) {
|
|
5573
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
5574
|
+
return {
|
|
5575
|
+
tr: raw.tr || "Fikrim yok",
|
|
5576
|
+
en: raw.en || "No idea",
|
|
5577
|
+
...raw
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
5581
|
+
return { tr: raw.trim(), en: raw.trim() };
|
|
5582
|
+
}
|
|
5583
|
+
return { tr: "Fikrim yok", en: "No idea" };
|
|
5584
|
+
}
|
|
5571
5585
|
function evalSingleRule(rule, answers) {
|
|
5572
5586
|
const targetVal = answers ? answers[rule.questionKey] : void 0;
|
|
5573
5587
|
const op = rule.operator;
|
|
@@ -5657,9 +5671,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5657
5671
|
}
|
|
5658
5672
|
} else if (q.type === "multiple_choice" || q.type === "image_choice" && (q.maxSelections ?? 1) > 1) {
|
|
5659
5673
|
const arr = Array.isArray(val) ? val : [];
|
|
5674
|
+
const isExclusiveNoOpinion = q.allowNoOpinion && arr.includes(NO_OPINION_VALUE);
|
|
5660
5675
|
if (q.required && arr.length === 0) {
|
|
5661
5676
|
qErrors.push(lMsg(locale, `Lütfen en az bir seçenek işaretleyiniz.`, `Please select at least one option.`));
|
|
5662
|
-
} else if (arr.length > 0) {
|
|
5677
|
+
} else if (arr.length > 0 && !isExclusiveNoOpinion) {
|
|
5663
5678
|
if (q.minSelections && arr.length < q.minSelections) {
|
|
5664
5679
|
qErrors.push(
|
|
5665
5680
|
lMsg(
|
|
@@ -5679,7 +5694,7 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5679
5694
|
);
|
|
5680
5695
|
}
|
|
5681
5696
|
}
|
|
5682
|
-
if (q.allowOther && arr.includes("__other__") && !String(otherTexts?.[q.key] || "").trim()) {
|
|
5697
|
+
if (!isExclusiveNoOpinion && q.allowOther && arr.includes("__other__") && !String(otherTexts?.[q.key] || "").trim()) {
|
|
5683
5698
|
qErrors.push(
|
|
5684
5699
|
lMsg(locale, `Lütfen "Diğer" seçeneği için açıklama giriniz.`, `Please specify your "Other" choice.`)
|
|
5685
5700
|
);
|
|
@@ -5694,9 +5709,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5694
5709
|
);
|
|
5695
5710
|
}
|
|
5696
5711
|
} else if (q.type === "nps") {
|
|
5712
|
+
const isNoOp = Boolean(q.allowNoOpinion && val === NO_OPINION_VALUE);
|
|
5697
5713
|
if (q.required && empty) {
|
|
5698
5714
|
qErrors.push(lMsg(locale, `Lütfen 0 ile 10 arasında bir puan seçiniz.`, `Please choose a score from 0 to 10.`));
|
|
5699
|
-
} else if (!empty) {
|
|
5715
|
+
} else if (!empty && !isNoOp) {
|
|
5700
5716
|
const n = Number(val);
|
|
5701
5717
|
if (Number.isNaN(n) || n < 0 || n > 10) {
|
|
5702
5718
|
qErrors.push(lMsg(locale, `Puan 0 ile 10 arasında olmalıdır.`, `Score must be between 0 and 10.`));
|
|
@@ -5704,9 +5720,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5704
5720
|
}
|
|
5705
5721
|
} else if (q.type === "star_rating") {
|
|
5706
5722
|
const maxS = q.maxStars || 5;
|
|
5723
|
+
const isNoOp = Boolean(q.allowNoOpinion && val === NO_OPINION_VALUE);
|
|
5707
5724
|
if (q.required && empty) {
|
|
5708
5725
|
qErrors.push(lMsg(locale, `Lütfen derecelendirme yapınız.`, `Please provide a rating.`));
|
|
5709
|
-
} else if (!empty) {
|
|
5726
|
+
} else if (!empty && !isNoOp) {
|
|
5710
5727
|
const n = Number(val);
|
|
5711
5728
|
if (Number.isNaN(n) || n < 1 || n > maxS) {
|
|
5712
5729
|
qErrors.push(lMsg(locale, `Derece 1 ile ${maxS} arasında olmalıdır.`, `Rating must be between 1 and ${maxS}.`));
|
|
@@ -5715,9 +5732,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5715
5732
|
} else if (q.type === "likert_scale") {
|
|
5716
5733
|
const sMin = q.scaleMin ?? 1;
|
|
5717
5734
|
const sMax = q.scaleMax ?? 5;
|
|
5735
|
+
const isNoOp = Boolean(q.allowNoOpinion && val === NO_OPINION_VALUE);
|
|
5718
5736
|
if (q.required && empty) {
|
|
5719
5737
|
qErrors.push(lMsg(locale, `Lütfen ölçekten bir değer seçiniz.`, `Please select a value on the scale.`));
|
|
5720
|
-
} else if (!empty) {
|
|
5738
|
+
} else if (!empty && !isNoOp) {
|
|
5721
5739
|
const n = Number(val);
|
|
5722
5740
|
if (Number.isNaN(n) || n < sMin || n > sMax) {
|
|
5723
5741
|
qErrors.push(
|
|
@@ -5726,7 +5744,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5726
5744
|
}
|
|
5727
5745
|
}
|
|
5728
5746
|
} else if (q.type === "ranking") {
|
|
5729
|
-
|
|
5747
|
+
const isNoOp = Boolean(
|
|
5748
|
+
q.allowNoOpinion && (val === NO_OPINION_VALUE || Array.isArray(val) && val[0] === NO_OPINION_VALUE)
|
|
5749
|
+
);
|
|
5750
|
+
if (q.required && !isNoOp && (!Array.isArray(val) || val.length === 0)) {
|
|
5730
5751
|
qErrors.push(lMsg(locale, `Lütfen sıralamayı onaylayınız.`, `Please confirm the ranking.`));
|
|
5731
5752
|
}
|
|
5732
5753
|
} else if (q.type === "short_text" || q.type === "long_text") {
|
|
@@ -5871,6 +5892,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5871
5892
|
countsMap[o.id] = 0;
|
|
5872
5893
|
});
|
|
5873
5894
|
let otherCount = 0;
|
|
5895
|
+
let noOpinionCount = 0;
|
|
5874
5896
|
const otherSamples = [];
|
|
5875
5897
|
for (const r of responses) {
|
|
5876
5898
|
const v = r.answers?.[q.key];
|
|
@@ -5888,6 +5910,8 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5888
5910
|
submittedAt: r.submittedAt || r.createdAt || ""
|
|
5889
5911
|
});
|
|
5890
5912
|
}
|
|
5913
|
+
} else if (item === NO_OPINION_VALUE) {
|
|
5914
|
+
noOpinionCount += 1;
|
|
5891
5915
|
} else {
|
|
5892
5916
|
countsMap[item] = (countsMap[item] || 0) + 1;
|
|
5893
5917
|
}
|
|
@@ -5912,9 +5936,19 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5912
5936
|
percentage: answeredCount > 0 ? Math.round(otherCount / answeredCount * 1e3) / 10 : 0
|
|
5913
5937
|
});
|
|
5914
5938
|
}
|
|
5939
|
+
if (q.allowNoOpinion || noOpinionCount > 0) {
|
|
5940
|
+
optionsBreakdown.push({
|
|
5941
|
+
id: NO_OPINION_VALUE,
|
|
5942
|
+
labels: resolveNoOpinionLabels(q.noOpinionLabel),
|
|
5943
|
+
image: null,
|
|
5944
|
+
count: noOpinionCount,
|
|
5945
|
+
percentage: answeredCount > 0 ? Math.round(noOpinionCount / answeredCount * 1e3) / 10 : 0
|
|
5946
|
+
});
|
|
5947
|
+
}
|
|
5915
5948
|
return {
|
|
5916
5949
|
...baseInfo,
|
|
5917
5950
|
answeredCount,
|
|
5951
|
+
noOpinionCount,
|
|
5918
5952
|
optionsBreakdown,
|
|
5919
5953
|
otherSamples
|
|
5920
5954
|
};
|
|
@@ -5925,15 +5959,23 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5925
5959
|
const distMap = {};
|
|
5926
5960
|
for (let i = minVal; i <= maxVal; i += 1) distMap[i] = 0;
|
|
5927
5961
|
let sum = 0;
|
|
5962
|
+
let scoredCount = 0;
|
|
5963
|
+
let noOpinionCount = 0;
|
|
5928
5964
|
let qPromoters = 0;
|
|
5929
5965
|
let qPassives = 0;
|
|
5930
5966
|
let qDetractors = 0;
|
|
5931
5967
|
for (const r of responses) {
|
|
5932
5968
|
const rawV = r.answers?.[q.key];
|
|
5933
5969
|
if (isEmptyFieldValue(rawV)) continue;
|
|
5970
|
+
if (rawV === NO_OPINION_VALUE) {
|
|
5971
|
+
answeredCount += 1;
|
|
5972
|
+
noOpinionCount += 1;
|
|
5973
|
+
continue;
|
|
5974
|
+
}
|
|
5934
5975
|
const n = Number(rawV);
|
|
5935
5976
|
if (Number.isNaN(n)) continue;
|
|
5936
5977
|
answeredCount += 1;
|
|
5978
|
+
scoredCount += 1;
|
|
5937
5979
|
sum += n;
|
|
5938
5980
|
distMap[n] = (distMap[n] || 0) + 1;
|
|
5939
5981
|
if (q.type === "nps") {
|
|
@@ -5946,38 +5988,44 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5946
5988
|
value,
|
|
5947
5989
|
labels: q.scaleLabels ? q.scaleLabels[String(value)] : void 0,
|
|
5948
5990
|
count: distMap[value] || 0,
|
|
5949
|
-
percentage:
|
|
5991
|
+
percentage: scoredCount > 0 ? Math.round((distMap[value] || 0) / scoredCount * 1e3) / 10 : 0
|
|
5950
5992
|
}));
|
|
5951
5993
|
return {
|
|
5952
5994
|
...baseInfo,
|
|
5953
5995
|
answeredCount,
|
|
5996
|
+
scoredCount,
|
|
5997
|
+
allowNoOpinion: Boolean(q.allowNoOpinion),
|
|
5998
|
+
noOpinionCount,
|
|
5999
|
+
noOpinionPercentage: answeredCount > 0 ? Math.round(noOpinionCount / answeredCount * 1e3) / 10 : 0,
|
|
6000
|
+
noOpinionLabels: resolveNoOpinionLabels(q.noOpinionLabel),
|
|
5954
6001
|
min: minVal,
|
|
5955
6002
|
max: maxVal,
|
|
5956
6003
|
lowLabel: q.lowLabel,
|
|
5957
6004
|
highLabel: q.highLabel,
|
|
5958
6005
|
scaleLabels: q.scaleLabels,
|
|
5959
|
-
average:
|
|
6006
|
+
average: scoredCount > 0 ? Math.round(sum / scoredCount * 100) / 100 : 0,
|
|
5960
6007
|
distribution,
|
|
5961
6008
|
npsBreakdown: q.type === "nps" ? {
|
|
5962
|
-
score:
|
|
6009
|
+
score: scoredCount > 0 ? Math.round((qPromoters - qDetractors) / scoredCount * 100) : 0,
|
|
5963
6010
|
promoters: qPromoters,
|
|
5964
6011
|
passives: qPassives,
|
|
5965
6012
|
detractors: qDetractors,
|
|
5966
|
-
promotersPct:
|
|
5967
|
-
passivesPct:
|
|
5968
|
-
detractorsPct:
|
|
6013
|
+
promotersPct: scoredCount > 0 ? Math.round(qPromoters / scoredCount * 1e3) / 10 : 0,
|
|
6014
|
+
passivesPct: scoredCount > 0 ? Math.round(qPassives / scoredCount * 1e3) / 10 : 0,
|
|
6015
|
+
detractorsPct: scoredCount > 0 ? Math.round(qDetractors / scoredCount * 1e3) / 10 : 0
|
|
5969
6016
|
} : void 0
|
|
5970
6017
|
};
|
|
5971
6018
|
}
|
|
5972
6019
|
if (q.type === "matrix_single") {
|
|
5973
6020
|
const mRows = Array.isArray(q.matrixRows) ? q.matrixRows : [];
|
|
5974
|
-
const
|
|
6021
|
+
const baseCols = Array.isArray(q.matrixColumns) ? q.matrixColumns : [];
|
|
5975
6022
|
const matrixData = {};
|
|
5976
6023
|
const rowTotals = {};
|
|
6024
|
+
let anyNoOpinionCell = false;
|
|
5977
6025
|
for (const rItem of mRows) {
|
|
5978
6026
|
matrixData[rItem.id] = {};
|
|
5979
6027
|
rowTotals[rItem.id] = 0;
|
|
5980
|
-
for (const cItem of
|
|
6028
|
+
for (const cItem of baseCols) {
|
|
5981
6029
|
matrixData[rItem.id][cItem.id] = 0;
|
|
5982
6030
|
}
|
|
5983
6031
|
}
|
|
@@ -5989,6 +6037,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5989
6037
|
const chosenCol = valObj[rItem.id];
|
|
5990
6038
|
if (!isEmptyFieldValue(chosenCol)) {
|
|
5991
6039
|
anyRow = true;
|
|
6040
|
+
if (chosenCol === NO_OPINION_VALUE) anyNoOpinionCell = true;
|
|
5992
6041
|
rowTotals[rItem.id] = (rowTotals[rItem.id] || 0) + 1;
|
|
5993
6042
|
if (matrixData[rItem.id]) {
|
|
5994
6043
|
matrixData[rItem.id][chosenCol] = (matrixData[rItem.id][chosenCol] || 0) + 1;
|
|
@@ -5997,13 +6046,20 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5997
6046
|
}
|
|
5998
6047
|
if (anyRow) answeredCount += 1;
|
|
5999
6048
|
}
|
|
6049
|
+
const effectiveCols = q.allowNoOpinion || anyNoOpinionCell ? [
|
|
6050
|
+
...baseCols,
|
|
6051
|
+
{
|
|
6052
|
+
id: NO_OPINION_VALUE,
|
|
6053
|
+
labels: resolveNoOpinionLabels(q.noOpinionLabel)
|
|
6054
|
+
}
|
|
6055
|
+
] : baseCols;
|
|
6000
6056
|
const rowsBreakdown = mRows.map((rItem) => {
|
|
6001
6057
|
const rTot = rowTotals[rItem.id] || 0;
|
|
6002
6058
|
return {
|
|
6003
6059
|
rowId: rItem.id,
|
|
6004
6060
|
labels: rItem.labels,
|
|
6005
6061
|
total: rTot,
|
|
6006
|
-
columns:
|
|
6062
|
+
columns: effectiveCols.map((cItem) => {
|
|
6007
6063
|
const cnt = matrixData[rItem.id]?.[cItem.id] || 0;
|
|
6008
6064
|
return {
|
|
6009
6065
|
colId: cItem.id,
|
|
@@ -6027,6 +6083,8 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6027
6083
|
const bordaSumMap = {};
|
|
6028
6084
|
const firstPlaceMap = {};
|
|
6029
6085
|
const itemCountMap = {};
|
|
6086
|
+
let rankedCount = 0;
|
|
6087
|
+
let noOpinionCount = 0;
|
|
6030
6088
|
opts.forEach((o) => {
|
|
6031
6089
|
rankSumMap[o.id] = 0;
|
|
6032
6090
|
bordaSumMap[o.id] = 0;
|
|
@@ -6035,8 +6093,14 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6035
6093
|
});
|
|
6036
6094
|
for (const r of responses) {
|
|
6037
6095
|
const arr = r.answers?.[q.key];
|
|
6096
|
+
if (arr === NO_OPINION_VALUE || Array.isArray(arr) && arr[0] === NO_OPINION_VALUE) {
|
|
6097
|
+
answeredCount += 1;
|
|
6098
|
+
noOpinionCount += 1;
|
|
6099
|
+
continue;
|
|
6100
|
+
}
|
|
6038
6101
|
if (!Array.isArray(arr) || arr.length === 0) continue;
|
|
6039
6102
|
answeredCount += 1;
|
|
6103
|
+
rankedCount += 1;
|
|
6040
6104
|
arr.forEach((optId, idx) => {
|
|
6041
6105
|
if (rankSumMap[optId] !== void 0) {
|
|
6042
6106
|
rankSumMap[optId] += idx + 1;
|
|
@@ -6046,7 +6110,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6046
6110
|
}
|
|
6047
6111
|
});
|
|
6048
6112
|
}
|
|
6049
|
-
const maxPossibleBorda =
|
|
6113
|
+
const maxPossibleBorda = rankedCount * nOpts;
|
|
6050
6114
|
const rankingBreakdown = opts.map((o) => {
|
|
6051
6115
|
const cnt = itemCountMap[o.id] || 0;
|
|
6052
6116
|
const avgRank = cnt > 0 ? Math.round(rankSumMap[o.id] / cnt * 100) / 100 : nOpts;
|
|
@@ -6059,12 +6123,17 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6059
6123
|
bordaPoints,
|
|
6060
6124
|
scorePercentage: maxPossibleBorda > 0 ? Math.round(bordaPoints / maxPossibleBorda * 1e3) / 10 : 0,
|
|
6061
6125
|
firstPlaceCount: firstPlaces,
|
|
6062
|
-
firstPlacePercentage:
|
|
6126
|
+
firstPlacePercentage: rankedCount > 0 ? Math.round(firstPlaces / rankedCount * 1e3) / 10 : 0
|
|
6063
6127
|
};
|
|
6064
6128
|
}).sort((a, b) => a.averageRank - b.averageRank);
|
|
6065
6129
|
return {
|
|
6066
6130
|
...baseInfo,
|
|
6067
6131
|
answeredCount,
|
|
6132
|
+
rankedCount,
|
|
6133
|
+
allowNoOpinion: Boolean(q.allowNoOpinion),
|
|
6134
|
+
noOpinionCount,
|
|
6135
|
+
noOpinionPercentage: answeredCount > 0 ? Math.round(noOpinionCount / answeredCount * 1e3) / 10 : 0,
|
|
6136
|
+
noOpinionLabels: resolveNoOpinionLabels(q.noOpinionLabel),
|
|
6068
6137
|
rankingBreakdown
|
|
6069
6138
|
};
|
|
6070
6139
|
}
|
|
@@ -6141,6 +6210,10 @@ function computePublicSurveyResults(survey, rawResponses) {
|
|
|
6141
6210
|
type: qs.type,
|
|
6142
6211
|
title: qs.title,
|
|
6143
6212
|
answeredCount: qs.answeredCount,
|
|
6213
|
+
scoredCount: qs.scoredCount,
|
|
6214
|
+
noOpinionCount: qs.noOpinionCount,
|
|
6215
|
+
noOpinionPercentage: qs.noOpinionPercentage,
|
|
6216
|
+
noOpinionLabels: qs.noOpinionLabels,
|
|
6144
6217
|
optionsBreakdown: qs.optionsBreakdown,
|
|
6145
6218
|
average: qs.average,
|
|
6146
6219
|
distribution: qs.distribution,
|
|
@@ -6201,19 +6274,29 @@ function buildSurveyResponseExportAoA(survey, rawResponses, locale = "en") {
|
|
|
6201
6274
|
];
|
|
6202
6275
|
for (const q of activeQuestions) {
|
|
6203
6276
|
const ans = r.answers?.[q.key];
|
|
6277
|
+
const noOpLabel = resolveLocalizedText(
|
|
6278
|
+
resolveNoOpinionLabels(q.noOpinionLabel),
|
|
6279
|
+
locale,
|
|
6280
|
+
tr ? "Fikrim yok" : "No idea"
|
|
6281
|
+
);
|
|
6204
6282
|
if (q.type === "matrix_single" && Array.isArray(q.matrixRows)) {
|
|
6205
6283
|
const mCols = Array.isArray(q.matrixColumns) ? q.matrixColumns : [];
|
|
6206
6284
|
for (const mRow of q.matrixRows) {
|
|
6207
6285
|
const chosenColId = ans && typeof ans === "object" ? ans[mRow.id] : "";
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6286
|
+
if (chosenColId === NO_OPINION_VALUE) {
|
|
6287
|
+
rowCells.push(noOpLabel);
|
|
6288
|
+
} else {
|
|
6289
|
+
const foundCol = mCols.find((c) => c.id === chosenColId);
|
|
6290
|
+
rowCells.push(
|
|
6291
|
+
foundCol ? resolveLocalizedText(foundCol.labels, locale, chosenColId) : String(chosenColId || "")
|
|
6292
|
+
);
|
|
6293
|
+
}
|
|
6212
6294
|
}
|
|
6213
6295
|
} else if (Array.isArray(q.options) && q.options.length > 0) {
|
|
6214
6296
|
if (Array.isArray(ans)) {
|
|
6215
6297
|
const mapped = ans.map((optId) => {
|
|
6216
6298
|
if (optId === "__other__") return tr ? "Diğer" : "Other";
|
|
6299
|
+
if (optId === NO_OPINION_VALUE) return noOpLabel;
|
|
6217
6300
|
const found = q.options.find((o) => o.id === optId);
|
|
6218
6301
|
return found ? resolveLocalizedText(found.labels, locale, optId) : optId;
|
|
6219
6302
|
});
|
|
@@ -6222,6 +6305,8 @@ function buildSurveyResponseExportAoA(survey, rawResponses, locale = "en") {
|
|
|
6222
6305
|
const strAns = String(ans);
|
|
6223
6306
|
if (strAns === "__other__") {
|
|
6224
6307
|
rowCells.push(tr ? "Diğer" : "Other");
|
|
6308
|
+
} else if (strAns === NO_OPINION_VALUE) {
|
|
6309
|
+
rowCells.push(noOpLabel);
|
|
6225
6310
|
} else {
|
|
6226
6311
|
const found = q.options.find((o) => o.id === strAns);
|
|
6227
6312
|
rowCells.push(found ? resolveLocalizedText(found.labels, locale, strAns) : strAns);
|
|
@@ -6233,7 +6318,9 @@ function buildSurveyResponseExportAoA(survey, rawResponses, locale = "en") {
|
|
|
6233
6318
|
rowCells.push(String(r.otherTexts?.[q.key] || ""));
|
|
6234
6319
|
}
|
|
6235
6320
|
} else {
|
|
6236
|
-
if (
|
|
6321
|
+
if (ans === NO_OPINION_VALUE) {
|
|
6322
|
+
rowCells.push(noOpLabel);
|
|
6323
|
+
} else if (q.type === "likert_scale" && q.scaleLabels && ans !== void 0 && ans !== null && ans !== "") {
|
|
6237
6324
|
const ptLbl = resolveLocalizedText(q.scaleLabels[String(ans)], locale, "");
|
|
6238
6325
|
rowCells.push(ptLbl ? `${ans} - ${ptLbl}` : Number.isNaN(Number(ans)) ? String(ans) : Number(ans));
|
|
6239
6326
|
} else if ((q.type === "nps" || q.type === "star_rating" || q.type === "likert_scale") && ans !== void 0 && ans !== null && ans !== "" && !Number.isNaN(Number(ans))) {
|
|
@@ -6330,6 +6417,16 @@ function exportSurveyResponsesToXlsxBuffer(survey, rawResponses, locale = "en")
|
|
|
6330
6417
|
d.percentage
|
|
6331
6418
|
]);
|
|
6332
6419
|
}
|
|
6420
|
+
if (qs.allowNoOpinion || qs.noOpinionCount && qs.noOpinionCount > 0) {
|
|
6421
|
+
summaryAoA.push([
|
|
6422
|
+
qs.key,
|
|
6423
|
+
qTitle,
|
|
6424
|
+
qs.type,
|
|
6425
|
+
resolveLocalizedText(qs.noOpinionLabels, locale, tr ? "Fikrim yok" : "No idea"),
|
|
6426
|
+
qs.noOpinionCount || 0,
|
|
6427
|
+
qs.noOpinionPercentage || 0
|
|
6428
|
+
]);
|
|
6429
|
+
}
|
|
6333
6430
|
} else if (Array.isArray(qs.rankingBreakdown)) {
|
|
6334
6431
|
for (const rk of qs.rankingBreakdown) {
|
|
6335
6432
|
summaryAoA.push([
|
|
@@ -6341,6 +6438,16 @@ function exportSurveyResponsesToXlsxBuffer(survey, rawResponses, locale = "en")
|
|
|
6341
6438
|
rk.scorePercentage
|
|
6342
6439
|
]);
|
|
6343
6440
|
}
|
|
6441
|
+
if (qs.allowNoOpinion || qs.noOpinionCount && qs.noOpinionCount > 0) {
|
|
6442
|
+
summaryAoA.push([
|
|
6443
|
+
qs.key,
|
|
6444
|
+
qTitle,
|
|
6445
|
+
qs.type,
|
|
6446
|
+
resolveLocalizedText(qs.noOpinionLabels, locale, tr ? "Fikrim yok" : "No idea"),
|
|
6447
|
+
qs.noOpinionCount || 0,
|
|
6448
|
+
qs.noOpinionPercentage || 0
|
|
6449
|
+
]);
|
|
6450
|
+
}
|
|
6344
6451
|
} else {
|
|
6345
6452
|
summaryAoA.push([
|
|
6346
6453
|
qs.key,
|
|
@@ -6376,7 +6483,7 @@ function slugifyIdentifier(text) {
|
|
|
6376
6483
|
ü: "u",
|
|
6377
6484
|
Ü: "u"
|
|
6378
6485
|
};
|
|
6379
|
-
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
6486
|
+
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/_{2,}/g, "_").replace(/^[-_]+|[-_]+$/g, "");
|
|
6380
6487
|
}
|
|
6381
6488
|
function getEnvRecaptchaPublicKey() {
|
|
6382
6489
|
return (process.env.MIX_RECAPTCHA_PUBLIC_KEY || process.env.RECAPTCHA_PUBLIC_KEY || process.env.NUXT_PUBLIC_RECAPTCHA_SITE_KEY || "").trim();
|
|
@@ -6754,9 +6861,7 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
6754
6861
|
},
|
|
6755
6862
|
async save(payload) {
|
|
6756
6863
|
const cleanTitle = String(payload.title || "Yeni Anket").trim();
|
|
6757
|
-
const cleanSlug = String(
|
|
6758
|
-
payload.slug || slugifyIdentifier(cleanTitle) || `survey_${Date.now()}`
|
|
6759
|
-
).trim();
|
|
6864
|
+
const cleanSlug = slugifyIdentifier(String(payload.slug || "")) || slugifyIdentifier(cleanTitle) || `survey_${Date.now()}`;
|
|
6760
6865
|
let existing = null;
|
|
6761
6866
|
if (payload.id) {
|
|
6762
6867
|
const rawId = String(payload.id).trim();
|