Skip to content

Conversation

@xitij2000
Copy link
Contributor

@xitij2000 xitij2000 commented Sep 15, 2021

Description

This commit adds new discussions settings for the new discussions experience. These are stored in the course so they can be a part of course import/export flow.
These are also added to the discussions configuration API to allow MFEs to update the settings.

Supporting information

Testing instructions

  1. Use the updates course authoring MFE from here: fix: Update the API path and fix saving settings [BD-38] [TNL-8621] [BB-4854] frontend-app-authoring#197
  2. Change the legacy provider settings for anonymous posting settings, and make sure they are persisted
  3. The settings should be saved to the coruse structure as well which you can verify using the shell

Deadline

"None"

@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Sep 15, 2021
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 15, 2021

Thanks for the pull request, @xitij2000! I've created BLENDED-963 to keep track of it in Jira. More details are on the BD-38 project page.

When this pull request is ready, tag your edX technical lead.

@xitij2000 xitij2000 force-pushed the kshiitj/discussions-structure-in-course branch 2 times, most recently from 66e4d95 to 92abd91 Compare October 6, 2021 09:38
@xitij2000 xitij2000 marked this pull request as ready for review October 6, 2021 09:39
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 6, 2021
@xitij2000 xitij2000 force-pushed the kshiitj/discussions-structure-in-course branch 2 times, most recently from 5b40d6f to a4d3a19 Compare October 6, 2021 12:52
@xitij2000
Copy link
Contributor Author

jenkins run python

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will hide these new settings from the advanced settings UI.

Might be worth removing it from here while testing to have an easy way to check for changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I've added a plugin entrypoint, this isn't needed any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving these over allows us to import this in both LMS and studio code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We simply set the default here instead of in a dozen other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This lets the standard machinery handle the regular fields and we can focus on the complex cases.

Comment on lines +312 to +317
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a setting that specific to the inbuild forums, so it can be stored in the plugin configuraiton.

Comment on lines +353 to 436
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is direclty moved over.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this code is just moved over without any changes other than adding type hints.

Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

@xitij2000, I've tested that the changes are persisted when I'm setting them through the advanced settings. From your first point, it looks that we should also test this with the frontend-app-course-authoring, right? When I'm visiting the discussions settings, I'm getting the following error:

TypeError
can't access property "map", basic is undefined
Call StackFeaturesTable
  src/pages-and-resources/discussions/app-list/FeaturesTable.jsx:96:12renderWithHooks
  node_modules/react-dom/cjs/react-dom.development.js:14803:27mountIndeterminateComponent
  node_modules/react-dom/cjs/react-dom.development.js:17482:13beginWork
  node_modules/react-dom/cjs/react-dom.development.js:18596:16callCallback
  node_modules/react-dom/cjs/react-dom.development.js:188:14invokeGuardedCallbackDev
  node_modules/react-dom/cjs/react-dom.development.js:237:16invokeGuardedCallback
  node_modules/react-dom/cjs/react-dom.development.js:292:31beginWork$1
  node_modules/react-dom/cjs/react-dom.development.js:23203:28performUnitOfWork
  node_modules/react-dom/cjs/react-dom.development.js:22154:12workLoopSync
  node_modules/react-dom/cjs/react-dom.development.js:22130:22

@xitij2000 xitij2000 force-pushed the kshiitj/discussions-structure-in-course branch 4 times, most recently from 4a92c14 to 2699f07 Compare October 11, 2021 08:45
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this: verified that the course settings are applied correctly through the MFE
  • I read through the code
  • I checked for accessibility issues: n/a
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository: n/a

Copy link
Contributor

@awaisdar001 awaisdar001 Oct 18, 2021

Choose a reason for hiding this comment

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

I know it doesn't load the course every time, but let's make it simpler and store that value in a variable course = self._get_course() to make it more readable.

after refactor this would becomecourse. discussions_settings[key] = value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do that but in that case every call to this API will load the course, even if it doesn't need to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain how it would be any different in loading the course with respect to storing it in var and using it and directly calling the get_course? Here is what I mean.

Approch 1: 
self._get_course().discussions_settings[updated_provider_type] = value
self._get_course().discussions_settings[key] = value
Approch 2: 
course = self._get_course()
course.discussions_settings[updated_provider_type] = value
course.discussions_settings[key] = value
...
modulestore().update_item(course, self.context['user_id'])

I found approach 2 more readable as we are updating the "same" course we have modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sure! I thought you meant loading it once up top and using that. Will update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, on reading through the code again, I think the approach you've mentioned will cause a performance hit when the course doesn't need to be loaded. I'll explain why.

There are three places that self._get_course() is used:

  1. Line 336: Here, we only want the course to be loaded if there is a setting that has changed, which is what we're checking in the if condition above. That is why we call get course only if that condition applies.
  2. Line 342: Here once again we check if the configuration has changed, and if it has, we load the course and update the settings.
  3. Line 352: Here, we only want to load the course if the settings have changed. At this point the course has definitely been loaded,

The approach you've outlined above won't work because each access to the course object is happening in a different conditional, so before applying each change we'd need to check if course is None and then load it, which is exactly why that was moved to a method in the first place.

This commit adds new discussions settings for the new discussions experience. These are stored in the course so they can be a part of course import/export flow.
These are also added to the discussions configuraiton API to allow MFEs to update the settings.
The discussions API is currently available via LMS, however that means it cannot save changes to the modulestore. This also adds the API to the studio config so it can now also be accessed from studio and be used to save course settings.
@xitij2000 xitij2000 force-pushed the kshiitj/discussions-structure-in-course branch from ffc158c to 98a9b8e Compare October 21, 2021 11:35
@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

Copy link
Contributor

@awaisdar001 awaisdar001 left a comment

Choose a reason for hiding this comment

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

👍

@xitij2000
Copy link
Contributor Author

@awaisdar001 This is good to merge on my side.

@awaisdar001
Copy link
Contributor

I'll merge this in the morning.

@asadazam93 asadazam93 merged commit bb0c031 into openedx:master Oct 27, 2021
@openedx-webhooks
Copy link

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

@xitij2000 xitij2000 deleted the kshiitj/discussions-structure-in-course branch October 27, 2021 11:29
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blended PR is managed through 2U's blended developmnt program merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants