-
Notifications
You must be signed in to change notification settings - Fork 4.1k
get correct html code for curriculum as well as in level solutions #8011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes introduce special handling for "web-dev" level types in both the solution and sample code retrieval logic. For such levels, the code prioritizes HTML solutions and extracts code within Changes
Sequence Diagram(s)sequenceDiagram
participant TeacherView
participant GameStore
participant LevelModel
participant Utils
TeacherView->>GameStore: getSolutionSrc(level)
GameStore->>LevelModel: getSolutionForLanguage('html')
alt level.type == 'web-dev'
LevelModel->>LevelModel: Find HTML solution
LevelModel->>Utils: extractPlayerCodeTag(source)
Utils-->>LevelModel: Extracted code or raw HTML
LevelModel-->>GameStore: Solution code
else
LevelModel->>LevelModel: Fallback to JS/Python solution
LevelModel-->>GameStore: Solution code
end
GameStore-->>TeacherView: Solution code for display
Assessment against linked issues
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn EBADENGINE Unsupported engine { 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/core/store/modules/game.js (1)
252-260
: Consider extracting common logic to reduce code duplication.The implementation is correct and handles 'web-dev' levels properly. However, the same logic pattern is repeated across multiple files.
Consider extracting the common web-dev processing logic into a utility function:
// In utils.js function processWebDevCode(source) { if (/<playercode>/.test(source)) { return utils.extractPlayerCodeTag(source) } return source }Then update this method:
if (rootState.game.level.type === 'web-dev') { const htmlSource = (_.find(solutions, { language: 'html' }))?.source if (htmlSource) { - if (/<playercode>/.test(htmlSource)) { - return utils.extractPlayerCodeTag(htmlSource) - } - return htmlSource + return utils.processWebDevCode(htmlSource) } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/core/store/modules/game.js
(1 hunks)app/models/Level.js
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
app/core/store/modules/game.js (1)
app/models/Level.js (3)
solutions
(505-505)solutions
(540-540)utils
(21-21)
app/models/Level.js (4)
app/core/utils.js (1)
_
(20-20)app/views/play/CampaignView.js (1)
utils
(19-19)app/views/courses/CoursesView.js (1)
utils
(36-36)app/models/LevelSession.js (1)
sampleCode
(192-192)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: ESLint CI
- GitHub Check: Node.js CI (18.10.0)
🔇 Additional comments (2)
app/models/Level.js (2)
560-566
: LGTM! Good error handling for web-dev levels.The implementation correctly handles null checks and follows a consistent pattern for extracting player code from HTML sample code.
541-547
:⚠️ Potential issueFix potential null access and improve error handling.
The code has a potential null pointer issue when accessing
solution.source
without proper null checking.Apply this diff to fix the null safety issue:
if (this.isType('web-dev')) { const solution = _.find(solutions, { language: 'html', succeeds: true }) - if (/<playercode>/.test(solution?.source)) { - solution.source = utils.extractPlayerCodeTag(solution.source) + if (solution && /<playercode>/.test(solution.source)) { + solution.source = utils.extractPlayerCodeTag(solution.source) } if (solution) return solution }Likely an incorrect or invalid review comment.
app/core/store/modules/game.js
Outdated
@@ -249,6 +249,15 @@ module.exports = { | |||
} = component.config.programmableMethods | |||
|
|||
const solutions = _.filter(((plan != null ? plan.solutions : undefined) != null ? (plan != null ? plan.solutions : undefined) : []), s => !s.testOnly && s.succeeds) | |||
if (rootState.game.level.type === 'web-dev') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no optional chaining here? I would be scared 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theoretically these chain should be safe. but let me add optional 😂
fix ENG-1717
Summary by CodeRabbit
New Features
Bug Fixes