Skip to content

Commit

Permalink
Redesigning and Updating the Learner Dashboard page Milestone-1.2 (op…
Browse files Browse the repository at this point in the history
…pia#13081)

* Added LearnerGoalsModel

* Resolved typescript errors

* Removed extra lines

* Added new changes

* Added codeowners

* Added test file in shards

* Added frontend tests

* Resolving errors

* Modified backend tests

* Removed extra function

* Added backend test

* Changed Max current goals limit

* Changed export policy

* Removed default value

* Added new changes

* Changed docstrings

* Added backend test

* Added backend test

* Added Exceptions

* Added backend test

* Removed extra test

* Lint fix
  • Loading branch information
krishita30j authored Jun 27, 2021
1 parent 86cd09e commit ea0628d
Show file tree
Hide file tree
Showing 31 changed files with 1,524 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@
/core/controllers/creator_dashboard*.py @nithusha21
/core/controllers/email_dashboard*.py @nithusha21
/core/controllers/learner_dashboard*.py @nithusha21
/core/controllers/learner_goals*.py @nithusha21
/core/controllers/learner_playlist*.py @nithusha21
/core/controllers/subscriptions*.py @nithusha21
/core/domain/activity*.py @nithusha21
/core/domain/learner_goals_services*.py @nithusha21
/core/domain/learner_playlist_services*.py @nithusha21
/core/domain/learner_progress*.py @nithusha21
/core/domain/subscription_services*.py @nithusha21
Expand Down
5 changes: 5 additions & 0 deletions core/controllers/learner_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def get(self):
learner_progress_services.get_collection_summary_dicts(
learner_progress.collection_playlist_summaries))

topics_to_learn_summary_dicts = (
learner_progress_services.get_displayable_topic_summary_dicts(
self.user_id, learner_progress.topics_to_learn_summaries))

full_thread_ids = subscription_services.get_all_threads_subscribed_to(
self.user_id)
if len(full_thread_ids) > 0:
Expand Down Expand Up @@ -133,6 +137,7 @@ def get(self):
partially_learnt_topic_summary_dicts),
'exploration_playlist': exploration_playlist_summary_dicts,
'collection_playlist': collection_playlist_summary_dicts,
'topics_to_learn': topics_to_learn_summary_dicts,
'number_of_nonexistent_activities': (
number_of_nonexistent_activities),
'completed_to_incomplete_collections': (
Expand Down
50 changes: 50 additions & 0 deletions core/controllers/learner_dashboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ class LearnerDashboardHandlerTests(test_utils.GenericTestBase):
STORY_TITLE_1 = 'Story title 1'
STORY_ID_2 = 'STORY_2'
STORY_TITLE_2 = 'Story title 2'
STORY_ID_3 = 'STORY_3'
STORY_TITLE_3 = 'Story title 3'

TOPIC_ID_1 = 'TOPIC_1'
TOPIC_NAME_1 = 'Topic title 1'
TOPIC_ID_2 = 'TOPIC_2'
TOPIC_NAME_2 = 'Topic title 2'
TOPIC_ID_3 = 'TOPIC_3'
TOPIC_NAME_3 = 'Topic title 3'

subtopic_0 = topic_domain.Subtopic(
0, 'Title 1', ['skill_id_1'], 'image.svg',
Expand Down Expand Up @@ -257,6 +261,33 @@ def test_can_see_partially_learnt_topics(self):
response['partially_learnt_topics_list'][0]['id'], self.TOPIC_ID_1)
self.logout()

def test_can_see_topics_to_learn(self):
self.login(self.VIEWER_EMAIL)

response = self.get_json(feconf.LEARNER_DASHBOARD_DATA_URL)
self.assertEqual(len(response['topics_to_learn']), 0)

self.save_new_topic(
self.TOPIC_ID_1, self.owner_id, name=self.TOPIC_NAME_1,
url_fragment='topic-one',
description='A new topic', canonical_story_ids=[],
additional_story_ids=[], uncategorized_skill_ids=[],
subtopics=[self.subtopic_0], next_subtopic_id=1)
topic_services.publish_topic(self.TOPIC_ID_1, self.admin_id)
self.save_new_story(self.STORY_ID_2, self.owner_id, self.TOPIC_ID_1)
topic_services.add_canonical_story(
self.owner_id, self.TOPIC_ID_1, self.STORY_ID_2)
topic_services.publish_story(
self.TOPIC_ID_1, self.STORY_ID_2, self.admin_id)

learner_progress_services.validate_and_add_topic_to_learn_goal(
self.viewer_id, self.TOPIC_ID_1)
response = self.get_json(feconf.LEARNER_DASHBOARD_DATA_URL)
self.assertEqual(len(response['topics_to_learn']), 1)
self.assertEqual(
response['topics_to_learn'][0]['id'], self.TOPIC_ID_1)
self.logout()

def test_can_see_exploration_playlist(self):
self.login(self.VIEWER_EMAIL)

Expand Down Expand Up @@ -359,6 +390,20 @@ def test_get_learner_dashboard_ids(self):
self.TOPIC_ID_2, self.STORY_ID_2, self.admin_id)
topic_services.publish_topic(self.TOPIC_ID_2, self.admin_id)

