Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #7021: Add a skill tab in the topic viewer #7287

Merged
merged 47 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0db408e
user skill mastery backend
sophiewu6 Jul 21, 2019
975c124
lint
sophiewu6 Jul 21, 2019
afb044a
review changes
sophiewu6 Jul 23, 2019
3008786
lint
sophiewu6 Jul 23, 2019
ea5d418
review changes
sophiewu6 Jul 23, 2019
dfa9bec
lint
sophiewu6 Jul 23, 2019
03edb30
Merge branch 'develop' of https://github.com/oppia/oppia into fronten…
sophiewu6 Jul 24, 2019
ca1405d
review changes
sophiewu6 Jul 24, 2019
50b9be7
lint
sophiewu6 Jul 24, 2019
e992de5
edit docstring
sophiewu6 Jul 26, 2019
19df2d5
Merge branch 'develop' of https://github.com/oppia/oppia into fronten…
sophiewu6 Jul 27, 2019
47e5d5d
Merge branch 'user-skill-mastery' of https://github.com/sophiewu6/opp…
sophiewu6 Jul 27, 2019
c6404ce
review changes
sophiewu6 Jul 27, 2019
b449149
Merge branch 'user-skill-mastery' of https://github.com/sophiewu6/opp…
sophiewu6 Jul 27, 2019
ad613d2
update and show skill mastery
sophiewu6 Jul 28, 2019
709a4df
lint
sophiewu6 Jul 28, 2019
00c6031
lint
sophiewu6 Jul 28, 2019
658d7f6
travis test error and added log in check
sophiewu6 Jul 28, 2019
d986662
lint
sophiewu6 Jul 28, 2019
396bdba
Merge branch 'develop' of https://github.com/oppia/oppia into fronten…
sophiewu6 Jul 29, 2019
d11e885
fix for e2e test
sophiewu6 Jul 29, 2019
a0ab30d
changed file name
sophiewu6 Jul 29, 2019
029526e
review changes
sophiewu6 Jul 29, 2019
7e29fa8
review changes
sophiewu6 Jul 30, 2019
fa2eba7
review changes and small bug fix
sophiewu6 Jul 30, 2019
00031ae
lint
sophiewu6 Jul 30, 2019
7b1a384
merge with develop
sophiewu6 Jul 30, 2019
ba956fa
added new line at the end of files
sophiewu6 Jul 30, 2019
a6291aa
reverted changes to constants.js
sophiewu6 Jul 30, 2019
75c41be
review changes
sophiewu6 Jul 31, 2019
7a98672
added skill tab
sophiewu6 Aug 3, 2019
71664bb
lint
sophiewu6 Aug 4, 2019
2872a06
merged with develop
sophiewu6 Aug 4, 2019
b1b4a2e
lint
sophiewu6 Aug 4, 2019
a6d16f1
merged with develop
sophiewu6 Aug 4, 2019
d36dab5
review changes and frontend test
sophiewu6 Aug 5, 2019
8766255
merged with develop
sophiewu6 Aug 5, 2019
61d2885
review changes
sophiewu6 Aug 6, 2019
6d668ba
codeowner
sophiewu6 Aug 6, 2019
9a24864
merged
sophiewu6 Aug 6, 2019
22f7b92
lint
sophiewu6 Aug 6, 2019
1f743cf
review changes
sophiewu6 Aug 7, 2019
deda6da
merged with develop
sophiewu6 Aug 7, 2019
de47c02
merged with develop
sophiewu6 Aug 12, 2019
0cd3979
review comments
sophiewu6 Aug 13, 2019
3107f1e
lint
sophiewu6 Aug 13, 2019
b5e5497
minor change
sophiewu6 Aug 13, 2019
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
Prev Previous commit
Next Next commit
review changes
  • Loading branch information
sophiewu6 committed Jul 29, 2019
commit 029526e3750a0fc99701e250b2273db14abfdc2b
6 changes: 2 additions & 4 deletions core/controllers/skill_mastery.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def put(self):
try:
degree_of_mastery_per_skill[skill_id] = (
float(degree_of_mastery_per_skill[skill_id]))
except TypeError:
except (TypeError, ValueError):
raise self.InvalidInputException(
'Expected degree of mastery of skill %s to be a number.'
% skill_id)
Expand All @@ -65,9 +65,7 @@ def put(self):
except Exception as e:
raise self.PageNotFoundException(e)

degrees_of_mastery = degree_of_mastery_per_skill.values()

skill_services.create_multi_user_skill_mastery(
self.user_id, skill_ids, degrees_of_mastery)
self.user_id, degree_of_mastery_per_skill)

self.render_json(self.values)
26 changes: 9 additions & 17 deletions core/domain/skill_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,26 +839,18 @@ def save_user_skill_mastery(user_skill_mastery):
user_skill_mastery_model.put()


