[Django app] Get information about a course

Hello everyone!

I’m working in a Django app that listens to the signal SignalHandler.course_published. It’s working fine, but I need to get extra data about a course, like who created/authored the course.

I looked at all course tables of MySQL and I didn’t find this information. We have the course_overviews_courseoverview table with many information, but nothing about the creator/author.

Someone knows where can I get this information?

When we create a course, the Open edX executes this function:


def create_course(self, org, course, run, user_id, **kwargs):  # lint-amnesty, pylint: disable=arguments-differ
        Creates and returns the course.

            org (str): the organization that owns the course
            course (str): the name of the course
            run (str): the name of the run
            user_id: id of the user creating the course
            fields (dict): Fields to set on the course at initialization
            kwargs: Any optional arguments understood by a subset of modulestores to customize instantiation

        Returns: a CourseBlock
        # first make sure an existing course doesn't already exist in the mapping
        course_key = self.make_course_key(org, course, run)

        log.info('Creating course run %s...', course_key)
        if course_key in self.mappings and self.mappings[course_key].has_course(course_key):
            log.error('Cannot create course run %s. It already exists!', course_key)
            raise DuplicateCourseError(course_key, course_key)

        # create the course
        store = self._verify_modulestore_support(None, 'create_course')
        course = store.create_course(org, course, run, user_id, **kwargs)
        log.info('Course run %s created successfully!', course_key)

        # add new course to the mapping
        self.mappings[course_key] = store

        return course

course = store.create_course(org, course, run, user_id, **kwargs)
Where this data is stored? How can I get this?

Hello, what’s your goal with this information? The platform is modeled in a way where more than one person may have authored a course and the person who first created the course shell may not be relevant to the rest of the course lifecycle.

If you want to associate data with the course such as which instructors teach it, I think that you can attach that data to the relevant models in course_discovery.

I’m setting the created_by at the first time the course_published event is trigged to a course_id and setting the update_by for the next time.

I’m using the user that submits the request in CMS:

from openedx.core.lib.request_utils import get_request_or_stub
request = get_request_or_stub()
user = request.user.username