@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
package/dist/server/index.mjs
CHANGED
|
@@ -4719,7 +4719,7 @@ function slugifyIdentifier$1(text) {
|
|
|
4719
4719
|
ü: "u",
|
|
4720
4720
|
Ü: "u"
|
|
4721
4721
|
};
|
|
4722
|
-
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
4722
|
+
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/_{2,}/g, "_").replace(/^[-_]+|[-_]+$/g, "");
|
|
4723
4723
|
}
|
|
4724
4724
|
function stripHtmlTags(html) {
|
|
4725
4725
|
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();
|
|
@@ -5543,6 +5543,20 @@ const ciFormService = ({ strapi }) => ({
|
|
|
5543
5543
|
}
|
|
5544
5544
|
});
|
|
5545
5545
|
const XLSX = XLSXNs?.utils ? XLSXNs : XLSXNs?.default || XLSXNs;
|
|
5546
|
+
const NO_OPINION_VALUE = "__na__";
|
|
5547
|
+
function resolveNoOpinionLabels(raw) {
|
|
5548
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
5549
|
+
return {
|
|
5550
|
+
tr: raw.tr || "Fikrim yok",
|
|
5551
|
+
en: raw.en || "No idea",
|
|
5552
|
+
...raw
|
|
5553
|
+
};
|
|
5554
|
+
}
|
|
5555
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
5556
|
+
return { tr: raw.trim(), en: raw.trim() };
|
|
5557
|
+
}
|
|
5558
|
+
return { tr: "Fikrim yok", en: "No idea" };
|
|
5559
|
+
}
|
|
5546
5560
|
function evalSingleRule(rule, answers) {
|
|
5547
5561
|
const targetVal = answers ? answers[rule.questionKey] : void 0;
|
|
5548
5562
|
const op = rule.operator;
|
|
@@ -5632,9 +5646,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5632
5646
|
}
|
|
5633
5647
|
} else if (q.type === "multiple_choice" || q.type === "image_choice" && (q.maxSelections ?? 1) > 1) {
|
|
5634
5648
|
const arr = Array.isArray(val) ? val : [];
|
|
5649
|
+
const isExclusiveNoOpinion = q.allowNoOpinion && arr.includes(NO_OPINION_VALUE);
|
|
5635
5650
|
if (q.required && arr.length === 0) {
|
|
5636
5651
|
qErrors.push(lMsg(locale, `Lütfen en az bir seçenek işaretleyiniz.`, `Please select at least one option.`));
|
|
5637
|
-
} else if (arr.length > 0) {
|
|
5652
|
+
} else if (arr.length > 0 && !isExclusiveNoOpinion) {
|
|
5638
5653
|
if (q.minSelections && arr.length < q.minSelections) {
|
|
5639
5654
|
qErrors.push(
|
|
5640
5655
|
lMsg(
|
|
@@ -5654,7 +5669,7 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5654
5669
|
);
|
|
5655
5670
|
}
|
|
5656
5671
|
}
|
|
5657
|
-
if (q.allowOther && arr.includes("__other__") && !String(otherTexts?.[q.key] || "").trim()) {
|
|
5672
|
+
if (!isExclusiveNoOpinion && q.allowOther && arr.includes("__other__") && !String(otherTexts?.[q.key] || "").trim()) {
|
|
5658
5673
|
qErrors.push(
|
|
5659
5674
|
lMsg(locale, `Lütfen "Diğer" seçeneği için açıklama giriniz.`, `Please specify your "Other" choice.`)
|
|
5660
5675
|
);
|
|
@@ -5669,9 +5684,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5669
5684
|
);
|
|
5670
5685
|
}
|
|
5671
5686
|
} else if (q.type === "nps") {
|
|
5687
|
+
const isNoOp = Boolean(q.allowNoOpinion && val === NO_OPINION_VALUE);
|
|
5672
5688
|
if (q.required && empty) {
|
|
5673
5689
|
qErrors.push(lMsg(locale, `Lütfen 0 ile 10 arasında bir puan seçiniz.`, `Please choose a score from 0 to 10.`));
|
|
5674
|
-
} else if (!empty) {
|
|
5690
|
+
} else if (!empty && !isNoOp) {
|
|
5675
5691
|
const n = Number(val);
|
|
5676
5692
|
if (Number.isNaN(n) || n < 0 || n > 10) {
|
|
5677
5693
|
qErrors.push(lMsg(locale, `Puan 0 ile 10 arasında olmalıdır.`, `Score must be between 0 and 10.`));
|
|
@@ -5679,9 +5695,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5679
5695
|
}
|
|
5680
5696
|
} else if (q.type === "star_rating") {
|
|
5681
5697
|
const maxS = q.maxStars || 5;
|
|
5698
|
+
const isNoOp = Boolean(q.allowNoOpinion && val === NO_OPINION_VALUE);
|
|
5682
5699
|
if (q.required && empty) {
|
|
5683
5700
|
qErrors.push(lMsg(locale, `Lütfen derecelendirme yapınız.`, `Please provide a rating.`));
|
|
5684
|
-
} else if (!empty) {
|
|
5701
|
+
} else if (!empty && !isNoOp) {
|
|
5685
5702
|
const n = Number(val);
|
|
5686
5703
|
if (Number.isNaN(n) || n < 1 || n > maxS) {
|
|
5687
5704
|
qErrors.push(lMsg(locale, `Derece 1 ile ${maxS} arasında olmalıdır.`, `Rating must be between 1 and ${maxS}.`));
|
|
@@ -5690,9 +5707,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5690
5707
|
} else if (q.type === "likert_scale") {
|
|
5691
5708
|
const sMin = q.scaleMin ?? 1;
|
|
5692
5709
|
const sMax = q.scaleMax ?? 5;
|
|
5710
|
+
const isNoOp = Boolean(q.allowNoOpinion && val === NO_OPINION_VALUE);
|
|
5693
5711
|
if (q.required && empty) {
|
|
5694
5712
|
qErrors.push(lMsg(locale, `Lütfen ölçekten bir değer seçiniz.`, `Please select a value on the scale.`));
|
|
5695
|
-
} else if (!empty) {
|
|
5713
|
+
} else if (!empty && !isNoOp) {
|
|
5696
5714
|
const n = Number(val);
|
|
5697
5715
|
if (Number.isNaN(n) || n < sMin || n > sMax) {
|
|
5698
5716
|
qErrors.push(
|
|
@@ -5701,7 +5719,10 @@ function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en
|
|
|
5701
5719
|
}
|
|
5702
5720
|
}
|
|
5703
5721
|
} else if (q.type === "ranking") {
|
|
5704
|
-
|
|
5722
|
+
const isNoOp = Boolean(
|
|
5723
|
+
q.allowNoOpinion && (val === NO_OPINION_VALUE || Array.isArray(val) && val[0] === NO_OPINION_VALUE)
|
|
5724
|
+
);
|
|
5725
|
+
if (q.required && !isNoOp && (!Array.isArray(val) || val.length === 0)) {
|
|
5705
5726
|
qErrors.push(lMsg(locale, `Lütfen sıralamayı onaylayınız.`, `Please confirm the ranking.`));
|
|
5706
5727
|
}
|
|
5707
5728
|
} else if (q.type === "short_text" || q.type === "long_text") {
|
|
@@ -5846,6 +5867,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5846
5867
|
countsMap[o.id] = 0;
|
|
5847
5868
|
});
|
|
5848
5869
|
let otherCount = 0;
|
|
5870
|
+
let noOpinionCount = 0;
|
|
5849
5871
|
const otherSamples = [];
|
|
5850
5872
|
for (const r of responses) {
|
|
5851
5873
|
const v = r.answers?.[q.key];
|
|
@@ -5863,6 +5885,8 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5863
5885
|
submittedAt: r.submittedAt || r.createdAt || ""
|
|
5864
5886
|
});
|
|
5865
5887
|
}
|
|
5888
|
+
} else if (item === NO_OPINION_VALUE) {
|
|
5889
|
+
noOpinionCount += 1;
|
|
5866
5890
|
} else {
|
|
5867
5891
|
countsMap[item] = (countsMap[item] || 0) + 1;
|
|
5868
5892
|
}
|
|
@@ -5887,9 +5911,19 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5887
5911
|
percentage: answeredCount > 0 ? Math.round(otherCount / answeredCount * 1e3) / 10 : 0
|
|
5888
5912
|
});
|
|
5889
5913
|
}
|
|
5914
|
+
if (q.allowNoOpinion || noOpinionCount > 0) {
|
|
5915
|
+
optionsBreakdown.push({
|
|
5916
|
+
id: NO_OPINION_VALUE,
|
|
5917
|
+
labels: resolveNoOpinionLabels(q.noOpinionLabel),
|
|
5918
|
+
image: null,
|
|
5919
|
+
count: noOpinionCount,
|
|
5920
|
+
percentage: answeredCount > 0 ? Math.round(noOpinionCount / answeredCount * 1e3) / 10 : 0
|
|
5921
|
+
});
|
|
5922
|
+
}
|
|
5890
5923
|
return {
|
|
5891
5924
|
...baseInfo,
|
|
5892
5925
|
answeredCount,
|
|
5926
|
+
noOpinionCount,
|
|
5893
5927
|
optionsBreakdown,
|
|
5894
5928
|
otherSamples
|
|
5895
5929
|
};
|
|
@@ -5900,15 +5934,23 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5900
5934
|
const distMap = {};
|
|
5901
5935
|
for (let i = minVal; i <= maxVal; i += 1) distMap[i] = 0;
|
|
5902
5936
|
let sum = 0;
|
|
5937
|
+
let scoredCount = 0;
|
|
5938
|
+
let noOpinionCount = 0;
|
|
5903
5939
|
let qPromoters = 0;
|
|
5904
5940
|
let qPassives = 0;
|
|
5905
5941
|
let qDetractors = 0;
|
|
5906
5942
|
for (const r of responses) {
|
|
5907
5943
|
const rawV = r.answers?.[q.key];
|
|
5908
5944
|
if (isEmptyFieldValue(rawV)) continue;
|
|
5945
|
+
if (rawV === NO_OPINION_VALUE) {
|
|
5946
|
+
answeredCount += 1;
|
|
5947
|
+
noOpinionCount += 1;
|
|
5948
|
+
continue;
|
|
5949
|
+
}
|
|
5909
5950
|
const n = Number(rawV);
|
|
5910
5951
|
if (Number.isNaN(n)) continue;
|
|
5911
5952
|
answeredCount += 1;
|
|
5953
|
+
scoredCount += 1;
|
|
5912
5954
|
sum += n;
|
|
5913
5955
|
distMap[n] = (distMap[n] || 0) + 1;
|
|
5914
5956
|
if (q.type === "nps") {
|
|
@@ -5921,38 +5963,44 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5921
5963
|
value,
|
|
5922
5964
|
labels: q.scaleLabels ? q.scaleLabels[String(value)] : void 0,
|
|
5923
5965
|
count: distMap[value] || 0,
|
|
5924
|
-
percentage:
|
|
5966
|
+
percentage: scoredCount > 0 ? Math.round((distMap[value] || 0) / scoredCount * 1e3) / 10 : 0
|
|
5925
5967
|
}));
|
|
5926
5968
|
return {
|
|
5927
5969
|
...baseInfo,
|
|
5928
5970
|
answeredCount,
|
|
5971
|
+
scoredCount,
|
|
5972
|
+
allowNoOpinion: Boolean(q.allowNoOpinion),
|
|
5973
|
+
noOpinionCount,
|
|
5974
|
+
noOpinionPercentage: answeredCount > 0 ? Math.round(noOpinionCount / answeredCount * 1e3) / 10 : 0,
|
|
5975
|
+
noOpinionLabels: resolveNoOpinionLabels(q.noOpinionLabel),
|
|
5929
5976
|
min: minVal,
|
|
5930
5977
|
max: maxVal,
|
|
5931
5978
|
lowLabel: q.lowLabel,
|
|
5932
5979
|
highLabel: q.highLabel,
|
|
5933
5980
|
scaleLabels: q.scaleLabels,
|
|
5934
|
-
average:
|
|
5981
|
+
average: scoredCount > 0 ? Math.round(sum / scoredCount * 100) / 100 : 0,
|
|
5935
5982
|
distribution,
|
|
5936
5983
|
npsBreakdown: q.type === "nps" ? {
|
|
5937
|
-
score:
|
|
5984
|
+
score: scoredCount > 0 ? Math.round((qPromoters - qDetractors) / scoredCount * 100) : 0,
|
|
5938
5985
|
promoters: qPromoters,
|
|
5939
5986
|
passives: qPassives,
|
|
5940
5987
|
detractors: qDetractors,
|
|
5941
|
-
promotersPct:
|
|
5942
|
-
passivesPct:
|
|
5943
|
-
detractorsPct:
|
|
5988
|
+
promotersPct: scoredCount > 0 ? Math.round(qPromoters / scoredCount * 1e3) / 10 : 0,
|
|
5989
|
+
passivesPct: scoredCount > 0 ? Math.round(qPassives / scoredCount * 1e3) / 10 : 0,
|
|
5990
|
+
detractorsPct: scoredCount > 0 ? Math.round(qDetractors / scoredCount * 1e3) / 10 : 0
|
|
5944
5991
|
} : void 0
|
|
5945
5992
|
};
|
|
5946
5993
|
}
|
|
5947
5994
|
if (q.type === "matrix_single") {
|
|
5948
5995
|
const mRows = Array.isArray(q.matrixRows) ? q.matrixRows : [];
|
|
5949
|
-
const
|
|
5996
|
+
const baseCols = Array.isArray(q.matrixColumns) ? q.matrixColumns : [];
|
|
5950
5997
|
const matrixData = {};
|
|
5951
5998
|
const rowTotals = {};
|
|
5999
|
+
let anyNoOpinionCell = false;
|
|
5952
6000
|
for (const rItem of mRows) {
|
|
5953
6001
|
matrixData[rItem.id] = {};
|
|
5954
6002
|
rowTotals[rItem.id] = 0;
|
|
5955
|
-
for (const cItem of
|
|
6003
|
+
for (const cItem of baseCols) {
|
|
5956
6004
|
matrixData[rItem.id][cItem.id] = 0;
|
|
5957
6005
|
}
|
|
5958
6006
|
}
|
|
@@ -5964,6 +6012,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5964
6012
|
const chosenCol = valObj[rItem.id];
|
|
5965
6013
|
if (!isEmptyFieldValue(chosenCol)) {
|
|
5966
6014
|
anyRow = true;
|
|
6015
|
+
if (chosenCol === NO_OPINION_VALUE) anyNoOpinionCell = true;
|
|
5967
6016
|
rowTotals[rItem.id] = (rowTotals[rItem.id] || 0) + 1;
|
|
5968
6017
|
if (matrixData[rItem.id]) {
|
|
5969
6018
|
matrixData[rItem.id][chosenCol] = (matrixData[rItem.id][chosenCol] || 0) + 1;
|
|
@@ -5972,13 +6021,20 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
5972
6021
|
}
|
|
5973
6022
|
if (anyRow) answeredCount += 1;
|
|
5974
6023
|
}
|
|
6024
|
+
const effectiveCols = q.allowNoOpinion || anyNoOpinionCell ? [
|
|
6025
|
+
...baseCols,
|
|
6026
|
+
{
|
|
6027
|
+
id: NO_OPINION_VALUE,
|
|
6028
|
+
labels: resolveNoOpinionLabels(q.noOpinionLabel)
|
|
6029
|
+
}
|
|
6030
|
+
] : baseCols;
|
|
5975
6031
|
const rowsBreakdown = mRows.map((rItem) => {
|
|
5976
6032
|
const rTot = rowTotals[rItem.id] || 0;
|
|
5977
6033
|
return {
|
|
5978
6034
|
rowId: rItem.id,
|
|
5979
6035
|
labels: rItem.labels,
|
|
5980
6036
|
total: rTot,
|
|
5981
|
-
columns:
|
|
6037
|
+
columns: effectiveCols.map((cItem) => {
|
|
5982
6038
|
const cnt = matrixData[rItem.id]?.[cItem.id] || 0;
|
|
5983
6039
|
return {
|
|
5984
6040
|
colId: cItem.id,
|
|
@@ -6002,6 +6058,8 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6002
6058
|
const bordaSumMap = {};
|
|
6003
6059
|
const firstPlaceMap = {};
|
|
6004
6060
|
const itemCountMap = {};
|
|
6061
|
+
let rankedCount = 0;
|
|
6062
|
+
let noOpinionCount = 0;
|
|
6005
6063
|
opts.forEach((o) => {
|
|
6006
6064
|
rankSumMap[o.id] = 0;
|
|
6007
6065
|
bordaSumMap[o.id] = 0;
|
|
@@ -6010,8 +6068,14 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6010
6068
|
});
|
|
6011
6069
|
for (const r of responses) {
|
|
6012
6070
|
const arr = r.answers?.[q.key];
|
|
6071
|
+
if (arr === NO_OPINION_VALUE || Array.isArray(arr) && arr[0] === NO_OPINION_VALUE) {
|
|
6072
|
+
answeredCount += 1;
|
|
6073
|
+
noOpinionCount += 1;
|
|
6074
|
+
continue;
|
|
6075
|
+
}
|
|
6013
6076
|
if (!Array.isArray(arr) || arr.length === 0) continue;
|
|
6014
6077
|
answeredCount += 1;
|
|
6078
|
+
rankedCount += 1;
|
|
6015
6079
|
arr.forEach((optId, idx) => {
|
|
6016
6080
|
if (rankSumMap[optId] !== void 0) {
|
|
6017
6081
|
rankSumMap[optId] += idx + 1;
|
|
@@ -6021,7 +6085,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6021
6085
|
}
|
|
6022
6086
|
});
|
|
6023
6087
|
}
|
|
6024
|
-
const maxPossibleBorda =
|
|
6088
|
+
const maxPossibleBorda = rankedCount * nOpts;
|
|
6025
6089
|
const rankingBreakdown = opts.map((o) => {
|
|
6026
6090
|
const cnt = itemCountMap[o.id] || 0;
|
|
6027
6091
|
const avgRank = cnt > 0 ? Math.round(rankSumMap[o.id] / cnt * 100) / 100 : nOpts;
|
|
@@ -6034,12 +6098,17 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
6034
6098
|
bordaPoints,
|
|
6035
6099
|
scorePercentage: maxPossibleBorda > 0 ? Math.round(bordaPoints / maxPossibleBorda * 1e3) / 10 : 0,
|
|
6036
6100
|
firstPlaceCount: firstPlaces,
|
|
6037
|
-
firstPlacePercentage:
|
|
6101
|
+
firstPlacePercentage: rankedCount > 0 ? Math.round(firstPlaces / rankedCount * 1e3) / 10 : 0
|
|
6038
6102
|
};
|
|
6039
6103
|
}).sort((a, b) => a.averageRank - b.averageRank);
|
|
6040
6104
|
return {
|
|
6041
6105
|
...baseInfo,
|
|
6042
6106
|
answeredCount,
|
|
6107
|
+
rankedCount,
|
|
6108
|
+
allowNoOpinion: Boolean(q.allowNoOpinion),
|
|
6109
|
+
noOpinionCount,
|
|
6110
|
+
noOpinionPercentage: answeredCount > 0 ? Math.round(noOpinionCount / answeredCount * 1e3) / 10 : 0,
|
|
6111
|
+
noOpinionLabels: resolveNoOpinionLabels(q.noOpinionLabel),
|
|
6043
6112
|
rankingBreakdown
|
|
6044
6113
|
};
|
|
6045
6114
|
}
|
|
@@ -6116,6 +6185,10 @@ function computePublicSurveyResults(survey, rawResponses) {
|
|
|
6116
6185
|
type: qs.type,
|
|
6117
6186
|
title: qs.title,
|
|
6118
6187
|
answeredCount: qs.answeredCount,
|
|
6188
|
+
scoredCount: qs.scoredCount,
|
|
6189
|
+
noOpinionCount: qs.noOpinionCount,
|
|
6190
|
+
noOpinionPercentage: qs.noOpinionPercentage,
|
|
6191
|
+
noOpinionLabels: qs.noOpinionLabels,
|
|
6119
6192
|
optionsBreakdown: qs.optionsBreakdown,
|
|
6120
6193
|
average: qs.average,
|
|
6121
6194
|
distribution: qs.distribution,
|
|
@@ -6176,19 +6249,29 @@ function buildSurveyResponseExportAoA(survey, rawResponses, locale = "en") {
|
|
|
6176
6249
|
];
|
|
6177
6250
|
for (const q of activeQuestions) {
|
|
6178
6251
|
const ans = r.answers?.[q.key];
|
|
6252
|
+
const noOpLabel = resolveLocalizedText(
|
|
6253
|
+
resolveNoOpinionLabels(q.noOpinionLabel),
|
|
6254
|
+
locale,
|
|
6255
|
+
tr ? "Fikrim yok" : "No idea"
|
|
6256
|
+
);
|
|
6179
6257
|
if (q.type === "matrix_single" && Array.isArray(q.matrixRows)) {
|
|
6180
6258
|
const mCols = Array.isArray(q.matrixColumns) ? q.matrixColumns : [];
|
|
6181
6259
|
for (const mRow of q.matrixRows) {
|
|
6182
6260
|
const chosenColId = ans && typeof ans === "object" ? ans[mRow.id] : "";
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6261
|
+
if (chosenColId === NO_OPINION_VALUE) {
|
|
6262
|
+
rowCells.push(noOpLabel);
|
|
6263
|
+
} else {
|
|
6264
|
+
const foundCol = mCols.find((c) => c.id === chosenColId);
|
|
6265
|
+
rowCells.push(
|
|
6266
|
+
foundCol ? resolveLocalizedText(foundCol.labels, locale, chosenColId) : String(chosenColId || "")
|
|
6267
|
+
);
|
|
6268
|
+
}
|
|
6187
6269
|
}
|
|
6188
6270
|
} else if (Array.isArray(q.options) && q.options.length > 0) {
|
|
6189
6271
|
if (Array.isArray(ans)) {
|
|
6190
6272
|
const mapped = ans.map((optId) => {
|
|
6191
6273
|
if (optId === "__other__") return tr ? "Diğer" : "Other";
|
|
6274
|
+
if (optId === NO_OPINION_VALUE) return noOpLabel;
|
|
6192
6275
|
const found = q.options.find((o) => o.id === optId);
|
|
6193
6276
|
return found ? resolveLocalizedText(found.labels, locale, optId) : optId;
|
|
6194
6277
|
});
|
|
@@ -6197,6 +6280,8 @@ function buildSurveyResponseExportAoA(survey, rawResponses, locale = "en") {
|
|
|
6197
6280
|
const strAns = String(ans);
|
|
6198
6281
|
if (strAns === "__other__") {
|
|
6199
6282
|
rowCells.push(tr ? "Diğer" : "Other");
|
|
6283
|
+
} else if (strAns === NO_OPINION_VALUE) {
|
|
6284
|
+
rowCells.push(noOpLabel);
|
|
6200
6285
|
} else {
|
|
6201
6286
|
const found = q.options.find((o) => o.id === strAns);
|
|
6202
6287
|
rowCells.push(found ? resolveLocalizedText(found.labels, locale, strAns) : strAns);
|
|
@@ -6208,7 +6293,9 @@ function buildSurveyResponseExportAoA(survey, rawResponses, locale = "en") {
|
|
|
6208
6293
|
rowCells.push(String(r.otherTexts?.[q.key] || ""));
|
|
6209
6294
|
}
|
|
6210
6295
|
} else {
|
|
6211
|
-
if (
|
|
6296
|
+
if (ans === NO_OPINION_VALUE) {
|
|
6297
|
+
rowCells.push(noOpLabel);
|
|
6298
|
+
} else if (q.type === "likert_scale" && q.scaleLabels && ans !== void 0 && ans !== null && ans !== "") {
|
|
6212
6299
|
const ptLbl = resolveLocalizedText(q.scaleLabels[String(ans)], locale, "");
|
|
6213
6300
|
rowCells.push(ptLbl ? `${ans} - ${ptLbl}` : Number.isNaN(Number(ans)) ? String(ans) : Number(ans));
|
|
6214
6301
|
} else if ((q.type === "nps" || q.type === "star_rating" || q.type === "likert_scale") && ans !== void 0 && ans !== null && ans !== "" && !Number.isNaN(Number(ans))) {
|
|
@@ -6305,6 +6392,16 @@ function exportSurveyResponsesToXlsxBuffer(survey, rawResponses, locale = "en")
|
|
|
6305
6392
|
d.percentage
|
|
6306
6393
|
]);
|
|
6307
6394
|
}
|
|
6395
|
+
if (qs.allowNoOpinion || qs.noOpinionCount && qs.noOpinionCount > 0) {
|
|
6396
|
+
summaryAoA.push([
|
|
6397
|
+
qs.key,
|
|
6398
|
+
qTitle,
|
|
6399
|
+
qs.type,
|
|
6400
|
+
resolveLocalizedText(qs.noOpinionLabels, locale, tr ? "Fikrim yok" : "No idea"),
|
|
6401
|
+
qs.noOpinionCount || 0,
|
|
6402
|
+
qs.noOpinionPercentage || 0
|
|
6403
|
+
]);
|
|
6404
|
+
}
|
|
6308
6405
|
} else if (Array.isArray(qs.rankingBreakdown)) {
|
|
6309
6406
|
for (const rk of qs.rankingBreakdown) {
|
|
6310
6407
|
summaryAoA.push([
|
|
@@ -6316,6 +6413,16 @@ function exportSurveyResponsesToXlsxBuffer(survey, rawResponses, locale = "en")
|
|
|
6316
6413
|
rk.scorePercentage
|
|
6317
6414
|
]);
|
|
6318
6415
|
}
|
|
6416
|
+
if (qs.allowNoOpinion || qs.noOpinionCount && qs.noOpinionCount > 0) {
|
|
6417
|
+
summaryAoA.push([
|
|
6418
|
+
qs.key,
|
|
6419
|
+
qTitle,
|
|
6420
|
+
qs.type,
|
|
6421
|
+
resolveLocalizedText(qs.noOpinionLabels, locale, tr ? "Fikrim yok" : "No idea"),
|
|
6422
|
+
qs.noOpinionCount || 0,
|
|
6423
|
+
qs.noOpinionPercentage || 0
|
|
6424
|
+
]);
|
|
6425
|
+
}
|
|
6319
6426
|
} else {
|
|
6320
6427
|
summaryAoA.push([
|
|
6321
6428
|
qs.key,
|
|
@@ -6351,7 +6458,7 @@ function slugifyIdentifier(text) {
|
|
|
6351
6458
|
ü: "u",
|
|
6352
6459
|
Ü: "u"
|
|
6353
6460
|
};
|
|
6354
|
-
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
6461
|
+
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/_{2,}/g, "_").replace(/^[-_]+|[-_]+$/g, "");
|
|
6355
6462
|
}
|
|
6356
6463
|
function getEnvRecaptchaPublicKey() {
|
|
6357
6464
|
return (process.env.MIX_RECAPTCHA_PUBLIC_KEY || process.env.RECAPTCHA_PUBLIC_KEY || process.env.NUXT_PUBLIC_RECAPTCHA_SITE_KEY || "").trim();
|
|
@@ -6729,9 +6836,7 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
6729
6836
|
},
|
|
6730
6837
|
async save(payload) {
|
|
6731
6838
|
const cleanTitle = String(payload.title || "Yeni Anket").trim();
|
|
6732
|
-
const cleanSlug = String(
|
|
6733
|
-
payload.slug || slugifyIdentifier(cleanTitle) || `survey_${Date.now()}`
|
|
6734
|
-
).trim();
|
|
6839
|
+
const cleanSlug = slugifyIdentifier(String(payload.slug || "")) || slugifyIdentifier(cleanTitle) || `survey_${Date.now()}`;
|
|
6735
6840
|
let existing = null;
|
|
6736
6841
|
if (payload.id) {
|
|
6737
6842
|
const rawId = String(payload.id).trim();
|
|
@@ -350,6 +350,10 @@ declare const _default: {
|
|
|
350
350
|
type: any;
|
|
351
351
|
title: any;
|
|
352
352
|
answeredCount: any;
|
|
353
|
+
scoredCount: any;
|
|
354
|
+
noOpinionCount: any;
|
|
355
|
+
noOpinionPercentage: any;
|
|
356
|
+
noOpinionLabels: any;
|
|
353
357
|
optionsBreakdown: any;
|
|
354
358
|
average: any;
|
|
355
359
|
distribution: any;
|
|
@@ -399,6 +403,10 @@ declare const _default: {
|
|
|
399
403
|
type: any;
|
|
400
404
|
title: any;
|
|
401
405
|
answeredCount: any;
|
|
406
|
+
scoredCount: any;
|
|
407
|
+
noOpinionCount: any;
|
|
408
|
+
noOpinionPercentage: any;
|
|
409
|
+
noOpinionLabels: any;
|
|
402
410
|
optionsBreakdown: any;
|
|
403
411
|
average: any;
|
|
404
412
|
distribution: any;
|
|
@@ -426,6 +434,10 @@ declare const _default: {
|
|
|
426
434
|
type: any;
|
|
427
435
|
title: any;
|
|
428
436
|
answeredCount: any;
|
|
437
|
+
scoredCount: any;
|
|
438
|
+
noOpinionCount: any;
|
|
439
|
+
noOpinionPercentage: any;
|
|
440
|
+
noOpinionLabels: any;
|
|
429
441
|
optionsBreakdown: any;
|
|
430
442
|
average: any;
|
|
431
443
|
distribution: any;
|
|
@@ -468,6 +480,7 @@ declare const _default: {
|
|
|
468
480
|
};
|
|
469
481
|
questionStats: ({
|
|
470
482
|
answeredCount: number;
|
|
483
|
+
noOpinionCount: number;
|
|
471
484
|
optionsBreakdown: {
|
|
472
485
|
id: string;
|
|
473
486
|
labels: Record<string, string>;
|
|
@@ -487,6 +500,11 @@ declare const _default: {
|
|
|
487
500
|
hasConditions: boolean;
|
|
488
501
|
} | {
|
|
489
502
|
answeredCount: number;
|
|
503
|
+
scoredCount: number;
|
|
504
|
+
allowNoOpinion: boolean;
|
|
505
|
+
noOpinionCount: number;
|
|
506
|
+
noOpinionPercentage: number;
|
|
507
|
+
noOpinionLabels: Record<string, string>;
|
|
490
508
|
min: number;
|
|
491
509
|
max: number;
|
|
492
510
|
lowLabel: string | Record<string, string>;
|
|
@@ -533,6 +551,11 @@ declare const _default: {
|
|
|
533
551
|
hasConditions: boolean;
|
|
534
552
|
} | {
|
|
535
553
|
answeredCount: number;
|
|
554
|
+
rankedCount: number;
|
|
555
|
+
allowNoOpinion: boolean;
|
|
556
|
+
noOpinionCount: number;
|
|
557
|
+
noOpinionPercentage: number;
|
|
558
|
+
noOpinionLabels: Record<string, string>;
|
|
536
559
|
rankingBreakdown: {
|
|
537
560
|
id: string;
|
|
538
561
|
labels: Record<string, string>;
|
|
@@ -78,6 +78,10 @@ declare const ciSurveyService: ({ strapi }: {
|
|
|
78
78
|
type: any;
|
|
79
79
|
title: any;
|
|
80
80
|
answeredCount: any;
|
|
81
|
+
scoredCount: any;
|
|
82
|
+
noOpinionCount: any;
|
|
83
|
+
noOpinionPercentage: any;
|
|
84
|
+
noOpinionLabels: any;
|
|
81
85
|
optionsBreakdown: any;
|
|
82
86
|
average: any;
|
|
83
87
|
distribution: any;
|
|
@@ -127,6 +131,10 @@ declare const ciSurveyService: ({ strapi }: {
|
|
|
127
131
|
type: any;
|
|
128
132
|
title: any;
|
|
129
133
|
answeredCount: any;
|
|
134
|
+
scoredCount: any;
|
|
135
|
+
noOpinionCount: any;
|
|
136
|
+
noOpinionPercentage: any;
|
|
137
|
+
noOpinionLabels: any;
|
|
130
138
|
optionsBreakdown: any;
|
|
131
139
|
average: any;
|
|
132
140
|
distribution: any;
|
|
@@ -154,6 +162,10 @@ declare const ciSurveyService: ({ strapi }: {
|
|
|
154
162
|
type: any;
|
|
155
163
|
title: any;
|
|
156
164
|
answeredCount: any;
|
|
165
|
+
scoredCount: any;
|
|
166
|
+
noOpinionCount: any;
|
|
167
|
+
noOpinionPercentage: any;
|
|
168
|
+
noOpinionLabels: any;
|
|
157
169
|
optionsBreakdown: any;
|
|
158
170
|
average: any;
|
|
159
171
|
distribution: any;
|
|
@@ -196,6 +208,7 @@ declare const ciSurveyService: ({ strapi }: {
|
|
|
196
208
|
};
|
|
197
209
|
questionStats: ({
|
|
198
210
|
answeredCount: number;
|
|
211
|
+
noOpinionCount: number;
|
|
199
212
|
optionsBreakdown: {
|
|
200
213
|
id: string;
|
|
201
214
|
labels: Record<string, string>;
|
|
@@ -215,6 +228,11 @@ declare const ciSurveyService: ({ strapi }: {
|
|
|
215
228
|
hasConditions: boolean;
|
|
216
229
|
} | {
|
|
217
230
|
answeredCount: number;
|
|
231
|
+
scoredCount: number;
|
|
232
|
+
allowNoOpinion: boolean;
|
|
233
|
+
noOpinionCount: number;
|
|
234
|
+
noOpinionPercentage: number;
|
|
235
|
+
noOpinionLabels: Record<string, string>;
|
|
218
236
|
min: number;
|
|
219
237
|
max: number;
|
|
220
238
|
lowLabel: string | Record<string, string>;
|
|
@@ -261,6 +279,11 @@ declare const ciSurveyService: ({ strapi }: {
|
|
|
261
279
|
hasConditions: boolean;
|
|
262
280
|
} | {
|
|
263
281
|
answeredCount: number;
|
|
282
|
+
rankedCount: number;
|
|
283
|
+
allowNoOpinion: boolean;
|
|
284
|
+
noOpinionCount: number;
|
|
285
|
+
noOpinionPercentage: number;
|
|
286
|
+
noOpinionLabels: Record<string, string>;
|
|
264
287
|
rankingBreakdown: {
|
|
265
288
|
id: string;
|
|
266
289
|
labels: Record<string, string>;
|
|
@@ -220,6 +220,10 @@ declare const _default: {
|
|
|
220
220
|
type: any;
|
|
221
221
|
title: any;
|
|
222
222
|
answeredCount: any;
|
|
223
|
+
scoredCount: any;
|
|
224
|
+
noOpinionCount: any;
|
|
225
|
+
noOpinionPercentage: any;
|
|
226
|
+
noOpinionLabels: any;
|
|
223
227
|
optionsBreakdown: any;
|
|
224
228
|
average: any;
|
|
225
229
|
distribution: any;
|
|
@@ -269,6 +273,10 @@ declare const _default: {
|
|
|
269
273
|
type: any;
|
|
270
274
|
title: any;
|
|
271
275
|
answeredCount: any;
|
|
276
|
+
scoredCount: any;
|
|
277
|
+
noOpinionCount: any;
|
|
278
|
+
noOpinionPercentage: any;
|
|
279
|
+
noOpinionLabels: any;
|
|
272
280
|
optionsBreakdown: any;
|
|
273
281
|
average: any;
|
|
274
282
|
distribution: any;
|
|
@@ -296,6 +304,10 @@ declare const _default: {
|
|
|
296
304
|
type: any;
|
|
297
305
|
title: any;
|
|
298
306
|
answeredCount: any;
|
|
307
|
+
scoredCount: any;
|
|
308
|
+
noOpinionCount: any;
|
|
309
|
+
noOpinionPercentage: any;
|
|
310
|
+
noOpinionLabels: any;
|
|
299
311
|
optionsBreakdown: any;
|
|
300
312
|
average: any;
|
|
301
313
|
distribution: any;
|
|
@@ -338,6 +350,7 @@ declare const _default: {
|
|
|
338
350
|
};
|
|
339
351
|
questionStats: ({
|
|
340
352
|
answeredCount: number;
|
|
353
|
+
noOpinionCount: number;
|
|
341
354
|
optionsBreakdown: {
|
|
342
355
|
id: string;
|
|
343
356
|
labels: Record<string, string>;
|
|
@@ -357,6 +370,11 @@ declare const _default: {
|
|
|
357
370
|
hasConditions: boolean;
|
|
358
371
|
} | {
|
|
359
372
|
answeredCount: number;
|
|
373
|
+
scoredCount: number;
|
|
374
|
+
allowNoOpinion: boolean;
|
|
375
|
+
noOpinionCount: number;
|
|
376
|
+
noOpinionPercentage: number;
|
|
377
|
+
noOpinionLabels: Record<string, string>;
|
|
360
378
|
min: number;
|
|
361
379
|
max: number;
|
|
362
380
|
lowLabel: string | Record<string, string>;
|
|
@@ -403,6 +421,11 @@ declare const _default: {
|
|
|
403
421
|
hasConditions: boolean;
|
|
404
422
|
} | {
|
|
405
423
|
answeredCount: number;
|
|
424
|
+
rankedCount: number;
|
|
425
|
+
allowNoOpinion: boolean;
|
|
426
|
+
noOpinionCount: number;
|
|
427
|
+
noOpinionPercentage: number;
|
|
428
|
+
noOpinionLabels: Record<string, string>;
|
|
406
429
|
rankingBreakdown: {
|
|
407
430
|
id: string;
|
|
408
431
|
labels: Record<string, string>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ValidationLocale } from './formValidator';
|
|
2
|
+
export declare const NO_OPINION_VALUE = "__na__";
|
|
3
|
+
export declare function resolveNoOpinionLabels(raw?: Record<string, string> | string): Record<string, string>;
|
|
2
4
|
export type CISurveyQuestionType = 'single_choice' | 'multiple_choice' | 'dropdown' | 'image_choice' | 'star_rating' | 'nps' | 'likert_scale' | 'matrix_single' | 'ranking' | 'short_text' | 'long_text' | 'statement' | 'consent';
|
|
3
5
|
export interface CISurveyOption {
|
|
4
6
|
id: string;
|
|
@@ -32,6 +34,8 @@ export interface CISurveyQuestion {
|
|
|
32
34
|
validation?: string;
|
|
33
35
|
allowOther?: boolean;
|
|
34
36
|
otherLabel?: Record<string, string> | string;
|
|
37
|
+
allowNoOpinion?: boolean;
|
|
38
|
+
noOpinionLabel?: Record<string, string> | string;
|
|
35
39
|
shuffleOptions?: boolean;
|
|
36
40
|
inline?: boolean;
|
|
37
41
|
minSelections?: number;
|
|
@@ -134,6 +138,7 @@ export declare function computeSurveyAnalytics(survey: CISurveyDefinition, rawRe
|
|
|
134
138
|
};
|
|
135
139
|
questionStats: ({
|
|
136
140
|
answeredCount: number;
|
|
141
|
+
noOpinionCount: number;
|
|
137
142
|
optionsBreakdown: {
|
|
138
143
|
id: string;
|
|
139
144
|
labels: Record<string, string>;
|
|
@@ -153,6 +158,11 @@ export declare function computeSurveyAnalytics(survey: CISurveyDefinition, rawRe
|
|
|
153
158
|
hasConditions: boolean;
|
|
154
159
|
} | {
|
|
155
160
|
answeredCount: number;
|
|
161
|
+
scoredCount: number;
|
|
162
|
+
allowNoOpinion: boolean;
|
|
163
|
+
noOpinionCount: number;
|
|
164
|
+
noOpinionPercentage: number;
|
|
165
|
+
noOpinionLabels: Record<string, string>;
|
|
156
166
|
min: number;
|
|
157
167
|
max: number;
|
|
158
168
|
lowLabel: string | Record<string, string>;
|
|
@@ -199,6 +209,11 @@ export declare function computeSurveyAnalytics(survey: CISurveyDefinition, rawRe
|
|
|
199
209
|
hasConditions: boolean;
|
|
200
210
|
} | {
|
|
201
211
|
answeredCount: number;
|
|
212
|
+
rankedCount: number;
|
|
213
|
+
allowNoOpinion: boolean;
|
|
214
|
+
noOpinionCount: number;
|
|
215
|
+
noOpinionPercentage: number;
|
|
216
|
+
noOpinionLabels: Record<string, string>;
|
|
202
217
|
rankingBreakdown: {
|
|
203
218
|
id: string;
|
|
204
219
|
labels: Record<string, string>;
|
|
@@ -245,6 +260,10 @@ export declare function computePublicSurveyResults(survey: CISurveyDefinition, r
|
|
|
245
260
|
type: any;
|
|
246
261
|
title: any;
|
|
247
262
|
answeredCount: any;
|
|
263
|
+
scoredCount: any;
|
|
264
|
+
noOpinionCount: any;
|
|
265
|
+
noOpinionPercentage: any;
|
|
266
|
+
noOpinionLabels: any;
|
|
248
267
|
optionsBreakdown: any;
|
|
249
268
|
average: any;
|
|
250
269
|
distribution: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ozguraltan/strapi-content-input",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Locomotive CMS ContentInput visual page/content builder ported to Strapi v5 as a native JSONB Custom Field plugin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ozgur Altan <ozguraltan05@gmail.com>",
|