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

fix: not start rti tasks if not course-config #216

Merged
merged 6 commits into from
Sep 16, 2024

Conversation

johanseto
Copy link
Collaborator

@johanseto johanseto commented Sep 2, 2024

Description

Check the existence of course-config for the processed course_id.
If there is not course-config (PEARSON_RTI_COURSES_DATA) for the desired course,
RTI requests would not be sent.

Refactored a little the tests.

Testing instructions

Before

After

Additional information

Jira story:

Checklist for Merge

  • Tested in a remote environment
  • Updated documentation
  • Rebased master/main
  • Squashed commits

Check the existence of course-config for the processed course_id.
If there is not course-config (`PEARSON_RTI_COURSES_DATA`) for the desired course,
RTI requests would not be sent.

Refactored a little the tests.

Arguments:
instance<Blockcompletion>: Instance of BlockCompletion model.
"""
if not getattr(settings, "PEARSON_RTI_ACTIVATE_COMPLETION_GATE", False):
if not getattr(settings, "PEARSON_RTI_ACTIVATE_COMPLETION_GATE", False) or not getattr(
settings, "PEARSON_RTI_COURSES_DATA", {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

please consider to update the setting name and type

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The question is: is someone using the past integration? The idea was to keep compatibility with both integrations.

Anyway why fo you say the type? to change the dict to a list or something like that? I also like the dict approach:

{
"PEARSON_RTI_COURSES_DATA": {
"course-v1:one": true,
"course-v1:two": true,
"course-v1:three": false

...
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

The question is: is someone using the past integration? The idea was to keep compatibility with both integrations.

If the setting name has been changed, it doesn’t mean the previous implementation is unavailable. It might require an extra configuration step, which could seem redundant, but it remains compatible.

Anyway why fo you say the type? to change the dict to a list or something like that? I also like the dict approach:

You mentioned compatibility, but the dictionary approach is indeed completely new; the current implementation does not support that structure. However, if you prefer the dictionary over a simple list, that’s fine. Just update the setting name and adjust the logic to check for the value instead of the key.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually the v0 version is also compatible looking the test:

course_exam_configuration = {
course_id: {
"exam_authorization_count": 3,
"exam_series_code": "OTT"
},
}
@override_settings(PEARSON_RTI_COURSES_DATA=course_exam_configuration)

Is like

{
"PEARSON_RTI_COURSES_DATA": {
  "course-v1:one": { 
      "exam_authorization_count": 3, 
      "exam_series_code": "OTT" 
  },
  "course-v1:two": { 
      "exam_authorization_count": 23, 
      "exam_series_code": "OTT" 
  },
  "course-v1:three": { 
      "exam_authorization_count": 13, 
      "exam_series_code": "OTT" 
  }

...
}

so each course if the value is python truthy like a defined dict: it would pass.

So what's the purpose of creating another setting for courses, if the current could work in both versions

So in both examples I am checking the value of the key:
with the dict get

if not getattr(settings, "PEARSON_RTI_ACTIVATE_COMPLETION_GATE", False) or not getattr(
settings, "PEARSON_RTI_COURSES_DATA", {}
).get(str(instance.context_key)):

Copy link
Collaborator

Choose a reason for hiding this comment

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

So what's the purpose of creating another setting for courses, if the current could work in both versions

basically the name of the settings doesn't reflect the purpose of the setting

Copy link
Collaborator Author

@johanseto johanseto Sep 4, 2024

Choose a reason for hiding this comment

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

I added in these 2 commits.
609622d
f72c455
Anyway, I wouldn't say I like it. Now, we have to manage two settings, one for v1 and the other for the engine.
Also, we have to synchronize those settings via query or something like that to configure each course with the Pearson version to use.

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. You don't have to manage two settings previous implementation is deprecated and you shouldn't use it
  2. You didn't have to add the second condition that implementation fails if that setting is not present
  3. The previous implementation is deprecated therefore you shouldn't modify that at all
  4. You don't need any query, it's faster if you do that manually there are only two courses

This settings must to be a list with the course_id strings enabled
@johanseto
Copy link
Collaborator Author

@andrey-canon COuld you check if you agree with f125f1e.

The setting now would have this shape. And I have to update manually the 2 courses or tenant_config using the PVengine integration.

"PEARSON_ENGINE_COURSES_ENABLED" : ["course-v1:one", "course-v1:two"]

PD: Tests are falling due granular fine token permission to clone custom_reg_form.

@johanseto johanseto merged commit 3c7ca23 into master Sep 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/m m lines label test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants