@doenet/assignment-viewer 0.1.0-alpha5 → 0.1.0-alpha6
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/dist/index.js +158 -63
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1686,7 +1686,6 @@ function generateNewSingleDocAttempt({
|
|
|
1686
1686
|
state,
|
|
1687
1687
|
numActivityVariants,
|
|
1688
1688
|
initialQuestionCounter,
|
|
1689
|
-
questionCounts,
|
|
1690
1689
|
parentAttempt
|
|
1691
1690
|
}) {
|
|
1692
1691
|
const previousVariants = state.previousVariants;
|
|
@@ -1706,7 +1705,7 @@ function generateNewSingleDocAttempt({
|
|
|
1706
1705
|
if (state.restrictToVariantSlice) {
|
|
1707
1706
|
selectedVariant = (selectedVariant - 1) * state.restrictToVariantSlice.numSlices + state.restrictToVariantSlice.idx;
|
|
1708
1707
|
}
|
|
1709
|
-
const finalQuestionCounter = initialQuestionCounter +
|
|
1708
|
+
const finalQuestionCounter = initialQuestionCounter + (state.source.isDescription ? 0 : 1);
|
|
1710
1709
|
const newState = {
|
|
1711
1710
|
...state,
|
|
1712
1711
|
creditAchieved: 0,
|
|
@@ -1836,7 +1835,6 @@ function generateNewSelectAttempt({
|
|
|
1836
1835
|
state,
|
|
1837
1836
|
numActivityVariants,
|
|
1838
1837
|
initialQuestionCounter,
|
|
1839
|
-
questionCounts,
|
|
1840
1838
|
parentAttempt
|
|
1841
1839
|
}) {
|
|
1842
1840
|
const source = state.source;
|
|
@@ -1928,7 +1926,6 @@ function generateNewSelectAttempt({
|
|
|
1928
1926
|
state: newActivityOptionStates[childIdx],
|
|
1929
1927
|
numActivityVariants,
|
|
1930
1928
|
initialQuestionCounter: questionCounter,
|
|
1931
|
-
questionCounts,
|
|
1932
1929
|
parentAttempt: state.attemptNumber + 1
|
|
1933
1930
|
});
|
|
1934
1931
|
questionCounter = endCounter;
|
|
@@ -1953,7 +1950,6 @@ function generateNewSingleDocAttemptForMultiSelect({
|
|
|
1953
1950
|
state,
|
|
1954
1951
|
numActivityVariants,
|
|
1955
1952
|
initialQuestionCounter,
|
|
1956
|
-
questionCounts,
|
|
1957
1953
|
parentAttempt,
|
|
1958
1954
|
childId
|
|
1959
1955
|
}) {
|
|
@@ -2002,7 +1998,6 @@ function generateNewSingleDocAttemptForMultiSelect({
|
|
|
2002
1998
|
state: newActivityOptionStates[selectedIdx],
|
|
2003
1999
|
numActivityVariants,
|
|
2004
2000
|
initialQuestionCounter,
|
|
2005
|
-
questionCounts,
|
|
2006
2001
|
parentAttempt: state.attemptNumber + 1
|
|
2007
2002
|
});
|
|
2008
2003
|
newActivityOptionStates[selectedIdx] = newChildState;
|
|
@@ -2171,7 +2166,6 @@ function generateNewSequenceAttempt({
|
|
|
2171
2166
|
state,
|
|
2172
2167
|
numActivityVariants,
|
|
2173
2168
|
initialQuestionCounter,
|
|
2174
|
-
questionCounts,
|
|
2175
2169
|
parentAttempt
|
|
2176
2170
|
}) {
|
|
2177
2171
|
var _a;
|
|
@@ -2219,7 +2213,6 @@ function generateNewSequenceAttempt({
|
|
|
2219
2213
|
state: originalState,
|
|
2220
2214
|
numActivityVariants,
|
|
2221
2215
|
initialQuestionCounter: questionCounter,
|
|
2222
|
-
questionCounts,
|
|
2223
2216
|
parentAttempt: state.attemptNumber + 1
|
|
2224
2217
|
});
|
|
2225
2218
|
questionCounter = endCounter;
|
|
@@ -3191,7 +3184,6 @@ function generateNewActivityAttempt({
|
|
|
3191
3184
|
state,
|
|
3192
3185
|
numActivityVariants,
|
|
3193
3186
|
initialQuestionCounter,
|
|
3194
|
-
questionCounts,
|
|
3195
3187
|
parentAttempt
|
|
3196
3188
|
}) {
|
|
3197
3189
|
switch (state.type) {
|
|
@@ -3200,7 +3192,6 @@ function generateNewActivityAttempt({
|
|
|
3200
3192
|
state,
|
|
3201
3193
|
numActivityVariants,
|
|
3202
3194
|
initialQuestionCounter,
|
|
3203
|
-
questionCounts,
|
|
3204
3195
|
parentAttempt
|
|
3205
3196
|
});
|
|
3206
3197
|
}
|
|
@@ -3209,7 +3200,6 @@ function generateNewActivityAttempt({
|
|
|
3209
3200
|
state,
|
|
3210
3201
|
numActivityVariants,
|
|
3211
3202
|
initialQuestionCounter,
|
|
3212
|
-
questionCounts,
|
|
3213
3203
|
parentAttempt
|
|
3214
3204
|
});
|
|
3215
3205
|
}
|
|
@@ -3218,7 +3208,6 @@ function generateNewActivityAttempt({
|
|
|
3218
3208
|
state,
|
|
3219
3209
|
numActivityVariants,
|
|
3220
3210
|
initialQuestionCounter,
|
|
3221
|
-
questionCounts,
|
|
3222
3211
|
parentAttempt
|
|
3223
3212
|
});
|
|
3224
3213
|
}
|
|
@@ -3229,8 +3218,7 @@ function generateNewSingleDocSubAttempt({
|
|
|
3229
3218
|
singleDocId,
|
|
3230
3219
|
state,
|
|
3231
3220
|
numActivityVariants,
|
|
3232
|
-
initialQuestionCounter
|
|
3233
|
-
questionCounts
|
|
3221
|
+
initialQuestionCounter
|
|
3234
3222
|
}) {
|
|
3235
3223
|
if (singleDocId === state.id) {
|
|
3236
3224
|
throw Error(
|
|
@@ -3256,7 +3244,6 @@ function generateNewSingleDocSubAttempt({
|
|
|
3256
3244
|
state: parentState,
|
|
3257
3245
|
numActivityVariants,
|
|
3258
3246
|
initialQuestionCounter,
|
|
3259
|
-
questionCounts,
|
|
3260
3247
|
parentAttempt: grandParentAttempt,
|
|
3261
3248
|
childId: singleDocId
|
|
3262
3249
|
}));
|
|
@@ -3265,7 +3252,6 @@ function generateNewSingleDocSubAttempt({
|
|
|
3265
3252
|
state: parentState,
|
|
3266
3253
|
numActivityVariants,
|
|
3267
3254
|
initialQuestionCounter,
|
|
3268
|
-
questionCounts,
|
|
3269
3255
|
parentAttempt: grandParentAttempt
|
|
3270
3256
|
}));
|
|
3271
3257
|
}
|
|
@@ -3279,7 +3265,6 @@ function generateNewSingleDocSubAttempt({
|
|
|
3279
3265
|
state: allStates[singleDocId],
|
|
3280
3266
|
numActivityVariants,
|
|
3281
3267
|
initialQuestionCounter,
|
|
3282
|
-
questionCounts,
|
|
3283
3268
|
parentAttempt: parentState.attemptNumber
|
|
3284
3269
|
});
|
|
3285
3270
|
allStates[singleDocId] = newSubActivityState;
|
|
@@ -3429,27 +3414,22 @@ function validateIds(source) {
|
|
|
3429
3414
|
function gatherDocumentStructure(source) {
|
|
3430
3415
|
if (source.type === "singleDoc") {
|
|
3431
3416
|
return {
|
|
3432
|
-
numActivityVariants: { [source.id]: source.numVariants ?? 1 }
|
|
3433
|
-
questionCounts: {
|
|
3434
|
-
[source.id]: source.baseComponentCounts ? (source.baseComponentCounts.question ?? 0) + (source.baseComponentCounts.problem ?? 0) + (source.baseComponentCounts.exercise ?? 0) : 1
|
|
3435
|
-
}
|
|
3417
|
+
numActivityVariants: { [source.id]: source.numVariants ?? 1 }
|
|
3436
3418
|
};
|
|
3437
3419
|
} else {
|
|
3438
3420
|
const numActivityVariants = {};
|
|
3439
|
-
const questionCounts = {};
|
|
3440
3421
|
for (const item of source.items) {
|
|
3441
3422
|
const res = gatherDocumentStructure(item);
|
|
3442
3423
|
Object.assign(numActivityVariants, res.numActivityVariants);
|
|
3443
|
-
Object.assign(questionCounts, res.questionCounts);
|
|
3444
3424
|
}
|
|
3445
|
-
return { numActivityVariants
|
|
3425
|
+
return { numActivityVariants };
|
|
3446
3426
|
}
|
|
3447
3427
|
}
|
|
3448
3428
|
function validateStateAndSource(state, source) {
|
|
3449
3429
|
if (!isExportedActivityState(state) || !isActivitySource(source)) {
|
|
3450
3430
|
return false;
|
|
3451
3431
|
}
|
|
3452
|
-
const sourceHash =
|
|
3432
|
+
const sourceHash = createSourceHash(source);
|
|
3453
3433
|
return state.sourceHash === sourceHash;
|
|
3454
3434
|
}
|
|
3455
3435
|
function gatherStates(state) {
|
|
@@ -3523,6 +3503,22 @@ function propagateStateChangeToRoot({
|
|
|
3523
3503
|
id: newParentState.id
|
|
3524
3504
|
});
|
|
3525
3505
|
}
|
|
3506
|
+
function removeVersionFromSource(source) {
|
|
3507
|
+
if (source.type === "singleDoc") {
|
|
3508
|
+
return {
|
|
3509
|
+
...source,
|
|
3510
|
+
version: ""
|
|
3511
|
+
};
|
|
3512
|
+
} else {
|
|
3513
|
+
return {
|
|
3514
|
+
...source,
|
|
3515
|
+
items: source.items.map(removeVersionFromSource)
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
function createSourceHash(source) {
|
|
3520
|
+
return hash(removeVersionFromSource(source));
|
|
3521
|
+
}
|
|
3526
3522
|
function isSingleDocReportStateMessage(obj) {
|
|
3527
3523
|
const typeObj = obj;
|
|
3528
3524
|
return (
|
|
@@ -3702,7 +3698,8 @@ function SelectActivity({
|
|
|
3702
3698
|
reportVisibility = false,
|
|
3703
3699
|
reportVisibilityCallback,
|
|
3704
3700
|
itemAttemptNumbers,
|
|
3705
|
-
itemSequence
|
|
3701
|
+
itemSequence,
|
|
3702
|
+
itemWord
|
|
3706
3703
|
}) {
|
|
3707
3704
|
const selectedActivities = [];
|
|
3708
3705
|
const selectedIds = [];
|
|
@@ -3733,7 +3730,8 @@ function SelectActivity({
|
|
|
3733
3730
|
reportVisibility,
|
|
3734
3731
|
reportVisibilityCallback,
|
|
3735
3732
|
itemAttemptNumbers,
|
|
3736
|
-
itemSequence
|
|
3733
|
+
itemSequence,
|
|
3734
|
+
itemWord
|
|
3737
3735
|
},
|
|
3738
3736
|
activity.id
|
|
3739
3737
|
)
|
|
@@ -3765,7 +3763,8 @@ function SequenceActivity({
|
|
|
3765
3763
|
reportVisibility = false,
|
|
3766
3764
|
reportVisibilityCallback,
|
|
3767
3765
|
itemAttemptNumbers,
|
|
3768
|
-
itemSequence
|
|
3766
|
+
itemSequence,
|
|
3767
|
+
itemWord
|
|
3769
3768
|
}) {
|
|
3770
3769
|
const activityList = [];
|
|
3771
3770
|
for (const activity of state.orderedChildren) {
|
|
@@ -3795,7 +3794,8 @@ function SequenceActivity({
|
|
|
3795
3794
|
reportVisibility,
|
|
3796
3795
|
reportVisibilityCallback,
|
|
3797
3796
|
itemAttemptNumbers,
|
|
3798
|
-
itemSequence
|
|
3797
|
+
itemSequence,
|
|
3798
|
+
itemWord
|
|
3799
3799
|
},
|
|
3800
3800
|
activity.id
|
|
3801
3801
|
)
|
|
@@ -53268,7 +53268,7 @@ function ExternalVirtualKeyboard() {
|
|
|
53268
53268
|
}
|
|
53269
53269
|
);
|
|
53270
53270
|
}
|
|
53271
|
-
const version = "0.7.0-
|
|
53271
|
+
const version = "0.7.0-alpha33";
|
|
53272
53272
|
const latestDoenetmlVersion = version;
|
|
53273
53273
|
function DoenetViewer({
|
|
53274
53274
|
doenetML,
|
|
@@ -53430,7 +53430,8 @@ function SingleDocActivity({
|
|
|
53430
53430
|
reportVisibility = false,
|
|
53431
53431
|
reportVisibilityCallback,
|
|
53432
53432
|
itemAttemptNumbers,
|
|
53433
|
-
itemSequence
|
|
53433
|
+
itemSequence,
|
|
53434
|
+
itemWord
|
|
53434
53435
|
}) {
|
|
53435
53436
|
const [rendered, setRendered] = useState$3(false);
|
|
53436
53437
|
const [attemptNumber, setAttemptNumber] = useState$3(state.attemptNumber);
|
|
@@ -53476,6 +53477,8 @@ function SingleDocActivity({
|
|
|
53476
53477
|
const showAttemptButton = allowItemAttemptButtons && generateNewItemAttempt !== void 0 && !source.isDescription && maxAttemptsAllowed !== 1;
|
|
53477
53478
|
const render3 = checkRender(state);
|
|
53478
53479
|
const hidden = checkHidden(state);
|
|
53480
|
+
const newAttemptsLeft = Math.max(maxAttemptsAllowed - itemAttemptNumber, 0);
|
|
53481
|
+
const attemptButtonDisabled = maxAttemptsAllowed > 0 && newAttemptsLeft <= 0;
|
|
53479
53482
|
return /* @__PURE__ */ jsxRuntimeExports$1.jsx("div", { ref, children: /* @__PURE__ */ jsxRuntimeExports$1.jsxs("div", { hidden: !render3 || hidden, style: { minHeight: "100px" }, children: [
|
|
53480
53483
|
/* @__PURE__ */ jsxRuntimeExports$1.jsx(
|
|
53481
53484
|
DoenetViewer,
|
|
@@ -53517,17 +53520,21 @@ function SingleDocActivity({
|
|
|
53517
53520
|
state.initialQuestionCounter
|
|
53518
53521
|
);
|
|
53519
53522
|
},
|
|
53520
|
-
disabled:
|
|
53523
|
+
disabled: attemptButtonDisabled,
|
|
53521
53524
|
style: {
|
|
53522
53525
|
marginLeft: "20px",
|
|
53523
|
-
backgroundColor: "
|
|
53526
|
+
backgroundColor: "rgb(237, 242, 247)",
|
|
53527
|
+
opacity: attemptButtonDisabled ? 0.4 : "inherit",
|
|
53524
53528
|
borderRadius: "10px",
|
|
53525
|
-
padding: "5px 20px"
|
|
53529
|
+
padding: "5px 20px",
|
|
53530
|
+
cursor: attemptButtonDisabled ? "not-allowed" : "pointer"
|
|
53526
53531
|
},
|
|
53527
53532
|
children: [
|
|
53528
|
-
"New
|
|
53533
|
+
"New ",
|
|
53534
|
+
itemWord,
|
|
53535
|
+
" attempt",
|
|
53529
53536
|
" ",
|
|
53530
|
-
maxAttemptsAllowed > 0 ? `(${
|
|
53537
|
+
maxAttemptsAllowed > 0 ? `(${newAttemptsLeft.toString()} left)` : null
|
|
53531
53538
|
]
|
|
53532
53539
|
}
|
|
53533
53540
|
) : null
|
|
@@ -53556,7 +53563,8 @@ function Activity({
|
|
|
53556
53563
|
reportVisibility = false,
|
|
53557
53564
|
reportVisibilityCallback,
|
|
53558
53565
|
itemAttemptNumbers,
|
|
53559
|
-
itemSequence
|
|
53566
|
+
itemSequence,
|
|
53567
|
+
itemWord
|
|
53560
53568
|
}) {
|
|
53561
53569
|
switch (state.type) {
|
|
53562
53570
|
case "singleDoc": {
|
|
@@ -53585,7 +53593,8 @@ function Activity({
|
|
|
53585
53593
|
reportVisibility,
|
|
53586
53594
|
reportVisibilityCallback,
|
|
53587
53595
|
itemAttemptNumbers,
|
|
53588
|
-
itemSequence
|
|
53596
|
+
itemSequence,
|
|
53597
|
+
itemWord
|
|
53589
53598
|
}
|
|
53590
53599
|
);
|
|
53591
53600
|
}
|
|
@@ -53615,7 +53624,8 @@ function Activity({
|
|
|
53615
53624
|
reportVisibility,
|
|
53616
53625
|
reportVisibilityCallback,
|
|
53617
53626
|
itemAttemptNumbers,
|
|
53618
|
-
itemSequence
|
|
53627
|
+
itemSequence,
|
|
53628
|
+
itemWord
|
|
53619
53629
|
}
|
|
53620
53630
|
);
|
|
53621
53631
|
}
|
|
@@ -53645,7 +53655,8 @@ function Activity({
|
|
|
53645
53655
|
reportVisibility,
|
|
53646
53656
|
reportVisibilityCallback,
|
|
53647
53657
|
itemAttemptNumbers,
|
|
53648
|
-
itemSequence
|
|
53658
|
+
itemSequence,
|
|
53659
|
+
itemWord
|
|
53649
53660
|
}
|
|
53650
53661
|
);
|
|
53651
53662
|
}
|
|
@@ -53687,7 +53698,6 @@ function activityDoenetStateReducer(state, action) {
|
|
|
53687
53698
|
state: activityState,
|
|
53688
53699
|
numActivityVariants: action.numActivityVariants,
|
|
53689
53700
|
initialQuestionCounter: action.initialQuestionCounter,
|
|
53690
|
-
questionCounts: action.questionCounts,
|
|
53691
53701
|
parentAttempt: 1
|
|
53692
53702
|
});
|
|
53693
53703
|
const newItemAttemptNumbers = state.itemAttemptNumbers.map(() => 1);
|
|
@@ -53724,8 +53734,7 @@ function activityDoenetStateReducer(state, action) {
|
|
|
53724
53734
|
singleDocId: action.docId,
|
|
53725
53735
|
state: activityState,
|
|
53726
53736
|
numActivityVariants: action.numActivityVariants,
|
|
53727
|
-
initialQuestionCounter: action.initialQuestionCounter
|
|
53728
|
-
questionCounts: action.questionCounts
|
|
53737
|
+
initialQuestionCounter: action.initialQuestionCounter
|
|
53729
53738
|
});
|
|
53730
53739
|
const newDoenetMLStates = [...state.doenetStates];
|
|
53731
53740
|
newDoenetMLStates[action.doenetStateIdx] = null;
|
|
@@ -53833,15 +53842,16 @@ function Viewer({
|
|
|
53833
53842
|
darkMode = "light",
|
|
53834
53843
|
showAnswerResponseMenu = false,
|
|
53835
53844
|
answerResponseCountsByItem = [],
|
|
53836
|
-
showTitle = true
|
|
53845
|
+
showTitle = true,
|
|
53846
|
+
itemWord = "item"
|
|
53837
53847
|
}) {
|
|
53838
53848
|
const [errMsg, setErrMsg] = useState$3(null);
|
|
53839
53849
|
const initialPass = useRef$6(true);
|
|
53840
|
-
const { numActivityVariants,
|
|
53850
|
+
const { numActivityVariants, sourceHash, numItems } = useMemo$4(() => {
|
|
53841
53851
|
try {
|
|
53842
53852
|
validateIds(source);
|
|
53843
53853
|
const docStructure = gatherDocumentStructure(source);
|
|
53844
|
-
const sourceHash2 =
|
|
53854
|
+
const sourceHash2 = createSourceHash(source);
|
|
53845
53855
|
const numItems2 = getNumItems(source);
|
|
53846
53856
|
return { ...docStructure, sourceHash: sourceHash2, numItems: numItems2 };
|
|
53847
53857
|
} catch (e2) {
|
|
@@ -53849,7 +53859,6 @@ function Viewer({
|
|
|
53849
53859
|
setErrMsg(`Error in activity source: ${message}`);
|
|
53850
53860
|
return {
|
|
53851
53861
|
numActivityVariants: {},
|
|
53852
|
-
questionCounts: {},
|
|
53853
53862
|
sourceHash: "",
|
|
53854
53863
|
numItems: 0
|
|
53855
53864
|
};
|
|
@@ -53872,6 +53881,9 @@ function Viewer({
|
|
|
53872
53881
|
const [itemsRendered, setItemsRendered] = useState$3([]);
|
|
53873
53882
|
const [itemsToRender, setItemsToRender] = useState$3([]);
|
|
53874
53883
|
const [itemsVisible, setItemsVisible] = useState$3([]);
|
|
53884
|
+
const [newAttemptNum, setNewAttemptNum] = useState$3(0);
|
|
53885
|
+
const dialogRef = useRef$6(null);
|
|
53886
|
+
const newItemAttemptInfo = useRef$6({ id: "", initialQuestionCounter: 0 });
|
|
53875
53887
|
const attemptNumber = activityState.attemptNumber;
|
|
53876
53888
|
function addItemToRender(id2) {
|
|
53877
53889
|
if (!itemsToRender.includes(id2)) {
|
|
@@ -53997,7 +54009,6 @@ function Viewer({
|
|
|
53997
54009
|
type: "generateNewActivityAttempt",
|
|
53998
54010
|
numActivityVariants,
|
|
53999
54011
|
initialQuestionCounter: 1,
|
|
54000
|
-
questionCounts,
|
|
54001
54012
|
allowSaveState: flags.allowSaveState,
|
|
54002
54013
|
baseId: activityId,
|
|
54003
54014
|
sourceHash
|
|
@@ -54044,7 +54055,6 @@ function Viewer({
|
|
|
54044
54055
|
userId,
|
|
54045
54056
|
source,
|
|
54046
54057
|
numActivityVariants,
|
|
54047
|
-
questionCounts,
|
|
54048
54058
|
sourceHash
|
|
54049
54059
|
]);
|
|
54050
54060
|
function clickNext() {
|
|
@@ -54068,7 +54078,14 @@ function Viewer({
|
|
|
54068
54078
|
});
|
|
54069
54079
|
}
|
|
54070
54080
|
}
|
|
54071
|
-
function
|
|
54081
|
+
function generateNewItemAttemptPrompt(id2, initialQuestionCounter) {
|
|
54082
|
+
var _a;
|
|
54083
|
+
newItemAttemptInfo.current = { id: id2, initialQuestionCounter };
|
|
54084
|
+
setNewAttemptNum((itemSequence.indexOf(id2) ?? 0) + 1);
|
|
54085
|
+
(_a = dialogRef.current) == null ? void 0 : _a.showModal();
|
|
54086
|
+
}
|
|
54087
|
+
function generateNewItemAttempt() {
|
|
54088
|
+
const { id: id2, initialQuestionCounter } = newItemAttemptInfo.current;
|
|
54072
54089
|
activityDoenetStateDispatch({
|
|
54073
54090
|
type: "generateSingleDocSubActivityAttempt",
|
|
54074
54091
|
docId: id2,
|
|
@@ -54076,7 +54093,6 @@ function Viewer({
|
|
|
54076
54093
|
itemSequence,
|
|
54077
54094
|
numActivityVariants,
|
|
54078
54095
|
initialQuestionCounter,
|
|
54079
|
-
questionCounts,
|
|
54080
54096
|
allowSaveState: flags.allowSaveState,
|
|
54081
54097
|
baseId: activityId,
|
|
54082
54098
|
sourceHash
|
|
@@ -54135,17 +54151,17 @@ function Viewer({
|
|
|
54135
54151
|
});
|
|
54136
54152
|
}
|
|
54137
54153
|
function generateActivityAttempt() {
|
|
54154
|
+
setItemsRendered([]);
|
|
54155
|
+
setItemsToRender([]);
|
|
54156
|
+
setCurrentItemIdx(0);
|
|
54138
54157
|
activityDoenetStateDispatch({
|
|
54139
54158
|
type: "generateNewActivityAttempt",
|
|
54140
54159
|
numActivityVariants,
|
|
54141
54160
|
initialQuestionCounter: 1,
|
|
54142
|
-
questionCounts,
|
|
54143
54161
|
allowSaveState: flags.allowSaveState,
|
|
54144
54162
|
baseId: activityId,
|
|
54145
54163
|
sourceHash
|
|
54146
54164
|
});
|
|
54147
|
-
setItemsRendered([]);
|
|
54148
|
-
setCurrentItemIdx(0);
|
|
54149
54165
|
}
|
|
54150
54166
|
if (errMsg !== null) {
|
|
54151
54167
|
const errorIcon = /* @__PURE__ */ jsxRuntimeExports$1.jsx("span", { style: { fontSize: "1em", color: "#C1292E" }, children: /* @__PURE__ */ jsxRuntimeExports$1.jsx(MdError, {}) });
|
|
@@ -54187,7 +54203,77 @@ function Viewer({
|
|
|
54187
54203
|
}
|
|
54188
54204
|
}
|
|
54189
54205
|
}
|
|
54206
|
+
const activityAttemptsLeft = Math.max(
|
|
54207
|
+
maxAttemptsAllowed - attemptNumber,
|
|
54208
|
+
0
|
|
54209
|
+
);
|
|
54210
|
+
const newAttemptsLeft = newAttemptNum === 0 ? activityAttemptsLeft : Math.max(
|
|
54211
|
+
maxAttemptsAllowed - activityDoenetState.itemAttemptNumbers[newAttemptNum - 1],
|
|
54212
|
+
0
|
|
54213
|
+
);
|
|
54214
|
+
const newAttemptDisabled = numItems === 0 || maxAttemptsAllowed > 0 && activityAttemptsLeft <= 0;
|
|
54190
54215
|
return /* @__PURE__ */ jsxRuntimeExports$1.jsxs("div", { children: [
|
|
54216
|
+
/* @__PURE__ */ jsxRuntimeExports$1.jsxs("dialog", { ref: dialogRef, children: [
|
|
54217
|
+
/* @__PURE__ */ jsxRuntimeExports$1.jsxs("h3", { children: [
|
|
54218
|
+
"Create new attempt of",
|
|
54219
|
+
" ",
|
|
54220
|
+
newAttemptNum === 0 ? "the entire activity" : `${itemWord} ${newAttemptNum.toString()}`,
|
|
54221
|
+
"?"
|
|
54222
|
+
] }),
|
|
54223
|
+
/* @__PURE__ */ jsxRuntimeExports$1.jsxs("p", { children: [
|
|
54224
|
+
"Creating a new attempt will generate",
|
|
54225
|
+
" ",
|
|
54226
|
+
newAttemptNum === 0 ? `new versions of all ${itemWord}s so that you can start again at the beginning.` : `a new version of ${itemWord} ${newAttemptNum.toString()} so that you can start that ${itemWord} again.`
|
|
54227
|
+
] }),
|
|
54228
|
+
maxAttemptsAllowed > 0 ? /* @__PURE__ */ jsxRuntimeExports$1.jsxs("p", { children: [
|
|
54229
|
+
"You can create a new attempt",
|
|
54230
|
+
" ",
|
|
54231
|
+
newAttemptsLeft.toString(),
|
|
54232
|
+
" more time",
|
|
54233
|
+
newAttemptsLeft > 1 ? "s" : "",
|
|
54234
|
+
"."
|
|
54235
|
+
] }) : null,
|
|
54236
|
+
/* @__PURE__ */ jsxRuntimeExports$1.jsxs("p", { style: { marginTop: "30px" }, children: [
|
|
54237
|
+
/* @__PURE__ */ jsxRuntimeExports$1.jsx(
|
|
54238
|
+
"button",
|
|
54239
|
+
{
|
|
54240
|
+
autoFocus: true,
|
|
54241
|
+
onClick: () => {
|
|
54242
|
+
var _a;
|
|
54243
|
+
(_a = dialogRef.current) == null ? void 0 : _a.close();
|
|
54244
|
+
},
|
|
54245
|
+
style: {
|
|
54246
|
+
marginLeft: "30px",
|
|
54247
|
+
backgroundColor: "lightgray",
|
|
54248
|
+
borderRadius: "10px",
|
|
54249
|
+
padding: "5px 20px"
|
|
54250
|
+
},
|
|
54251
|
+
children: "Cancel"
|
|
54252
|
+
}
|
|
54253
|
+
),
|
|
54254
|
+
/* @__PURE__ */ jsxRuntimeExports$1.jsx(
|
|
54255
|
+
"button",
|
|
54256
|
+
{
|
|
54257
|
+
onClick: () => {
|
|
54258
|
+
var _a;
|
|
54259
|
+
if (newAttemptNum === 0) {
|
|
54260
|
+
generateActivityAttempt();
|
|
54261
|
+
} else {
|
|
54262
|
+
generateNewItemAttempt();
|
|
54263
|
+
}
|
|
54264
|
+
(_a = dialogRef.current) == null ? void 0 : _a.close();
|
|
54265
|
+
},
|
|
54266
|
+
style: {
|
|
54267
|
+
marginLeft: "30px",
|
|
54268
|
+
backgroundColor: "lightgray",
|
|
54269
|
+
borderRadius: "10px",
|
|
54270
|
+
padding: "5px 20px"
|
|
54271
|
+
},
|
|
54272
|
+
children: "Create new attempt"
|
|
54273
|
+
}
|
|
54274
|
+
)
|
|
54275
|
+
] })
|
|
54276
|
+
] }),
|
|
54191
54277
|
showTitle ? /* @__PURE__ */ jsxRuntimeExports$1.jsx("h2", { style: { marginLeft: "20px" }, children: source.title }) : null,
|
|
54192
54278
|
/* @__PURE__ */ jsxRuntimeExports$1.jsx("div", { style: { marginTop: "5px" }, children: /* @__PURE__ */ jsxRuntimeExports$1.jsxs("div", { children: [
|
|
54193
54279
|
/* @__PURE__ */ jsxRuntimeExports$1.jsxs("span", { hidden: !paginate, children: [
|
|
@@ -54228,18 +54314,24 @@ function Viewer({
|
|
|
54228
54314
|
activityLevelAttempts && maxAttemptsAllowed !== 1 ? /* @__PURE__ */ jsxRuntimeExports$1.jsxs(
|
|
54229
54315
|
"button",
|
|
54230
54316
|
{
|
|
54231
|
-
onClick:
|
|
54232
|
-
|
|
54317
|
+
onClick: () => {
|
|
54318
|
+
var _a;
|
|
54319
|
+
setNewAttemptNum(0);
|
|
54320
|
+
(_a = dialogRef.current) == null ? void 0 : _a.showModal();
|
|
54321
|
+
},
|
|
54322
|
+
disabled: newAttemptDisabled,
|
|
54233
54323
|
style: {
|
|
54234
54324
|
marginLeft: "30px",
|
|
54235
|
-
backgroundColor: "
|
|
54325
|
+
backgroundColor: "rgb(237, 242, 247)",
|
|
54326
|
+
opacity: newAttemptDisabled ? 0.4 : "inherit",
|
|
54236
54327
|
borderRadius: "10px",
|
|
54237
|
-
padding: "5px 20px"
|
|
54328
|
+
padding: "5px 20px",
|
|
54329
|
+
cursor: newAttemptDisabled ? "not-allowed" : "pointer"
|
|
54238
54330
|
},
|
|
54239
54331
|
children: [
|
|
54240
54332
|
"New attempt",
|
|
54241
54333
|
" ",
|
|
54242
|
-
maxAttemptsAllowed > 0 ? `(${
|
|
54334
|
+
maxAttemptsAllowed > 0 ? `(${activityAttemptsLeft.toString()} left)` : null
|
|
54243
54335
|
]
|
|
54244
54336
|
}
|
|
54245
54337
|
) : null
|
|
@@ -54272,12 +54364,13 @@ function Viewer({
|
|
|
54272
54364
|
checkRender,
|
|
54273
54365
|
checkHidden,
|
|
54274
54366
|
allowItemAttemptButtons: itemLevelAttempts,
|
|
54275
|
-
generateNewItemAttempt,
|
|
54367
|
+
generateNewItemAttempt: generateNewItemAttemptPrompt,
|
|
54276
54368
|
hasRenderedCallback,
|
|
54277
54369
|
reportVisibility: !paginate,
|
|
54278
54370
|
reportVisibilityCallback,
|
|
54279
54371
|
itemAttemptNumbers: activityDoenetState.itemAttemptNumbers,
|
|
54280
|
-
itemSequence
|
|
54372
|
+
itemSequence,
|
|
54373
|
+
itemWord
|
|
54281
54374
|
}
|
|
54282
54375
|
)
|
|
54283
54376
|
] });
|
|
@@ -54318,7 +54411,8 @@ function ActivityViewer({
|
|
|
54318
54411
|
showAnswerResponseMenu = false,
|
|
54319
54412
|
answerResponseCountsByItem = [],
|
|
54320
54413
|
includeVariantSelector: _includeVariantSelector = false,
|
|
54321
|
-
showTitle = true
|
|
54414
|
+
showTitle = true,
|
|
54415
|
+
itemWord = "item"
|
|
54322
54416
|
}) {
|
|
54323
54417
|
const [initialVariantIndex, setInitialVariantIndex] = useState$3(null);
|
|
54324
54418
|
const thisPropSet = {
|
|
@@ -54372,7 +54466,8 @@ function ActivityViewer({
|
|
|
54372
54466
|
darkMode,
|
|
54373
54467
|
showAnswerResponseMenu,
|
|
54374
54468
|
answerResponseCountsByItem,
|
|
54375
|
-
showTitle
|
|
54469
|
+
showTitle,
|
|
54470
|
+
itemWord
|
|
54376
54471
|
}
|
|
54377
54472
|
) });
|
|
54378
54473
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@doenet/assignment-viewer",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "View assignments from questions written in DoenetML",
|
|
5
|
-
"version": "0.1.0-
|
|
5
|
+
"version": "0.1.0-alpha6",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
7
7
|
"homepage": "https://github.com/Doenet/assignment-viewer#readme",
|
|
8
8
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react-dom": "^18.3.1"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@doenet/doenetml-iframe": "^0.7.0-
|
|
37
|
+
"@doenet/doenetml-iframe": "^0.7.0-alpha33",
|
|
38
38
|
"nanoid": "^5.0.9",
|
|
39
39
|
"object-hash": "^3.0.0",
|
|
40
40
|
"react-icons": "^5.4.0",
|