def create_multi_user_skill_mastery(user_id, skill_ids, degrees_of_mastery):
def create_multi_user_skill_mastery(user_id, degrees_of_mastery):
"""Creates the mastery of a user in multiple skills.

Args:
user_id: str. The user ID of the user.
skill_ids: list(str). Skill IDs of the requested skills.
degrees_of_mastery: list(float). The degrees of mastery of the user in
the requested skills.

Raises:
Exception: skill_ids and degrees_of_mastery lists have different
lengths.
degrees_of_mastery: dict(str, float). The keys are the requested
skill IDs. The values are the corresponding mastery degree of
the user.
"""
if len(skill_ids) != len(degrees_of_mastery):
raise Exception(
'skill_ids and degrees_of_mastery should have the same length.')

user_skill_mastery_models = []

for skill_id, degree_of_mastery in zip(skill_ids, degrees_of_mastery):
for skill_id, degree_of_mastery in degrees_of_mastery.iteritems():
user_skill_mastery_models.append(user_models.UserSkillMasteryModel(
id=user_models.UserSkillMasteryModel.construct_model_id(
user_id, skill_id),
Expand All @@ -867,7 +859,7 @@ def create_multi_user_skill_mastery(user_id, skill_ids, degrees_of_mastery):
user_models.UserSkillMasteryModel.put_multi(user_skill_mastery_models)


def get_skill_mastery(user_id, skill_id):
def get_user_skill_mastery(user_id, skill_id):
"""Fetches the mastery of user in a particular skill.

Args:
Expand All @@ -890,13 +882,13 @@ def get_skill_mastery(user_id, skill_id):
return user_skill_mastery_model.degree_of_mastery


def get_multi_skill_mastery(user_id, skill_ids):
def get_multi_user_skill_mastery(user_id, skill_ids):
"""Fetches the mastery of user in multiple skills.

Args:
user_id: str. The user ID of the user.
skill_ids: list(str). Skill IDs of the skill for which mastery degree
is requested.
skill_ids: list(str). Skill IDs of the skill for which mastery degree is
requested.

Returns:
degrees_of_mastery: dict(str, float|None). The keys are the requested
Expand Down
23 changes: 7 additions & 16 deletions core/domain/skill_services_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,19 +752,19 @@ def setUp(self):
skill_services.create_user_skill_mastery(
self.USER_ID, self.SKILL_ID_2, self.DEGREE_OF_MASTERY_2)

def test_get_skill_mastery(self):
degree_of_mastery = skill_services.get_skill_mastery(
def test_get_user_skill_mastery(self):
degree_of_mastery = skill_services.get_user_skill_mastery(
self.USER_ID, self.SKILL_ID_1)

self.assertEqual(degree_of_mastery, self.DEGREE_OF_MASTERY_1)

degree_of_mastery = skill_services.get_skill_mastery(
degree_of_mastery = skill_services.get_user_skill_mastery(
self.USER_ID, self.SKILL_ID_3)

self.assertEqual(degree_of_mastery, None)

def test_get_multi_skill_mastery(self):
degree_of_mastery = skill_services.get_multi_skill_mastery(
def test_get_multi_user_skill_mastery(self):
degree_of_mastery = skill_services.get_multi_user_skill_mastery(
self.USER_ID, self.SKILL_IDS)

self.assertEqual(
Expand All @@ -778,23 +778,14 @@ def test_create_multi_user_skill_mastery(self):
skill_id_4 = skill_services.get_new_skill_id()
skill_id_5 = skill_services.get_new_skill_id()
skill_services.create_multi_user_skill_mastery(
self.USER_ID, [skill_id_4, skill_id_5], [0.3, 0.5])
self.USER_ID, {skill_id_4: 0.3, skill_id_5: 0.5})

degrees_of_mastery = skill_services.get_multi_skill_mastery(
degrees_of_mastery = skill_services.get_multi_user_skill_mastery(
self.USER_ID, [skill_id_4, skill_id_5])

self.assertEqual(
degrees_of_mastery, {skill_id_4: 0.3, skill_id_5: 0.5})

def test_create_multi_user_skill_mastery_with_different_length_lists(self):
skill_id_4 = skill_services.get_new_skill_id()
skill_id_5 = skill_services.get_new_skill_id()
with self.assertRaisesRegexp(
Exception,
'skill_ids and degrees_of_mastery should have the same length.'):
skill_services.create_multi_user_skill_mastery(
self.USER_ID, [skill_id_4, skill_id_5], [0.3, 0.5, 0.8])


# TODO(lilithxxx): Remove this mock class and tests for the mock skill
# migrations once the actual functions are implemented.
Expand Down
2 changes: 1 addition & 1 deletion feconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,8 @@ def get_empty_ratings():
SKILL_EDITOR_URL_PREFIX = '/skill_editor'
SKILL_EDITOR_QUESTION_URL = '/skill_editor_question_handler'
SKILL_MASTERY_DATA_URL = '/skill_mastery_handler/data'
SKILL_RIGHTS_URL_PREFIX = '/skill_editor_handler/rights'
SKILL_PUBLISH_URL_PREFIX = '/skill_editor_handler/publish_skill'
SKILL_RIGHTS_URL_PREFIX = '/skill_editor_handler/rights'
SPLASH_URL = '/splash'
STORY_DATA_HANDLER = '/story_data_handler'
STORY_EDITOR_URL_PREFIX = '/story_editor'
Expand Down