Skip to content

Commit

Permalink
Remove deleted skills from skillIdToRubricsObject in the topic editor (
Browse files Browse the repository at this point in the history
…#11855)

* remove deleted skills from skillIdToRubricsObject in the topic editor

* handle missing skills in /fetch_skills gracefully
  • Loading branch information
Kevin Thomas authored Feb 4, 2021
1 parent 1ecf469 commit 619c620
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
5 changes: 1 addition & 4 deletions core/controllers/skill_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,7 @@ def get(self):

skill_ids = topic_services.get_all_skill_ids_assigned_to_some_topic()

try:
skills = skill_fetchers.get_multi_skills(skill_ids)
except Exception as e:
raise self.PageNotFoundException(e)
skills = skill_fetchers.get_multi_skills(skill_ids, strict=False)

skill_dicts = [skill.to_dict() for skill in skills]
self.values.update({
Expand Down
7 changes: 0 additions & 7 deletions core/controllers/skill_editor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,6 @@ def test_skill_data_handler_get_multiple_skills(self):
self.assertEqual(len(json_response['skills']), 1)
self.logout()

def test_skill_data_handler_get_fails(self):
self.login(self.ADMIN_EMAIL)
# Check GET returns 404 when cannot get skill by id.
self.delete_skill_model_and_memcache(self.admin_id, self.skill_id)
self.get_json(self.url, expected_status_int=404)
self.logout()


class SkillDescriptionHandlerTest(BaseSkillEditorControllerTests):
"""Tests for SkillDescriptionHandler."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ angular.module('oppia').factory('TopicEditorStateService', [
};
var _updateSkillIdToRubricsObject = function(skillIdToRubricsObject) {
for (var skillId in skillIdToRubricsObject) {
// Skips deleted skills.
if (!skillIdToRubricsObject[skillId]) {
continue;
}
var rubrics = skillIdToRubricsObject[skillId].map(function(rubric) {
return RubricObjectFactory.createFromBackendDict(rubric);
});
Expand Down

0 comments on commit 619c620

Please sign in to comment.