8000 default to blocks-icons for codecombat-junior by smallst · Pull Request #7839 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

default to blocks-icons for codecombat-junior #7839

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

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

smallst
Copy link
Contributor
@smallst smallst commented Nov 20, 2024

fix ENG-1418

Summary by CodeRabbit

  • New Features

    • Enhanced code format determination for improved user experience, especially for 'codecombat-junior' users.
    • Improved spell creation logic to ensure accurate parameters.
    • Updated URL generation for curriculum guides to include specific parameters based on course ID.
  • Bug Fixes

    • Refined handling of blocks visibility based on updated code format logic.
  • Chores

    • Maintained error handling for missing programmable Thangs to ensure stability.

Copy link
Contributor
coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes in the TomeView.coffee file involve updates to the TomeView class, specifically in the logic for determining the desiredCodeFormat. The assignment of desiredCodeFormat is now conditional based on the product type, defaulting to classroomCodeFormatDefault when necessary. Modifications to the determineCodeFormat and createSpells methods enhance how code formats and spells are created, while maintaining existing error handling and event subscriptions. Additionally, the curriculum-guide-helper.js file has been updated to refine URL generation based on course-specific conditions.

Changes

File Change Summary
app/views/play/level/tome/TomeView.coffee Updated logic for desiredCodeFormat assignment, modified determineCodeFormat and createSpells methods.
ozaria/site/components/teacher-dashboard/BaseCurriculumGuide/curriculum-guide-helper.js Added conditional check for courseId in getLevelUrl to append codeFormat=blocks-icons.

Assessment against linked issues

Objective Addressed Explanation
Default to block mode for coco jr (ENG-1418)

Possibly related PRs

