@doenet/v06-to-v07 0.7.26-dev.572 → 0.7.26-dev.573

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.
@@ -47356,7 +47356,7 @@ async function cidFromArrayBuffer(data) {
47356
47356
  await crypto.subtle.digest("SHA-256", new Uint8Array());
47357
47357
  digest = (data2) => crypto.subtle.digest("SHA-256", data2);
47358
47358
  } catch (e22) {
47359
- const sha256 = (await import("./sha256-8sXzDnE0-hQwEEL17-Br5jiMaf.js").then((n2) => n2.s)).default;
47359
+ const sha256 = (await import("./sha256-8sXzDnE0-BtProggv-BVCPcIg2.js").then((n2) => n2.s)).default;
47360
47360
  digest = (data2) => sha256(data2, {
47361
47361
  asBytes: true
47362
47362
  });
@@ -83793,6 +83793,97 @@ function aggregateCreditOverScoredDescendants(dependencyValues, variableName, cr
83793
83793
  }
83794
83794
  return totalWeight > 0 ? creditSum / totalWeight : creditWhenNothingScored;
83795
83795
  }
83796
+ function aggregateCreditForCheckWork(dependencyValues) {
83797
+ const descendants = dependencyValues.scoredDescendants;
83798
+ const totalWeight = descendants.reduce(
83799
+ (sum2, descendant) => sum2 + descendant.stateValues.weight,
83800
+ 0
83801
+ );
83802
+ const useUnitWeights = !(totalWeight > 0);
83803
+ const weightSum = useUnitWeights ? descendants.length : totalWeight;
83804
+ let creditSum = 0;
83805
+ for (const [ind, descendant] of descendants.entries()) {
83806
+ const { stateValues } = dependencyValues["creditForCheckWork" + ind];
83807
+ const credit = stateValues.creditAchievedForCheckWork ?? stateValues.creditAchieved;
83808
+ creditSum += credit * (useUnitWeights ? 1 : descendant.stateValues.weight);
83809
+ }
83810
+ return creditSum / weightSum;
83811
+ }
83812
+ function checkWorkCreditNeedsAggregating(stateValues, alwaysAggregate) {
83813
+ if (!stateValues.suppressAnswerSubmitButtons) {
83814
+ return false;
83815
+ }
83816
+ if (!alwaysAggregate && !stateValues.aggregateScores) {
83817
+ return false;
83818
+ }
83819
+ const descendants = stateValues.scoredDescendants;
83820
+ if (descendants.length === 0) {
83821
+ return false;
83822
+ }
83823
+ const anyPositiveWeight = descendants.some(
83824
+ (descendant) => descendant.stateValues.weight > 0
83825
+ );
83826
+ const anyAggregatingDescendant = descendants.some(
83827
+ // The same test `scoredDescendants` uses to tell a container it keeps
83828
+ // from a leaf it cannot look inside.
83829
+ (descendant) => descendant.stateValues.scoredDescendants !== void 0
83830
+ );
83831
+ return !anyPositiveWeight || anyAggregatingDescendant;
83832
+ }
83833
+ function returnCheckWorkCreditStateVariableDefinition({
83834
+ alwaysAggregate = false
83835
+ } = {}) {
83836
+ const stateVariablesDeterminingDependencies = [
83837
+ "suppressAnswerSubmitButtons",
83838
+ "scoredDescendants"
83839
+ ];
83840
+ if (!alwaysAggregate) {
83841
+ stateVariablesDeterminingDependencies.push("aggregateScores");
83842
+ }
83843
+ return {
83844
+ forRenderer: true,
83845
+ defaultValue: null,
83846
+ stateVariablesDeterminingDependencies,
83847
+ returnDependencies({ stateValues }) {
83848
+ if (!checkWorkCreditNeedsAggregating(stateValues, alwaysAggregate)) {
83849
+ return {};
83850
+ }
83851
+ const dependencies2 = {
83852
+ scoredDescendants: {
83853
+ dependencyType: "stateVariable",
83854
+ variableName: "scoredDescendants"
83855
+ }
83856
+ };
83857
+ for (const [
83858
+ ind,
83859
+ descendant
83860
+ ] of stateValues.scoredDescendants.entries()) {
83861
+ dependencies2["creditForCheckWork" + ind] = {
83862
+ dependencyType: "multipleStateVariables",
83863
+ componentIdx: descendant.componentIdx,
83864
+ variableNames: [
83865
+ "creditAchievedForCheckWork",
83866
+ "creditAchieved"
83867
+ ],
83868
+ // An `<answer>` has only the latter, which is what its
83869
+ // check-work credit would be anyway.
83870
+ variablesOptional: true
83871
+ };
83872
+ }
83873
+ return dependencies2;
83874
+ },
83875
+ definition({ dependencyValues }) {
83876
+ if (dependencyValues.scoredDescendants === void 0) {
83877
+ return { setValue: { creditAchievedForCheckWork: null } };
83878
+ }
83879
+ return {
83880
+ setValue: {
83881
+ creditAchievedForCheckWork: aggregateCreditForCheckWork(dependencyValues)
83882
+ }
83883
+ };
83884
+ }
83885
+ };
83886
+ }
83796
83887
  function returnScoredSectionAttributes() {
83797
83888
  return {
83798
83889
  aggregateScores: {
@@ -84247,6 +84338,7 @@ function returnScoredSectionStateVariableDefinition() {
84247
84338
  };
84248
84339
  }
84249
84340
  };
84341
+ stateVariableDefinitions.creditAchievedForCheckWork = returnCheckWorkCreditStateVariableDefinition();
84250
84342
  stateVariableDefinitions.creditAchievedIfSubmit = {
84251
84343
  defaultValue: 0,
84252
84344
  stateVariablesDeterminingDependencies: [
@@ -127384,6 +127476,11 @@ class Input extends InlineComponent {
127384
127476
  componentIdx: stateValues.sectionDeterminingColorCorrectness,
127385
127477
  variableNames: [
127386
127478
  "justSubmitted",
127479
+ // The section colors its inputs by the same credit
127480
+ // its button reports, so the two can never disagree;
127481
+ // it is `null` wherever the score already says it,
127482
+ // hence the fallback below.
127483
+ "creditAchievedForCheckWork",
127387
127484
  "creditAchieved",
127388
127485
  "showCorrectness",
127389
127486
  "colorCorrectness"
@@ -127526,7 +127623,7 @@ class Input extends InlineComponent {
127526
127623
  let creditAchieved = 0;
127527
127624
  const comp = dependencyValues.componentDeterminingDisplayedCorrectness;
127528
127625
  if (comp) {
127529
- const overallCredit = comp.stateValues.creditAchieved ?? 0;
127626
+ const overallCredit = comp.stateValues.creditAchievedForCheckWork ?? comp.stateValues.creditAchieved ?? 0;
127530
127627
  const creditAchievedPerInput = dependencyValues.answerCreditAchievedPerInput?.stateValues.creditAchievedPerInput ?? (dependencyValues.answerColoringState?.stateValues?.colorInputsSeparately ? dependencyValues.answerColoringState.stateValues.creditAchievedPerInput : void 0);
127531
127628
  if (comp.stateValues.colorInputsSeparately && creditAchievedPerInput) {
127532
127629
  const key = `${componentIdx}/${variableForImplicitProp}`;
@@ -133133,6 +133230,9 @@ class Document extends BaseComponent {
133133
133230
  return { setValue: { creditAchieved, percentCreditAchieved } };
133134
133231
  }
133135
133232
  };
133233
+ stateVariableDefinitions.creditAchievedForCheckWork = returnCheckWorkCreditStateVariableDefinition({
133234
+ alwaysAggregate: true
133235
+ });
133136
133236
  stateVariableDefinitions.creditAchievedIfSubmit = {
133137
133237
  defaultValue: 0,
133138
133238
  stateVariablesDeterminingDependencies: ["scoredDescendants"],
@@ -247744,4 +247844,4 @@ export {
247744
247844
  getDefaultExportFromCjs$1 as g,
247745
247845
  updateSyntaxFromV06toV07 as u
247746
247846
  };
247747
- //# sourceMappingURL=index-D-2i13ZI.js.map
247847
+ //# sourceMappingURL=index-4M4L_2sg.js.map