Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions common/lib/xmodule/xmodule/modulestore/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,15 @@ class InheritanceMixin(XBlockMixin):
default=default_reset_button
)
edxnotes = Boolean(
display_name=_("Enable Notes"),
help=_("Enter true or false. If true, you can use the Notes for HTML components."),
display_name=_("Enable Student Notes"),
help=_("Enter true or false. If true, students can use the Student Notes feature."),
default=False,
scope=Scope.settings
)
edxnotes_visibility = Boolean(
display_name=_("Enable visibility of Notes"),
help=_("Enter true or false. If true, Notes for HTML components will be visible."),
display_name="Student Notes Visibility",
help=_("Indicates whether Student Notes are visible in the course. "
"Students can also show or hide their notes in the courseware."),
default=True,
scope=Scope.user_info
)
Expand Down
6 changes: 4 additions & 2 deletions lms/djangoapps/edxnotes/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ def get_html(self, *args, **kwargs):
is_studio = getattr(self.system, "is_author_mode", False)
course = self.descriptor.runtime.modulestore.get_course(self.runtime.course_id)

# Must be disabled in Studio or depends on the feature flag/advanced
# settings of the course.
# Must be disabled:
# - in Studio;
# - when Harvard Annotation Tool is enabled for the course;
# - when the feature flag or `edxnotes` setting of the course is set to False.
if is_studio or not is_feature_enabled(course):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@polesye I would rather write:

# Must be disabled:
# - In Studio.
# - When Harvard Annotation Tool is enabled for the course.
# - When the feature flag of the course in advanced settings is set to False.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would rather write:

Fixed.

return original_get_html(self, *args, **kwargs)
else:
Expand Down
20 changes: 17 additions & 3 deletions lms/djangoapps/edxnotes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,27 @@ def generate_uid():

def is_feature_enabled(course):
"""
Returns True if the edxnotes app is enabled for the course, False otherwise.
Returns True if Student Notes feature is enabled for the course,
False otherwise.

In order for the app to be enabled it must be:
In order for the application to be enabled it must be:
1) enabled globally via FEATURES.
2) present in the course tab configuration.
3) Harvard Annotation Tool must be disabled for the course.
"""
tab_found = next((True for t in course.tabs if t["type"] == "edxnotes"), False)
feature_enabled = settings.FEATURES.get("ENABLE_EDXNOTES")

return feature_enabled and tab_found
return (feature_enabled and tab_found) and not is_harvard_notes_enabled(course)


def is_harvard_notes_enabled(course):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what do you think about just using Harvard's notes.utils.notes_enabled_for_course for checking?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

what do you think about just using Harvard's notes.utils.notes_enabled_for_course for checking?

It doesn't check for 'textannotation', 'imageannotation', 'videoannotation' fields. So, we cannot use it.

"""
Returns True if Harvard Annotation Tool is enabled for the course,
False otherwise.

Checks for 'textannotation', 'imageannotation', 'videoannotation' in the list
of advanced modules of the course.
"""
modules = set(['textannotation', 'imageannotation', 'videoannotation'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@polesye There is a fourth field, notes for their My Notes page:

http://www.equtek.com/clients/edX/annotation/setup.php

I do not know if it will work independently if none of 'textannotation', 'imageannotation', 'video annotation' are present. But perhaps we should also add it to the fields?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do not know if it will work independently if none of 'textannotation', 'imageannotation', 'video annotation' are present. But perhaps we should also add it to the fields?

Looks like they are independent modules. I do not see any reasons to add notes in this list. Enabling My Notes page shouldn't affect our Student Notes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@polesye

Looks like they are independent modules. I do not see any reasons to add notes in this list. Enabling My Notes page shouldn't affect our Student Notes.

OK, thanks for looking into it.

return bool(modules.intersection(course.advanced_modules))
30 changes: 27 additions & 3 deletions lms/djangoapps/edxnotes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,33 @@ def test_edxnotes_enabled(self, mock_generate_uid, mock_get_id_token, mock_get_t
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": True})
def test_edxnotes_disabled_if_edxnotes_flag_is_false(self):
"""
Tests if get_html is wrapped when feature flag is on, but edxnotes are
Tests that get_html is wrapped when feature flag is on, but edxnotes are
disabled for the course.
"""
self.assertEqual("original_get_html", self.problem.get_html())

@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False})
def test_edxnotes_disabled(self):
"""
Tests if get_html is not wrapped when feature flag is off.
Tests that get_html is not wrapped when feature flag is off.
"""
self.assertEqual("original_get_html", self.problem.get_html())

def test_edxnotes_studio(self):
"""
Tests if get_html is not wrapped when problem is rendered in Studio.
Tests that get_html is not wrapped when problem is rendered in Studio.
"""
self.problem.system.is_author_mode = True
self.assertEqual("original_get_html", self.problem.get_html())

def test_edxnotes_harvard_notes_enabled(self):
"""
Tests that get_html is not wrapped when Harvard Annotation Tool is enabled.
"""
self.course.advanced_modules = ["videoannotation", "imageannotation", "textannotation"]
enable_edxnotes_for_the_course(self.course, self.user.id)
self.assertEqual("original_get_html", self.problem.get_html())


@skipUnless(settings.FEATURES["ENABLE_EDXNOTES"], "EdxNotes feature needs to be enabled.")
class EdxNotesHelpersTest(ModuleStoreTestCase):
Expand Down Expand Up @@ -179,6 +187,22 @@ def test_edxnotes_not_enabled(self):
self.course.tabs = []
self.assertFalse(helpers.is_feature_enabled(self.course))

def test_edxnotes_harvard_notes_enabled(self):
"""
Tests that edxnotes are disabled when Harvard Annotation Tool is enabled.
"""
self.course.advanced_modules = ["foo", "imageannotation", "boo"]
self.assertFalse(helpers.is_feature_enabled(self.course))

self.course.advanced_modules = ["foo", "boo", "videoannotation"]
self.assertFalse(helpers.is_feature_enabled(self.course))

self.course.advanced_modules = ["textannotation", "foo", "boo"]
self.assertFalse(helpers.is_feature_enabled(self.course))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@polesye is checking a position of harvard module is required here or it possible to check only when harvard is present in advanced modules? like here:

harvard_modules = ["videoannotation", "imageannotation", "textannotation"]
for module in harvard_modules:
    self.course.advanced_modules = [module]
    self.assertFalse(helpers.is_feature_enabled(self.course))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is checking a position of harvard module is required here or it possible to check only when harvard is present in advanced modules? like here:

@olmar I want to make sure that position and other modules doesn't affect the result.


self.course.advanced_modules = ["textannotation", "videoannotation", "imageannotation"]
self.assertFalse(helpers.is_feature_enabled(self.course))

def test_edxnotes_enabled(self):
"""
Tests that edxnotes are enabled when the course tab configuration contains
Expand Down