openedx.features.survey_report package#
Subpackages#
Submodules#
openedx.features.survey_report.api module#
Contains the logic to manage survey report model.
- openedx.features.survey_report.api.generate_report() None#
Generate a report with relevant data.
- openedx.features.survey_report.api.get_id() str#
Generate id for the survey report.
- openedx.features.survey_report.api.get_report_data() dict#
Get data from database to generate a new report.
- openedx.features.survey_report.api.send_report_to_external_api(report_id: int) None#
Send a report to Openedx endpoint and save the response in the SurveyReportUpload model.
endpoint: The value of the setting SURVEY_REPORT_ENDPOINT
content_type: JSON
payload: - courses_offered: Total number of active unique courses. - learner: Recently active users with login in some weeks. - registered_learners: Total number of users ever registered in the platform. - enrollments: Total number of active enrollments in the platform. - generated_certificates: Total number of generated certificates. - extra_data: Extra information that will be saved in the report, E.g: site_name, openedx-release. - created_at: Date when the report was generated, this date will send with format ‘%m-%d-%Y %H:%M:%S’
- openedx.features.survey_report.api.update_report(survey_report_id: int, data: dict) None#
openedx.features.survey_report.apps module#
Survey Report App Configuration.
openedx.features.survey_report.context_processors module#
This module provides context processors for integrating survey report functionality into Django admin sites.
It includes functions for determining whether to display a survey report banner and calculating the date threshold for displaying the banner.
Functions: - admin_extra_context(request): Sends extra context to every admin site, determining whether to display the survey report banner based on defined settings and conditions.
should_show_survey_report_banner():
Determines whether to show the survey report banner based on the threshold.
get_months_threshold(months):
Calculates the date threshold based on the specified number of months.
Dependencies: - Django: settings, reverse, shortcuts - datetime: datetime - dateutil.relativedelta: relativedelta
Usage: This module is designed to be imported into Django projects with admin functionality. It enhances the admin interface by providing dynamic context for displaying a survey report banner based on defined conditions and settings.
- openedx.features.survey_report.context_processors.admin_extra_context(request)#
This function sends extra context to every admin site. The current threshold to show the banner is one month but this can be redefined in the future.
- openedx.features.survey_report.context_processors.get_months_threshold(months)#
Calculate the date threshold based on the specified number of months.
- openedx.features.survey_report.context_processors.should_show_survey_report_banner()#
Determine whether to show the survey report banner based on the threshold.
openedx.features.survey_report.models module#
Survey Report models.
- class openedx.features.survey_report.models.SurveyReport(*args, **kwargs)#
Bases:
ModelThis model stores information to automate the way of gathering impact data from the openedx project.
fields: - courses_offered: Total number of active unique courses. - learner: Recently active users with login in some weeks. - registered_learners: Total number of users ever registered in the platform. - enrollments: Total number of active enrollments in the platform. - generated_certificates: Total number of generated certificates. - extra_data: Extra information that will be saved in the report, E.g: site_name, openedx-release. - state: State of the async generating process.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- courses_offered#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created_at#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enrollments#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- extra_data#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- generated_certificates#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_state_display(*, field=<django.db.models.fields.CharField: state>)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- learners#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- registered_learners#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- state#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- surveyreportupload_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class openedx.features.survey_report.models.SurveyReportAnonymousSiteID(*args, **kwargs)#
Bases:
ModelThis model is just to save the identification which will be send to the external API when the settings ANONYMOUS_SURVEY_REPORT is defined.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- class openedx.features.survey_report.models.SurveyReportUpload(*args, **kwargs)#
Bases:
ModelThis model stores the result of the POST request made to an external service after generating a survey report.
fields: - sent_at: Date when the report was sent. - report: The report that was sent. - status: Request status code. - request_details: Information about the send request.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- get_next_by_sent_at(*, field=<django.db.models.fields.DateTimeField: sent_at>, is_next=True, **kwargs)#
- get_previous_by_sent_at(*, field=<django.db.models.fields.DateTimeField: sent_at>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_uploaded() bool#
- objects = <django.db.models.manager.Manager object>#
- report#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- report_id#
- request_details#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- sent_at#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status_code#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
openedx.features.survey_report.queries module#
Queries to get data from database.
- openedx.features.survey_report.queries.get_course_enrollments() int#
Get total number of enrollments from users that aren’t staff. Course staff members will be included.
- openedx.features.survey_report.queries.get_generated_certificates() int#
Get total number of generated certificates.
- openedx.features.survey_report.queries.get_recently_active_users(weeks: int) int#
Get total number of users with last login in the last weeks.
- Parameters:
weeks (int) – number of weeks since the last login to considerate as an active learner.
- openedx.features.survey_report.queries.get_registered_learners() int#
Get total number of active learners registered.
- openedx.features.survey_report.queries.get_unique_courses_offered() int#
Get total number of unique course that started before today and have an open date, or have not finished yet, whose number of enrollments is greater than MIN_ENROLLS_ACTIVE_COURSE.
openedx.features.survey_report.tasks module#
Tasks for Survey Report.
openedx.features.survey_report.urls module#
Defines URLs for Survey Report.
openedx.features.survey_report.views module#
Views to manage the Survey Reports.