Skip to content

Commit

Permalink
feat: [ACADEMIC-16209] Unit summary settings
Browse files Browse the repository at this point in the history
[https://jira.2u.com/browse/ACADEMIC-16209](https://jira.2u.com/browse/ACADEMIC-16209)

1. Add unit xpert unit summaries settings behind flag `summaryhook_summaries_configuration` added [here](https://github.com/edx/ai-aside/pull/45/files)
2. Only show the checkbox when the value is a `boolean` otherwise the feature is considerer `disabled` by the flag.
3. Update block handler to update this value via `api` exposed [here](edx/ai-aside#43)
4. Create `AiAsideSummary` configuration class to provide access to the `ai_aside.api` endpoints.
  • Loading branch information
germanolleunlp committed Aug 21, 2023
1 parent 0fdae1d commit b4566cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cms/lib/ai_aside_summary_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ def is_enabled(self):
try:
from ai_aside.config_api.api import is_summary_config_enabled
return is_summary_config_enabled(self.course_key)
except (ImportError, ModuleNotFoundError):
except Exception:
return False

def is_summary_enabled(self, unit_key=None):
"""
Define if the summary configuration is enabled in ai_aside
"""
try:
from ai_aside.config_api.api import is_summary_enabled
from ai_aside.config_api.api import is_course_present, is_summary_enabled
if not is_course_present(self.course_key):
return None
return is_summary_enabled(self.course_key, unit_key)
except (ImportError, ModuleNotFoundError):
except Exception:
return None

def set_summary_settings(self, unit_key, settings=None):
Expand All @@ -50,5 +52,5 @@ def set_summary_settings(self, unit_key, settings=None):
try:
from ai_aside.config_api.api import set_unit_settings
return set_unit_settings(self.course_key, unit_key, settings)
except (ImportError, ModuleNotFoundError):
except Exception:
return None
12 changes: 11 additions & 1 deletion cms/lib/test/test_ai_aside_summary_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import sys
from unittest import TestCase
from unittest.mock import Mock, patch
from unittest.mock import Mock

from opaque_keys.edx.keys import CourseKey, UsageKey

Expand Down Expand Up @@ -36,12 +36,22 @@ def test_is_summary_enabled(self):
Check the summary configuration value for a particular course and an optional unit using the ai_aside lib.
"""
ai_aside_summary_config = AiAsideSummaryConfig(self.COURSE_KEY)
ai_aside.is_course_present.return_value = True
ai_aside.is_summary_enabled.return_value = True
self.assertTrue(ai_aside_summary_config.is_summary_enabled())

ai_aside.is_course_present.return_value = True
ai_aside.is_summary_enabled.return_value = False
self.assertFalse(ai_aside_summary_config.is_summary_enabled(self.UNIT_KEY))

ai_aside.is_course_present.return_value = False
ai_aside.is_summary_enabled.return_value = True
self.assertIsNone(ai_aside_summary_config.is_summary_enabled())

ai_aside.is_course_present.return_value = False
ai_aside.is_summary_enabled.return_value = False
self.assertIsNone(ai_aside_summary_config.is_summary_enabled(self.UNIT_KEY))

def test_set_summary_settings(self):
"""
Set the summary configuration settings for a particular unit using the ai_aside lib.
Expand Down

0 comments on commit b4566cf

Please sign in to comment.