self.save_new_topic(
self.TOPIC_ID_3, self.owner_id, name=self.TOPIC_NAME_3,
url_fragment='topic-three',
description='A new topic', canonical_story_ids=[],
additional_story_ids=[], uncategorized_skill_ids=[],
subtopics=[self.subtopic_1], next_subtopic_id=1)
self.save_new_story(self.STORY_ID_3, self.owner_id, self.TOPIC_ID_3)
topic_services.add_canonical_story(
self.owner_id, self.TOPIC_ID_3, self.STORY_ID_3)

topic_services.publish_story(
self.TOPIC_ID_3, self.STORY_ID_3, self.admin_id)
topic_services.publish_topic(self.TOPIC_ID_3, self.admin_id)

state_name = 'state_name'
version = 1

Expand All @@ -383,6 +428,8 @@ def test_get_learner_dashboard_ids(self):
self.viewer_id, self.TOPIC_ID_1)
learner_progress_services.record_topic_started(
self.viewer_id, self.TOPIC_ID_2)
learner_progress_services.validate_and_add_topic_to_learn_goal(
self.viewer_id, self.TOPIC_ID_3)

response = self.get_json(feconf.LEARNER_DASHBOARD_IDS_DATA_URL)
learner_dashboard_activity_ids = (
Expand Down Expand Up @@ -418,6 +465,9 @@ def test_get_learner_dashboard_ids(self):
self.assertEqual(
learner_dashboard_activity_ids['partially_learnt_topic_ids'],
[self.TOPIC_ID_2])
self.assertEqual(
learner_dashboard_activity_ids['topic_ids_to_learn'],
[self.TOPIC_ID_3])

def test_get_threads_after_updating_thread_summaries(self):
self.login(self.OWNER_EMAIL)
Expand Down
59 changes: 59 additions & 0 deletions core/controllers/learner_goals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2021 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Controllers for the learner goals."""

from __future__ import absolute_import # pylint: disable=import-only-modules
from __future__ import unicode_literals # pylint: disable=import-only-modules

from constants import constants
from core.controllers import acl_decorators
from core.controllers import base
from core.domain import learner_goals_services
from core.domain import learner_progress_services


class LearnerGoalsHandler(base.BaseHandler):
"""Handles operations related to the learner goals."""

@acl_decorators.can_access_learner_dashboard
def post(self, activity_type, topic_id):
belongs_to_learnt_list = False
goals_limit_exceeded = False

if activity_type == constants.ACTIVITY_TYPE_LEARN_TOPIC:
belongs_to_learnt_list, goals_limit_exceeded = (
learner_progress_services.validate_and_add_topic_to_learn_goal(
self.user_id, topic_id))
else:
raise self.InvalidInputException('Invalid activityType: %s' % (
activity_type))

self.values.update({
'belongs_to_learnt_list': belongs_to_learnt_list,
'goals_limit_exceeded': goals_limit_exceeded
})

self.render_json(self.values)

@acl_decorators.can_access_learner_dashboard
def delete(self, activity_type, topic_id):
if activity_type == constants.ACTIVITY_TYPE_LEARN_TOPIC:
learner_goals_services.remove_topics_from_learn_goal(
self.user_id, [topic_id])
else:
raise self.InvalidInputException('Invalid activityType: %s' % (
activity_type))

self.render_json(self.values)
Loading

0 comments on commit ea0628d

Please sign in to comment.