Skip to content

Commit

Permalink
Split flag for new structure viewers (oppia#7898)
Browse files Browse the repository at this point in the history
* Split flag

* added comment

* fixed test
  • Loading branch information
aks681 authored and seanlip committed Nov 5, 2019
1 parent e54f5ce commit 0134ff7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
8 changes: 8 additions & 0 deletions assets/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,16 @@ export = {

"ENABLE_PREREQUISITE_SKILLS": false,

// For the full new structures viewer features, both
// ENABLE_NEW_STRUCTURE_PLAYERS and ENABLE_NEW_STRUCTURE_VIEWER_UPDATES has
// to be true. Only ENABLE_NEW_STRUCTURE_PLAYERS can be true if just the
// players need to be accessed, but without story progress updation.
// This is split up so as to access the viewers in production without
// exposing the POST and PUT endpoints just yet.
"ENABLE_NEW_STRUCTURE_PLAYERS": false,

"ENABLE_NEW_STRUCTURE_VIEWER_UPDATES": false,

"ENABLE_SOLICIT_ANSWER_DETAILS_FEATURE": true,

"MAX_SKILLS_PER_QUESTION": 3,
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/story_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class StoryNodeCompletionHandler(base.BaseHandler):

@acl_decorators.can_access_story_viewer_page
def post(self, story_id, node_id):
if not constants.ENABLE_NEW_STRUCTURE_PLAYERS:
if not constants.ENABLE_NEW_STRUCTURE_VIEWER_UPDATES:
raise self.PageNotFoundException

try:
Expand Down
12 changes: 6 additions & 6 deletions core/controllers/story_viewer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,18 @@ def test_get_fails_when_new_structures_not_enabled(self):
class StoryNodeCompletionHandlerTests(BaseStoryViewerControllerTests):

def test_post_fails_when_new_structures_not_enabled(self):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', False):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', False):
self.post_json(
'%s/%s/%s' % (
feconf.STORY_NODE_COMPLETION_URL_PREFIX, 'story_id_1',
'node_1'),
{}, csrf_token=csrf_token, expected_status_int=404)

def test_post_succeeds_when_story_and_node_exist(self):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
csrf_token = self.get_new_csrf_token()

self.post_json(
Expand All @@ -203,7 +203,7 @@ def test_post_succeeds_when_story_and_node_exist(self):
self.assertEqual(completed_nodes[1], self.NODE_ID_1)

def test_post_fails_when_story_does_not_exist(self):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
csrf_token = self.get_new_csrf_token()

self.post_json(
Expand All @@ -213,7 +213,7 @@ def test_post_fails_when_story_does_not_exist(self):
{}, csrf_token=csrf_token, expected_status_int=404)

def test_post_fails_when_node_does_not_exist(self):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
csrf_token = self.get_new_csrf_token()

self.post_json(
Expand All @@ -228,7 +228,7 @@ def test_post_fails_when_story_is_not_published(self):
new_story_id, 'Title', self.TOPIC_ID)
story_services.save_new_story(self.admin_id, story)

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
csrf_token = self.get_new_csrf_token()

self.post_json(
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/suggestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class SuggestionToTopicActionHandler(base.BaseHandler):
@acl_decorators.get_decorator_for_accepting_suggestion(
acl_decorators.can_edit_topic)
def put(self, target_id, suggestion_id):
if not constants.ENABLE_NEW_STRUCTURE_PLAYERS:
if not constants.ENABLE_NEW_STRUCTURE_VIEWER_UPDATES:
raise self.PageNotFoundException

if suggestion_id.split('.')[0] != suggestion_models.TARGET_TYPE_TOPIC:
Expand Down
14 changes: 7 additions & 7 deletions core/controllers/suggestion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ def test_accept_question_suggestion(self):

self.login(self.ADMIN_EMAIL)
csrf_token = self.get_new_csrf_token()
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
self.put_json('%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX,
suggestion_to_accept['target_id'],
Expand Down Expand Up @@ -775,7 +775,7 @@ def test_cannot_access_suggestion_to_topic_handler(self):

csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', False):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', False):
self.put_json(
'%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX, self.topic_id,
Expand Down Expand Up @@ -811,7 +811,7 @@ def test_suggestion_to_topic_handler_with_invalid_target_type(self):

csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
response = self.put_json(
'%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX,
Expand Down Expand Up @@ -842,7 +842,7 @@ def test_suggestion_to_topic_handler_with_invalid_target_id(self):

csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
response = self.put_json(
'%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX,
Expand Down Expand Up @@ -872,7 +872,7 @@ def test_suggestion_to_topic_handler_with_invalid_action(self):

csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
response = self.put_json(
'%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX,
Expand Down Expand Up @@ -904,7 +904,7 @@ def test_reject_suggestion_to_topic(self):

csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
self.put_json('%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX,
suggestion_to_reject['target_id'],
Expand Down Expand Up @@ -939,7 +939,7 @@ def test_accept_suggestion_to_topic(self):

csrf_token = self.get_new_csrf_token()

with self.swap(constants, 'ENABLE_NEW_STRUCTURE_PLAYERS', True):
with self.swap(constants, 'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES', True):
self.put_json('%s/topic/%s/%s' % (
feconf.SUGGESTION_ACTION_URL_PREFIX,
suggestion_to_accept['target_id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class StoryContents {
nodeIsVisited[currentNodeIndex] = true;
var currentNode = nodes[currentNodeIndex];

startingNode.getAcquiredSkillIds().forEach((skillId) => {
currentNode.getAcquiredSkillIds().forEach((skillId) => {
simulatedSkillIds.add(skillId);
});
for (var i = 0; i < currentNode.getDestinationNodeIds().length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ angular.module('oppia').directive('conversationSkin', [
'WindowDimensionsService', 'COMPONENT_NAME_FEEDBACK',
'CONTENT_FOCUS_LABEL_PREFIX', 'CONTINUE_BUTTON_FOCUS_LABEL',
'DEFAULT_TWITTER_SHARE_MESSAGE_EDITOR',
'ENABLE_NEW_STRUCTURE_VIEWER_UPDATES',
'ENABLE_SOLICIT_ANSWER_DETAILS_FEATURE',
'EVENT_ACTIVE_CARD_CHANGED', 'EVENT_AUTOPLAY_AUDIO',
'EVENT_NEW_CARD_AVAILABLE', 'EVENT_NEW_CARD_OPENED',
Expand Down Expand Up @@ -397,6 +398,7 @@ angular.module('oppia').directive('conversationSkin', [
WindowDimensionsService, COMPONENT_NAME_FEEDBACK,
CONTENT_FOCUS_LABEL_PREFIX, CONTINUE_BUTTON_FOCUS_LABEL,
DEFAULT_TWITTER_SHARE_MESSAGE_EDITOR,
ENABLE_NEW_STRUCTURE_VIEWER_UPDATES,
ENABLE_SOLICIT_ANSWER_DETAILS_FEATURE,
EVENT_ACTIVE_CARD_CHANGED, EVENT_AUTOPLAY_AUDIO,
EVENT_NEW_CARD_AVAILABLE, EVENT_NEW_CARD_OPENED,
Expand Down Expand Up @@ -796,7 +798,8 @@ angular.module('oppia').directive('conversationSkin', [
}

if (ExplorationPlayerStateService.isInStoryChapterMode() &&
$scope.nextCard.isTerminal()) {
$scope.nextCard.isTerminal() &&
ENABLE_NEW_STRUCTURE_VIEWER_UPDATES) {
var storyId = UrlService.getUrlParams().story_id;
var nodeId = UrlService.getUrlParams().node_id;
StoryViewerBackendApiService.recordStoryNodeCompletion(
Expand Down

0 comments on commit 0134ff7

Please sign in to comment.