Skip to content

Conversation

@zacharis278
Copy link
Contributor

@zacharis278 zacharis278 commented Sep 19, 2022

Description

MST-1526

Call into the exam service instead of the edx-proctoring plugin on course publish. This feature is currently behind the course_apps.exams_ida course waffle flag.

configuration PR: https://github.com/edx/edx-internal/pull/7120

@zacharis278 zacharis278 marked this pull request as ready for review September 19, 2022 14:09
@zacharis278 zacharis278 force-pushed the zhancock/publish-exams branch 2 times, most recently from b272620 to 8f7c7ac Compare September 19, 2022 17:16
User = get_user_model()


def register_exams(course_key):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is some intentional code duplication between this function and the edx-proctoring register_special_exams. I think it would be messier to try to reuse some of these statements when these two integrations may evolve differently.

LOGGER.info('Attempting to register exams for course %s', course_key_str)

# Call the appropriate handler for either the exams IDA or the edx-proctoring plugin
register_exams_handler = register_exams if exams_ida_enabled(course_key) else register_exams_legacy
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the naming and structure here, it is very clear about what is what in very little space

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto!


try:
_patch_course_exams(exams_list, str(course_key))
log.info(f'Successfully registered {locations} with exam service')
Copy link
Contributor

Choose a reason for hiding this comment

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

are the locations useful in this log or too detailed? what about the course key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't actually come out to messy since I wouldn't expect a large number of exams in one course Successfully registered ['block-v1:edX+DemoX+Demo_Course+type@sequential+block@00a45f2d4cc54b07a172183a1834d710', 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@00a45f2d4cc54b07a172183a1834d71123'] with exam service

But you might have a point, I'm not sure if this is actually more useful than just the course key 🤔

Copy link
Contributor

@varshamenon4 varshamenon4 left a comment

Choose a reason for hiding this comment

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

Looks great! Approving as I just had some clarifying questions. :)

}
)

# filter out any potential dangling sequences
Copy link
Contributor

Choose a reason for hiding this comment

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

[question]: @zacharis278, could you clarify what is happening here and what is meant by "dangling sequences"? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A dangling sequence is one that is part of the course but has no relationship back up to the course block. If you look at the test for this it's a kind of easier to see. For example, the section that is a parent of the sequence is deleted.

log.info(msg)
locations.append(location)

if timed_exam.is_proctored_exam:
Copy link
Contributor

Choose a reason for hiding this comment

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

[question/suggestion]: Could there be any potential issues in the future with using conditional statements like this and also with defining the exam types here? Is there an enum/class/other data type that could be better used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh good observation, my thinking is we would eventually move away from using these independent variables and just directly set exam type. They don't serve any purpose in the LMS/CMS other than backwards compatibility. Maybe I should move this into a function just in case it needs to be referenced elsewhere.

return client


def _patch_course_exams(exams_list, course_id):
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that you've created a helper method for this! Looks good.

LOGGER.info('Attempting to register exams for course %s', course_key_str)

# Call the appropriate handler for either the exams IDA or the edx-proctoring plugin
register_exams_handler = register_exams if exams_ida_enabled(course_key) else register_exams_legacy
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto!

@override_waffle_flag(EXAMS_IDA, active=True)
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_SPECIAL_EXAMS': True})
@patch('cms.djangoapps.contentstore.exams._patch_course_exams')
class TestExamService(ModuleStoreTestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice test coverage!

@zacharis278 zacharis278 force-pushed the zhancock/publish-exams branch from 06b3c2b to 379b9e4 Compare September 20, 2022 15:32
@zacharis278 zacharis278 merged commit 2f3c93e into master Sep 20, 2022
@zacharis278 zacharis278 deleted the zhancock/publish-exams branch September 20, 2022 16:38
@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.

"""
Test for syncing exams to the exam service
"""
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
Copy link
Contributor

Choose a reason for hiding this comment

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

@zacharis278: I ran across this code while reviewing #31134

Please note that this is testing against Old Mongo, the Modulestore that's been deprecated for years and is currently in the process of being removed. Please use TEST_DATA_SPLIT_MODULESTORE (I believe it will default to this without the override line here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ormsbee oh weird, yeah looks like I just blindly copied this from the older proctoring tests. Is cleaning this up blocking anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

@zacharis278: That PR I linked to above is removing features from Old Mongo that this test depends on. In general, the team has tried to convert Old Mongo modulestore based tests to Split Modulestore based ones. Sometimes, a straightforward conversion fails (like this one, apparently). The policy we've adopted for tests that look useful but have never worked in Split Mongo is to mark them as @skip("OldMongo Deprecation") and review them later to see if they're worth keeping.

I realize this is new, actively developed functionality, and not some old test written 8+ years ago. I really hope it's a straightforward change for you folks. But we've been as loud as we could for a long while that Old Mongo is going away. So fixing this is non-blocking in the sense that we can land #31134 without it, but we would do that by disabling the test.

In terms of the timing, I don't think we'll merge before next week. It's a big PR that touches a bunch of old functionality, some of which I had forgotten even existed. I've been looking over for hours and I'm still less than halfway through it. Even assuming very quick turnaround on review cycles, I wouldn't expect the reviews to be done before Friday, and we wouldn't release something like this that close to the weekend.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there's proctoring code that relies on using Old Mongo, that should definitely get looked at as well. There was at least one that was a straightforward conversion (cms/djangoapps/contentstore/tests/test_proctoring.py), but I don't know if that was the one you were referring to.

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.

6 participants