Skip to content

Commit c15df44

Browse files
committed
feat: unlock first hint with meta
1 parent b20d64f commit c15df44

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/ProblemLayout/HintSystem.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ class HintSystem extends React.Component {
2323
subHintsFinished.push(new Array((this.props.hints[i].subHints !== undefined ? this.props.hints[i].subHints.length : 0)).fill(0));
2424
}
2525

26-
this.giveStuFeedback = props.giveStuFeedback
26+
this.giveStuFeedback = props.giveStuFeedback;
27+
this.unlockFirstHint = props.unlockFirstHint;
2728
this.state = {
2829
latestStep: 0,
29-
currentExpanded: 0,
30+
currentExpanded: this.unlockFirstHint ? 0 : -1,
3031
hintAnswer: "",
3132
showSubHints: new Array(this.props.hints.length).fill(false),
3233
subHintsFinished: subHintsFinished
3334
}
34-
if (this.props.hintStatus.length > 0) {
35+
if (this.unlockFirstHint && this.props.hintStatus.length > 0) {
3536
this.props.unlockHint(0, this.props.hints[0].type);
3637
}
3738
}
@@ -153,6 +154,7 @@ class HintSystem extends React.Component {
153154
<ErrorBoundary componentName={"SubHintSystem"}>
154155
<SubHintSystem
155156
giveStuFeedback={this.giveStuFeedback}
157+
unlockFirstHint={this.unlockFirstHint}
156158
problemID={problemID}
157159
hints={hint.subHints}
158160
unlockHint={this.unlockSubHint}

src/ProblemLayout/Problem.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ class Problem extends React.Component {
4545
const giveStuFeedback = this.props.lesson?.giveStuFeedback
4646
const giveStuHints = this.props.lesson?.giveStuHints
4747
const doMasteryUpdate = this.props.lesson?.doMasteryUpdate
48+
const unlockFirstHint = this.props.lesson?.unlockFirstHint
4849
this.giveStuFeedback = giveStuFeedback == null || giveStuFeedback
4950
this.giveStuHints = giveStuHints == null || giveStuHints
5051
this.doMasteryUpdate = doMasteryUpdate == null || doMasteryUpdate
52+
this.unlockFirstHint = unlockFirstHint != null && unlockFirstHint
5153

5254
this.state = {
5355
problem: this.props.problem,
@@ -85,7 +87,7 @@ class Problem extends React.Component {
8587
<ProblemCard problemID={problem.id} step={step} index={index} answerMade={this.answerMade}
8688
seed={this.props.seed} problemVars={this.props.problem.variabilization}
8789
lesson={problem.lesson} courseName={problem.courseName} giveStuFeedback={this.giveStuFeedback}
88-
giveStuHints={this.giveStuHints}
90+
giveStuHints={this.giveStuHints} unlockFirstHint={this.unlockFirstHint}
8991
/>
9092
</Element>
9193
})

src/ProblemLayout/ProblemCard.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ class ProblemCard extends React.Component {
3131
//console.log("Reconstructing");
3232
this.step = props.step;
3333
this.index = props.index;
34-
this.giveStuFeedback = props.giveStuFeedback
35-
this.giveStuHints = props.giveStuHints
36-
this.allowRetry = this.giveStuFeedback
37-
this.showHints = this.giveStuHints == null || this.giveStuHints
38-
this.showCorrectness = this.giveStuFeedback
39-
console.debug('this.step', this.step, 'showHints', this.showHints, 'hintPathway', context.hintPathway)
34+
this.giveStuFeedback = props.giveStuFeedback;
35+
this.giveStuHints = props.giveStuHints;
36+
this.unlockFirstHint = props.unlockFirstHint;
37+
this.allowRetry = this.giveStuFeedback;
38+
this.showHints = this.giveStuHints == null || this.giveStuHints;
39+
this.showCorrectness = this.giveStuFeedback;
40+
console.debug('this.step', this.step, 'showHints', this.showHints, 'hintPathway', context.hintPathway);
4041
this.hints = this.step.hints[context.hintPathway];
4142

4243
for (let hint of this.hints) {
@@ -241,6 +242,7 @@ class ProblemCard extends React.Component {
241242
<ErrorBoundary componentName={"HintSystem"} descriptor={"hint"}>
242243
<HintSystem
243244
giveStuFeedback={this.giveStuFeedback}
245+
unlockFirstHint={this.unlockFirstHint}
244246
problemID={this.props.problemID}
245247
index={this.props.index}
246248
step={this.step}

src/ProblemLayout/SubHintSystem.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class SubHintSystem extends React.Component {
1616

1717
constructor(props) {
1818
super(props);
19-
this.giveStuFeedback = props.giveStuFeedback
19+
this.giveStuFeedback = props.giveStuFeedback;
20+
this.unlockFirstHint = props.unlockFirstHint;
2021
this.state = {
2122
latestStep: 0,
22-
currentExpanded: 0,
23+
currentExpanded: this.unlockFirstHint ? 0 : -1,
2324
hintAnswer: ""
2425
}
25-
if (this.props.hintStatus.length > 0) {
26+
if (this.unlockFirstHint && this.props.hintStatus.length > 0) {
2627
this.props.unlockHint(0, this.props.parent);
2728
}
2829
}

0 commit comments

Comments
 (0)