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

PADV-806: feat: add new content authoring event signals #108

Closed
wants to merge 2 commits into from

Conversation

JuanDavidBuitrago
Copy link

@JuanDavidBuitrago JuanDavidBuitrago commented Nov 16, 2023

Description

Use the following OpenEdxPublicSignal events triggered by content creation and editing.

  • XBLOCK_CREATED and XBLOCK_UPDATED
  • COURSE_CREATED
  • CONTENT_LIBRARY_CREATED, CONTENT_LIBRARY_UPDATED and CONTENT_LIBRARY_DELETED
  • LIBRARY_BLOCK_CREATED, LIBRARY_BLOCK_UPDATED and LIBRARY_BLOCK_DELETED

Testing instruction

  1. Use this branch vue/PADV-806 to use the necessary changes
  2. Setup frontend-app-library-authoring if not done before:
    from .devstack import FEATURES
    FEATURES['ENABLE_LIBRARY_AUTHORING_MICROFRONTEND'] = True
    BLOCKSTORE_API_AUTH_TOKEN = 'edxapp-insecure-devstack-key'
  1. Set up the blockstore to run in devstack (ref) by running the following from the studio shell (make studio-shell):
# Configure blockstore to run inside LMS/Studio (instead of as an external service)
./manage.py cms waffle_switch --create blockstore.use_blockstore_app_api on

./manage.py cms shell  # enter python code below

# Create a "Collection" that new content libraries / xblocks can be created within:
from blockstore.apps.bundles.models import Collection
coll, _ = Collection.objects.get_or_create(title='Devstack Content Collection', uuid='11111111-2111-4111-8111-111111111111')

# Create an "Organization":
from organizations.models import Organization
Organization.objects.get_or_create(short_name='DeveloperInc', defaults={'name': 'DeveloperInc', 'active': True})
  1. Add below snippet somewhere, for example in cms/djangoapps/contentstore/signals/handlers.py:
from openedx_events.content_authoring.signals import (
    XBLOCK_CREATED,
    XBLOCK_UPDATED,
    COURSE_CREATED,
    CONTENT_LIBRARY_CREATED,
    CONTENT_LIBRARY_UPDATED,
    CONTENT_LIBRARY_DELETED,
    LIBRARY_BLOCK_CREATED,
    LIBRARY_BLOCK_UPDATED,
    LIBRARY_BLOCK_DELETED,
)
XBLOCK_CREATED.connect(lambda **x: print("test_event: ", x))
XBLOCK_UPDATED.connect(lambda **x: print("test_event: ", x))
COURSE_CREATED.connect(lambda **x: print("test_event: ", x))
CONTENT_LIBRARY_CREATED.connect(lambda **x: print("test_event: ", x))
CONTENT_LIBRARY_UPDATED.connect(lambda **x: print("test_event: ", x))
CONTENT_LIBRARY_DELETED.connect(lambda **x: print("test_event: ", x))
LIBRARY_BLOCK_CREATED.connect(lambda **x: print("test_event: ", x))
LIBRARY_BLOCK_UPDATED.connect(lambda **x: print("test_event: ", x))
LIBRARY_BLOCK_DELETED.connect(lambda **x: print("test_event: ", x))
  1. Open studio in http://localhost:18010/
  2. Open studio logs monitoring:
make studio-logs | grep test_event:
  1. Create a course
    Check the log for COURSE_CREATED and the XBLOCK_UPDATED event data

  2. Should see something like:

make studio-logs | grep test_event:
edx.devstack-olive.master.studio   | test_event:  {'signal': <OpenEdxPublicSignal: org.openedx.content_authoring.xblock.updated.v1>, 'sender': None, 'xblock_info': XBlockData(usage_key=BlockUsageLocator(CourseLocator('demo', 'demo1', '2020', None, None), 'course', 'course'), block_type='course', version=BlockUsageLocator(CourseLocator('demo', 'demo1', '2020', 'draft-branch', ObjectId('655df4e81593fe8f4610c9a8')), 'course', 'course')), 'metadata': EventsMetadata(event_type='org.openedx.content_authoring.xblock.updated.v1', id=UUID('39d5e9d2-8933-11ee-8a88-0242ac130010'), minorversion=0, source='openedx/cms/web', sourcehost='studio.devstack.edx', time=datetime.datetime(2023, 11, 22, 12, 32, 40, 172109, tzinfo=datetime.timezone.utc), sourcelib=(8, 3, 0))}
edx.devstack-olive.master.studio   | test_event:  {'signal': <OpenEdxPublicSignal: org.openedx.content_authoring.xblock.created.v1>, 'sender': None, 'xblock_info': XBlockData(usage_key=BlockUsageLocator(CourseLocator('demo', 'demo2', '2020', None, None), 'course_info', 'updates'), block_type='course_info', version=BlockUsageLocator(CourseLocator('demo', 'demo2', '2020', 'draft-branch', ObjectId('655e011b89ca06c615ebfe56')), 'course_info', 'updates')), 'metadata': EventsMetadata(event_type='org.openedx.content_authoring.xblock.created.v1', id=UUID('7fb4138c-893a-11ee-a5a4-0242ac130010'), minorversion=0, source='openedx/cms/web', sourcehost='studio.devstack.edx', time=datetime.datetime(2023, 11, 22, 13, 24, 43, 867932, tzinfo=datetime.timezone.utc), sourcelib=(8, 3, 0))}

Jira issue

Other information

Reference PR edx-platform: openedx#32599
Reference PR openedx/events: openedx/openedx-events#244

@JuanDavidBuitrago JuanDavidBuitrago changed the title PADV-806: feat!: add new content authoring event signals PADV-806: feat: add new content authoring event signals Nov 17, 2023
@JuanDavidBuitrago JuanDavidBuitrago marked this pull request as ready for review November 22, 2023 15:20
@JuanDavidBuitrago JuanDavidBuitrago self-assigned this Nov 22, 2023
Copy link

@Jacatove Jacatove left a comment

Choose a reason for hiding this comment

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

@JuanDavidBuitrago Do we really need to back port all content authoring event signals?.
For me it is clear the need to do it for COURSE_CREATED, but I don't know about the others.

openedx/core/djangoapps/content_libraries/api.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/content_libraries/api.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/content_libraries/api.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/content_libraries/api.py Outdated Show resolved Hide resolved
openedx/core/djangoapps/content_libraries/api.py Outdated Show resolved Hide resolved
xmodule/modulestore/mixed.py Show resolved Hide resolved
xmodule/modulestore/mixed.py Outdated Show resolved Hide resolved
xmodule/modulestore/tests/test_mixed_modulestore.py Outdated Show resolved Hide resolved
xmodule/modulestore/tests/test_mixed_modulestore.py Outdated Show resolved Hide resolved
@JuanDavidBuitrago
Copy link
Author

JuanDavidBuitrago commented Nov 27, 2023

@JuanDavidBuitrago Do we really need to back port all content authoring event signals?. For me it is clear the need to do it for COURSE_CREATED, but I don't know about the others.

@Jacatove I added the complete content authoring event signals because I had to update the openedx-events version, so I consider it is better to implement all of them to avoid problem using that version.

@JuanDavidBuitrago
Copy link
Author

I will let it as a draft to future work if it's useful.

Here is the PR with COURSE_CREATED signal only: #109

@JuanDavidBuitrago JuanDavidBuitrago marked this pull request as draft November 27, 2023 22:09
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