EDUCATOR-394 disable self-generated certificates when course is reset to instructor-paced

This commit is contained in:
rabiaiftikhar
2017-06-14 18:53:05 +05:00
parent 23d480f457
commit 7bf0674de8
3 changed files with 44 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import re
import logging
from django.conf import settings
from django.dispatch import Signal
from xmodule.fields import Date
from xmodule.modulestore.exceptions import ItemNotFoundError
@@ -12,6 +13,8 @@ from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from openedx.core.lib.courses import course_image_url
from xmodule.modulestore.django import modulestore
COURSE_PACING_CHANGE = Signal(providing_args=["course_key", "course_self_paced"])
# This list represents the attribute keys for a course's 'about' info.
# Note: The 'video' attribute is intentionally excluded as it must be
@@ -188,6 +191,7 @@ class CourseDetails(object):
descriptor = module_store.get_course(course_key)
dirty = False
is_pacing_changed = False
# In the descriptor's setter, the date is converted to JSON
# using Date's to_json method. Calling to_json on something that
@@ -271,10 +275,15 @@ class CourseDetails(object):
and jsondict['self_paced'] != descriptor.self_paced):
descriptor.self_paced = jsondict['self_paced']
dirty = True
is_pacing_changed = True
if dirty:
module_store.update_item(descriptor, user.id)
# fires a signal indicating that the course pacing has changed
if is_pacing_changed:
COURSE_PACING_CHANGE.send(sender=None, course_key=course_key, course_self_paced=descriptor.self_paced)
# NOTE: below auto writes to the db w/o verifying that any of
# the fields actually changed to make faster, could compare
# against db or could have client send over a list of which