🐇 In the land of code, where changes bloom,
A rabbit hops forth, dispelling the gloom.
With blocks and spells, we dance in delight,
For junior coders, the future is bright!
So let’s celebrate, with joy and with cheer,
Our TomeView's magic is finally here! ✨

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 (1.23.1)

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-plugin-script-tags@0.5.0: Now published as @mapbox/eslint-plugin-script-tags
warning blockly > jsdom > abab@2.0.6: Use your platform's native atob() and btoa() methods instead
warning blockly > jsdom > data-urls > abab@2.0.6: Use your platform's native atob() and btoa() methods instead
warning blockly > jsdom > domexception@4.0.0: Use your platform's native DOMException instead
warning treema > express > mkdirp@0.3.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
warning treema > express > connect@2.7.2: connect 2.x series is deprecated
warning treema > express > connect > formidable@1.0.11: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
warning vue@2.7.10: Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.
warning jasmine > glob@3.2.11: Glob versions prior to v9 are no longer supported
warning jasmine > glob > minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning karma > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning karma > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning karma > tmp > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning karma > socket.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (debug-js/debug#797)
warning karma > socket.io > socket.io-parser > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (debug-js/debug#797)
warning karma > socket.io > engine.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (debug-js/debug#797)
warning pug > pug-filters > constantinople > babel-types > babel-runtime > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning standard > eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
error treema@0.0.0: The engine "node" is incompatible with this module. Expected version "0.8.x". Got "22.9.0"
error Found incompatible module.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
app/views/play/level/tome/TomeView.coffee (1)

121-124: LGTM! Consider improving readability with a comment.

The implementation correctly ensures that CodeCombat Junior defaults to block mode while preserving user preferences. The precedence order is clear:

  1. User's preferred format
  2. 'blocks-icons' for CodeCombat Junior
  3. Classroom default format

Consider adding a brief comment explaining the precedence order for future maintainers:

      desiredCodeFormat = me.get('aceConfig')?.codeFormat
+     # Format precedence: user preference > product default > classroom default
      if @options.level.get('product') === 'codecombat-junior'
        desiredCodeFormat ?= 'blocks-icons'
      desiredCodeFormat ?= classroomCodeFormatDefault
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7cce909 and 7248440.

📒 Files selected for processing (1)
  • app/views/play/level/tome/TomeView.coffee (1 hunks)
🔇 Additional comments (1)
app/views/play/level/tome/TomeView.coffee (1)

121-124: Verify the impact on existing tests and configurations.

Let's ensure this change is properly covered by tests and doesn't conflict with existing configurations.

✅ Verification successful

Let me gather more specific information about how the code format is determined in these files to ensure there are no conflicts.


Based on the comprehensive results, I can now provide a final response about the code format changes:

Changes are consistent with existing configurations and test coverage

The modification to set blocks-icons as the default format for CodeCombat Junior is well-supported by the codebase:

  • The schema in classroom.schema.js properly defines blocks-icons as a valid option in the codeFormatDefault enum
  • The Vue component CourseCodeLanguageFormatComponent handles blocks-icons format appropriately, including proper disabling logic for non-Junior courses
  • The constants in core/constants.js include blocks-icons in both CODE_FORMAT_ALL and CODE_FORMAT_IPAD arrays
  • The change aligns with the existing classroom configuration system where code formats can be controlled at both classroom and user levels
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related code and test coverage

# Check for other references to blocks-icons and code format determination
echo "Checking for related code..."
rg -l "blocks-icons"

# Check for test files that might need updating
echo "Checking for related test files..."
fd -e test.coffee -e spec.coffee | xargs rg -l "codeFormat|blocks-icons"

# Check for classroom configuration files
echo "Checking for classroom config files..."
fd -e config.coffee | xargs rg -l "codeFormat|blocks-icons"

Length of output: 2557


Script:

#!/bin/bash
# Check the specific implementation details around code format determination

# Look for code format determination logic
echo "Checking code format determination logic..."
rg -A 5 "codeFormat.*=|get\('codeFormat'\)" 

# Check classroom schema for default values
echo "Checking classroom schema defaults..."
cat app/schemas/models/classroom.schema.js

# Check constants related to code format
echo "Checking code format constants..."
rg -A 2 "CODE_FORMAT|codeFormat" app/core/constants.js

# Check for any potential conflicts in Vue components
echo "Checking Vue component logic..."
cat "ozaria/site/components/teacher-dashboard/modals/modal-edit-class-components/CourseCodeLanguageFormatComponent.vue"

Length of output: 47115

desiredCodeFormat = me.get('aceConfig')?.codeFormat
if @options.level.get('product') == 'codecombat-junior'
desiredCodeFormat ?= 'blocks-icons'
desiredCodeFormat ?= classroomCodeFormatDefault
newCodeFormat = if desiredCodeFormat in classroomCodeFormats then desiredCodeFormat else classroomCodeFormatDefault
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is the objective here, but this line will reassign it back to text-code if classroomCodeFormats doesn't contain block-icons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya it is. if the teacher want classroom don't use block they can still disable that so that junior will still use text-code

Copy link
Contributor
@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
ozaria/site/components/teacher-dashboard/BaseCurriculumGuide/curriculum-guide-helper.js (1)

7-11: Consider handling existing codeFormat parameter.

The current implementation might overwrite an existing codeFormat parameter if one is present in the URL. Consider checking if the URL already contains a codeFormat parameter before appending a new one.

Here's a suggested improvement:

-    let url = `/play/level/${slug}?course=${courseId}&codeLanguage=${codeLanguage}`
-    if (courseId === utils.courseIDs.JUNIOR) {
-      url += '&codeFormat=blocks-icons'
-    }
+    const params = new URLSearchParams({
+      course: courseId,
+      codeLanguage: codeLanguage
+    });
+    if (courseId === utils.courseIDs.JUNIOR && !params.has('codeFormat')) {
+      params.set('codeFormat', 'blocks-icons');
+    }
+    let url = `/play/level/${slug}?${params.toString()}`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 33da34a and ed924f6.

📒 Files selected for processing (2)
  • app/views/play/level/tome/TomeView.coffee (1 hunks)
  • ozaria/site/components/teacher-dashboard/BaseCurriculumGuide/curriculum-guide-helper.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/views/play/level/tome/TomeView.coffee
🔇 Additional comments (1)
ozaria/site/components/teacher-dashboard/BaseCurriculumGuide/curriculum-guide-helper.js (1)

7-11: Implementation looks good, verify courseIDs constant.

The implementation correctly adds the blocks-icons format for Junior courses, aligning with the PR objective.

Let's verify the courseIDs constant is properly defined:

✅ Verification successful

Implementation verified, courseIDs.JUNIOR is properly defined

The courseIDs.JUNIOR constant is correctly defined in app/core/utils.js with a valid ID value ('65f32b6c87c07dbeb5ba1936'). The implementation in curriculum-guide-helper.js can safely rely on this constant.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify JUNIOR course ID is defined
rg -A 5 "courseIDs.*=.*{" app/core/utils

Length of output: 136


Script:

#!/bin/bash
# Search for courseIDs definition with proper regex escaping
rg -A 5 "courseIDs\s*=\s*\{" app/core/utils

# Also try searching in other common locations
rg -A 5 "courseIDs\s*=\s*\{" app/core
rg -A 5 "courseIDs\s*=\s*\{" ozaria/site

# Search specifically for JUNIOR constant
rg "JUNIOR.*:" --type js

Length of output: 1496

@@ -118,8 +118,15 @@ module.exports = class TomeView extends CocoView
else
classroomCodeFormatDefault = @options.classroomAceConfig?.codeFormatDefault or 'text-code'
classroomCodeFormats = @options.classroomAceConfig?.codeFormats or ['blocks-icons', 'blocks-text', 'blocks-and-code', 'text-code']
desiredCodeFormat = me.get('aceConfig')?.codeFormat or classroomCodeFormatDefault
desiredCodeFormat = me.get('aceConfig')?.codeFormat
if @options.level.get('product') == 'codecombat-junior'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need these changes with query variable below now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes still work for new users. query variable now only work for teacher-dashboard. i think we can keep them until we make new logic for codeformat

@smallst smallst merged commit e59f091 into master Nov 26, 2024
2 checks passed
@smallst smallst deleted the yuqiang/default-blocks-on-junior branch November 26, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0