Skip to content

Commit

Permalink
Fix #6210: Added an exploration whitelist (#6255)
Browse files Browse the repository at this point in the history
* fix #6210

* fixed issue

* fix lint

* fixed merge conflicts

* minor change

* made review changes

* made review changes

* made review change
  • Loading branch information
aks681 authored and seanlip committed Feb 27, 2019
1 parent 1d67823 commit 76f5d20
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 12 deletions.
2 changes: 2 additions & 0 deletions assets/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ var constants = {

"ENABLE_NEW_STRUCTURE_EDITORS": true,

"ENABLE_PREREQUISITE_SKILLS": false,

"ENABLE_NEW_STRUCTURE_PLAYERS": false,

"NUM_QUESTIONS_PER_PAGE": 10,
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ def get(self, exploration_id):
self.render_json({
'is_improvements_tab_enabled':
config_domain.IS_IMPROVEMENTS_TAB_ENABLED.value,
'is_playthrough_recording_enabled':
exploration_id in whitelisted_exploration_ids_for_playthroughs,
'is_exploration_whitelisted':
exploration_id in whitelisted_exploration_ids_for_playthroughs
})
6 changes: 3 additions & 3 deletions core/controllers/features_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_can_record_playthroughs_in_whitelisted_explorations(self):

json_response = self.get_json(exploration_features_url(self.EXP_ID))

self.assertTrue(json_response['is_playthrough_recording_enabled'])
self.assertTrue(json_response['is_exploration_whitelisted'])

def test_can_not_record_playthroughs_with_empty_whitelist(self):
self.set_config_property(
Expand All @@ -60,7 +60,7 @@ def test_can_not_record_playthroughs_with_empty_whitelist(self):

json_response = self.get_json(exploration_features_url(self.EXP_ID))

self.assertFalse(json_response['is_playthrough_recording_enabled'])
self.assertFalse(json_response['is_exploration_whitelisted'])

def test_can_not_record_playthroughs_for_exploration_not_in_whitelist(self):
self.set_config_property(
Expand All @@ -69,7 +69,7 @@ def test_can_not_record_playthroughs_for_exploration_not_in_whitelist(self):

json_response = self.get_json(exploration_features_url(self.EXP_ID))

self.assertFalse(json_response['is_playthrough_recording_enabled'])
self.assertFalse(json_response['is_exploration_whitelisted'])


class ExplorationImprovementsTabFeatureTest(ExplorationFeaturesTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ oppia.directive('outcomeDestinationEditor', [
StateEditorService, StateGraphLayoutService, UserService,
EXPLORATION_AND_SKILL_ID_PATTERN, PLACEHOLDER_OUTCOME_DEST) {
var currentStateName = null;
$scope.canAddPrerequisiteSkill =
constants.ENABLE_NEW_STRUCTURE_EDITORS;
$scope.canAddPrerequisiteSkill = (
constants.ENABLE_NEW_STRUCTURE_EDITORS &&
constants.ENABLE_PREREQUISITE_SKILLS &&
StateEditorService.isExplorationWhitelisted());

$scope.$on('saveOutcomeDestDetails', function() {
// Create new state if specified.
Expand Down
4 changes: 3 additions & 1 deletion core/templates/dev/head/components/OutcomeEditorDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ oppia.directive('outcomeEditor', [
$scope.editOutcomeForm = {};
$scope.isInQuestionMode = StateEditorService.isInQuestionMode;
$scope.canAddPrerequisiteSkill =
constants.ENABLE_NEW_STRUCTURE_EDITORS;
constants.ENABLE_NEW_STRUCTURE_EDITORS &&
constants.ENABLE_PREREQUISITE_SKILLS &&
StateEditorService.isExplorationWhitelisted();
$scope.feedbackEditorIsOpen = false;
$scope.destinationEditorIsOpen = false;
$scope.correctnessLabelEditorIsOpen = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<b>Refresher exploration ID (optional):</b>
<input type="text" name="refresherExplorationId" ng-model="outcome.refresherExplorationId" class="form-control protractor-test-add-refresher-exploration-id" tabindex="0" aria-invalid="false" ng-pattern="globalIdPattern">
</div>
<div style="margin-top: 12px;" ng-if="isSelfLoop() && canAddPrerequisiteSkill">
<div style="margin-top: 12px;" ng-if="canAddPrerequisiteSkill">
<b>Prerequisite skill ID (optional):&nbsp;</b>
<input type="text" name="missingPrerequisiteSkillId" ng-model="outcome.missingPrerequisiteSkillId" class="form-control" tabindex="0" aria-invalid="false" ng-pattern="explorationAndSkillIdPattern">
<input type="text" name="missingPrerequisiteSkillId" ng-model="outcome.missingPrerequisiteSkillId" class="form-control" tabindex="0" aria-invalid="false" ng-model-options="{allowInvalid: true}" ng-pattern="explorationAndSkillIdPattern">
<p style="font-size: 0.8em;">
<i> Mention the skill that this state requires so that a learner who is stuck in the state can quickly learn the
required material and continue with the exploration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ oppia.controller('ExplorationEditor', [
EditabilityService.markTranslatable();
}

StateEditorService.updateExplorationWhitelistedStatus(
featuresData.is_exploration_whitelisted);

GraphDataService.recompute();

if (!StateEditorService.getActiveStateName() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ oppia.factory('StateEditorService', [
// interaction.
var interaction = null;
var misconceptions = [];
var explorationIsWhitelisted = false;

return {
getActiveStateName: function() {
Expand All @@ -43,6 +44,12 @@ oppia.factory('StateEditorService', [
}
activeStateName = newActiveStateName;
},
isExplorationWhitelisted: function() {
return explorationIsWhitelisted;
},
updateExplorationWhitelistedStatus: function(value) {
explorationIsWhitelisted = value;
},
setMisconceptions: function(newMisconceptions) {
misconceptions = newMisconceptions;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ oppia.directive('stateResponses', [
$scope.$broadcast('saveOutcomeDestDetails');

EditorFirstTimeEventsService.registerFirstSaveRuleEvent();

// Close the modal and save it afterwards.
$uibModalInstance.close({
tmpRule: angular.copy($scope.tmpRule),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ oppia.factory('ExplorationFeaturesService', [function() {
settings.isImprovementsTabEnabled =
featuresData.is_improvements_tab_enabled;
settings.isPlaythroughRecordingEnabled =
featuresData.is_playthrough_recording_enabled;
featuresData.is_exploration_whitelisted;
if (explorationData.param_changes &&
explorationData.param_changes.length > 0) {
this.enableParameters();
Expand Down

0 comments on commit 76f5d20

Please sign in to comment.