Skip to content
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

[TNL-10995] fix: make max attempts setting fallback to default #404

Merged
merged 8 commits into from
Oct 11, 2023

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Oct 9, 2023

The max attempts setting for a problem xblock should be set to null for course default max attempt setting to take effect. This makes sure that xblock setting is updated if course default is updated.

Test instructions:

  • To reproduce the issue
  • Setup master devstack and follow steps provided in the README to use the new problem editor.
  • Enable new_core_editors.use_new_text_editor and new_core_editors.use_new_problem_editor waffle flag.
  • Update Maximum attempts setting in advanced setting for the course.
  • Select any problem in demo course or create a new problem.
  • Set Maximum attempts as default by clearing the field or entering the same number as default.
  • Go to advanced settings
  • Change the default maximum attempt settings.
  • Go back to the Problem created with Maximum attempts as default, the value is not updated and (default) hint disappears.
  • Reason: The new editor sets the maximum attempts value for the block with the actual default value, for example: default: 1, the editor updates the xblock max_attempts setting to 1. This is now stored for the xblock and not updated along with default.
  • Checkout this PR and follow the above steps again.

The max attempts setting for a problem xblock should be set to null for
course default max attempt setting to take effect. This makes sure that
xblock setting is updated if course default is updated.
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 9, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 9, 2023

Thanks for the pull request, @navinkarkera! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@navinkarkera navinkarkera marked this pull request as ready for review October 10, 2023 07:23
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (564d724) 90.47% compared to head (6889cd1) 90.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #404      +/-   ##
==========================================
+ Coverage   90.47%   90.49%   +0.02%     
==========================================
  Files         228      228              
  Lines        4115     4115              
  Branches      822      822              
==========================================
+ Hits         3723     3724       +1     
+ Misses        371      370       -1     
  Partials       21       21              
Files Coverage Δ
...components/EditProblemView/SettingsWidget/hooks.js 94.90% <100.00%> (-0.04%) ⬇️
...ponents/EditProblemView/SettingsWidget/messages.js 100.00% <ø> (ø)
.../SettingsWidget/settingsComponents/ScoringCard.jsx 100.00% <100.00%> (ø)
.../ProblemEditor/components/SelectTypeModal/hooks.js 90.90% <100.00%> (ø)
...ers/ProblemEditor/data/ReactStateSettingsParser.js 96.55% <100.00%> (ø)
...rs/containers/ProblemEditor/data/SettingsParser.js 97.72% <100.00%> (+0.16%) ⬆️
...ers/ProblemEditor/data/mockData/problemTestData.js 100.00% <ø> (ø)
src/editors/data/redux/problem/reducers.js 85.13% <ø> (+0.92%) ⬆️
src/editors/data/redux/thunkActions/problem.js 93.02% <80.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


test('Test score settings missing with null default', () => {
const settings = parseSettings(singleSelectWithHints.metadata, { max_attempts: null });
expect(settings.scoring).toStrictEqual({ attempts: { number: '', unlimited: true } });

Choose a reason for hiding this comment

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

@navinkarkera While the number seems to be either null or a real number everywhere, it is an empty string here and SettingParser.js Line 27. Is this intentional? Does null and empty string have different meanings? Having 2 different ways to express "nothing" is confusing.

If it is intentional, it is better to consolidate them into a single value. And if, for some reason, they are not avoidable and have a special meaning, I think we should extract them into constants like COURSE_DEFAULT_VALUE = null, UNLIMITED_VALUE = '', so their meanings are communicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tecoholic Nice catch! Initially, I thought without setting the state to '', I cannot display blank in attempts field as setting to null showed up as Null. Your comment made me retrace the state and set the display value without actually changing the state.

I have updated it now to use only null in the state except for few tests which is making sure that we are converting '' to null in the parser.

@navinkarkera navinkarkera force-pushed the navin/fix-max-attempts-setting branch from 3e05881 to 6889cd1 Compare October 10, 2023 14:49
Copy link

@tecoholic tecoholic left a comment

Choose a reason for hiding this comment

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

@navinkarkera 👍 LGTM

  • I tested this: Verified that the problems matching the default attempts set in the course settings get the value updated when the course's "maximum attempts" are updated.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@tecoholic
Copy link

tecoholic commented Oct 11, 2023

@cablaa77 @jristau1984: Hi, the fix for (TNL-10995) is ready for your review.

@kenclary kenclary merged commit b55b86c into openedx:main Oct 11, 2023
5 checks passed
@openedx-webhooks
Copy link

@navinkarkera 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@navinkarkera navinkarkera changed the title fix: make max attempts setting fallback to default [TNL-10995] fix: make max attempts setting fallback to default Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants