Skip to content

Commit

Permalink
Merge pull request #7 from edx/aed/viewing-delay
Browse files Browse the repository at this point in the history
Add settings and service method for determining completion-by-viewing delay.
  • Loading branch information
iloveagent57 authored Feb 15, 2018
2 parents b594006 + 4f1b211 commit a4695aa
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ Unreleased
~~~~~~~~~~
* Nothing

[0.0.6] - 2018-02-13
[0.0.7] - 2018-02-15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Add settings and service method for determining completion-by-viewing delay.

[0.0.6] - 2018-02-13
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Add the additional completion logic into the service and models from edx-platform
Expand Down
2 changes: 1 addition & 1 deletion completion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
from __future__ import unicode_literals


__version__ = '0.0.6'
__version__ = '0.0.7'

default_app_config = 'completion.apps.CompletionAppConfig' # pylint: disable=invalid-name
9 changes: 9 additions & 0 deletions completion/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from __future__ import unicode_literals

from django.conf import settings

from .models import BlockCompletion
from . import waffle

Expand Down Expand Up @@ -99,3 +101,10 @@ def vertical_is_complete(self, item):
if completions[child_location] < 1.0:
return False
return True

def get_completion_by_viewing_delay_ms(self):
"""
Do not mark blocks complete-by-viewing until they have been visible for
the returned amount of time, in milliseconds. Defaults to 5000.
"""
return getattr(settings, 'COMPLETION_BY_VIEWING_DELAY_MS', 5000)
6 changes: 5 additions & 1 deletion completion/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ def plugin_settings(settings): # pylint: disable=unused-argument
Defines completion-specific settings when app is used as a plugin to edx-platform.
See: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/plugins/README.rst
"""
pass
# Once a complete-by-viewing (e.g. HTML) block has been visible on-screen for this many ms, mark it complete
settings.COMPLETION_BY_VIEWING_DELAY_MS = 5000
# Once a user has watched this percentage of a video, mark it as complete:
# (0.0 = 0%, 1.0 = 100%)
settings.COMPLETION_VIDEO_COMPLETE_PERCENTAGE = 0.95
15 changes: 15 additions & 0 deletions completion/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import ddt
from django.test import TestCase
from django.test.utils import override_settings
from opaque_keys.edx.keys import CourseKey, UsageKey

from ..models import BlockCompletion
Expand Down Expand Up @@ -78,3 +79,17 @@ def test_get_completions_block_keys_missing_run(self):
def test_enabled_honors_waffle_switch(self, enabled):
with self.override_completion_switch(enabled):
self.assertEqual(self.completion_service.completion_tracking_enabled(), enabled)


@ddt.ddt
class CompletionDelayTestCase(CompletionSetUpMixin, TestCase):
"""
Test that the completion-by-viewing delay is properly passed in from
the project settings.
"""

@ddt.data(1, 1000, 0)
def test_get_completion_by_viewing_delay_ms(self, delay):
service = CompletionService(self.user, self.course_key)
with override_settings(COMPLETION_BY_VIEWING_DELAY_MS=delay):
self.assertEqual(service.get_completion_by_viewing_delay_ms(), delay)

0 comments on commit a4695aa

Please sign in to comment.