@media-quest/builder 0.0.28 → 0.0.30

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.
@@ -776,6 +776,9 @@ interface SumScoreAnswer {
776
776
  }
777
777
 
778
778
  interface SumScore {
779
+ readonly sumScoreVariableId: SumScoreVariableID;
780
+ readonly name: string;
781
+ readonly description: string;
779
782
  sumScore: number;
780
783
  avg: number;
781
784
  useAvg: boolean;
@@ -1912,7 +1912,15 @@ var fromPage = (page, sumScoreVariables, pagePosition, modulePrefix) => {
1912
1912
  return { value: o.value, label: o.label };
1913
1913
  });
1914
1914
  const varId = modulePrefix + "_" + page.prefix;
1915
- const includedInSumScores = page.includedInSumScores.filter((a) => true);
1915
+ const pageIncludedInSumScoresArray = page.includedInSumScores ?? [];
1916
+ const includedInSumScores = [];
1917
+ pageIncludedInSumScoresArray.forEach((p) => {
1918
+ sumScoreVariables.forEach((ssv) => {
1919
+ if (p.sumScoreVariableId === ssv.id) {
1920
+ includedInSumScores.push(ssv);
1921
+ }
1922
+ });
1923
+ });
1916
1924
  const variable = {
1917
1925
  kind: "codebook-question-variable",
1918
1926
  label: page.mainText.text,
@@ -1922,7 +1930,7 @@ var fromPage = (page, sumScoreVariables, pagePosition, modulePrefix) => {
1922
1930
  modulePrefix,
1923
1931
  pagePosition,
1924
1932
  varId,
1925
- includedInSumScores: []
1933
+ includedInSumScores
1926
1934
  };
1927
1935
  variables.push(variable);
1928
1936
  return variables;
@@ -2663,6 +2671,9 @@ var calculate = (sumScoreVariable, basedOnVariables, answers) => {
2663
2671
  });
2664
2672
  const avg = sumScore / includedAnswerCount;
2665
2673
  const result = {
2674
+ sumScoreVariableId: sumScoreVariable.id,
2675
+ name: sumScoreVariable.name,
2676
+ description: sumScoreVariable.description,
2666
2677
  avg,
2667
2678
  useAvg,
2668
2679
  includedAnswerCount,