-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20190 from code-dot-org/dtl_candidate_4aa23197
- Loading branch information
Showing
174 changed files
with
2,531 additions
and
737 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import msg from '@cdo/locale'; | ||
import authoredHintUtils from './authoredHintUtils'; | ||
|
||
export default function getAchievements(state) { | ||
return POSSIBLE_ACHIEVEMENTS.map( | ||
possibleAchievement => possibleAchievement(state) | ||
).filter(achievement => achievement); | ||
} | ||
|
||
const POSSIBLE_ACHIEVEMENTS = [ | ||
puzzleComplete, | ||
numberOfBlocks, | ||
usingHints, | ||
]; | ||
|
||
export function puzzleComplete(state) { | ||
return { | ||
isAchieved: true, | ||
message: msg.puzzleCompleted(), | ||
successIconUrl: '', | ||
}; | ||
} | ||
|
||
export function numberOfBlocks(state) { | ||
const blockLimit = state.feedback.blockLimit; | ||
const blocksUsed = state.feedback.blocksUsed; | ||
if (blockLimit === undefined || blockLimit === Infinity) { | ||
return null; | ||
} | ||
|
||
let message, isAchieved; | ||
if (blocksUsed < blockLimit) { | ||
message = msg.fewerNumberOfBlocks({numBlocks: blockLimit}); | ||
isAchieved = true; | ||
} else if (blocksUsed === blockLimit) { | ||
message = msg.exactNumberOfBlocks({numBlocks: blockLimit}); | ||
isAchieved = true; | ||
} else { | ||
message = msg.usingTooManyBlocks(); | ||
isAchieved = false; | ||
} | ||
|
||
return { | ||
isAchieved, | ||
message, | ||
successIconUrl: '', | ||
failureIconUrl: '', | ||
}; | ||
} | ||
|
||
export function usingHints(state) { | ||
const hintsUsed = authoredHintUtils.currentOpenedHintCount( | ||
state.pageConstants.serverLevelId); | ||
let message, isAchieved; | ||
if (hintsUsed === 0) { | ||
message = msg.withoutHints(); | ||
isAchieved = true; | ||
} else if (hintsUsed === 1) { | ||
message = msg.usingOneHint(); | ||
isAchieved = true; | ||
} else { | ||
message = msg.usingHints(); | ||
isAchieved = false; | ||
} | ||
return { | ||
isAchieved, | ||
message, | ||
successIconUrl: '', | ||
failureIconUrl: '', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.