Skip to content

Commit

Permalink
[GSoC'24] M2.2: Update the topic viewer page to show assigned classro…
Browse files Browse the repository at this point in the history
…om (oppia#20663)

* Fix part of oppia#19849: Update topic viewer breadcrumbs

* fix staging topic

* fix test

* update i18n key

* add test for classroom

* remove redundant i18 test bed
  • Loading branch information
AFZL210 authored Jul 18, 2024
1 parent efe9f77 commit dd0f495
Show file tree
Hide file tree
Showing 24 changed files with 216 additions and 260 deletions.
1 change: 1 addition & 0 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
"I18N_ATTRIBUTION_PRINT_STEP_TWO": "Attach a copy of the \"<[link]>\"",
"I18N_ATTRIBUTION_PRINT_TITLE": "Attribute in Print",
"I18N_ATTRIBUTION_TITLE": "How to attribute this lesson for sharing or reusing",
"I18N_BACK_TO_CLASSROOM": "Back to <[classroomName]>",
"I18N_BACK_TO_CLASSROOMS": "Back to Classrooms",
"I18N_BACK_TO_HOME_TEXT": "Back to Home",
"I18N_BLOG_AUTHOR_PROFILE_PAGE_BREADCRUMB": "Author Profile",
Expand Down
1 change: 1 addition & 0 deletions assets/i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
"I18N_ATTRIBUTION_PRINT_STEP_TWO": "Step two of attributing Oppia in Print",
"I18N_ATTRIBUTION_PRINT_TITLE": "Title of the attribution section that explains how to attribute Oppia in Print",
"I18N_ATTRIBUTION_TITLE": "Title of the modal that lists the various ways in which Oppia can be attributed.",
"I18N_BACK_TO_CLASSROOM": "Text which we show in topic viewer page mobile breadcrumbs to redirect to the classroom page.",
"I18N_BACK_TO_CLASSROOMS": "Text which we show in classroom page mobile breadcrumbs if we have more than one public classrooms.",
"I18N_BACK_TO_HOME_TEXT": "Text displayed in breadcrumbs - shown in the top left corner.",
"I18N_BLOG_AUTHOR_PROFILE_PAGE_BREADCRUMB": "Text displayed in the Blog Author Profile Page. - Text shown in the top left corner of the nav bar.",
Expand Down
14 changes: 13 additions & 1 deletion core/controllers/topic_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from core.constants import constants
from core.controllers import acl_decorators
from core.controllers import base
from core.domain import classroom_config_services
from core.domain import email_manager
from core.domain import platform_parameter_list
from core.domain import platform_parameter_services
Expand Down Expand Up @@ -168,6 +169,10 @@ def get(self, topic_name: str) -> None:
for skill_id in all_skill_ids:
degrees_of_mastery[skill_id] = None

classroom_name = (
classroom_config_services.get_classroom_name_for_topic_id(
topic.id))

self.values.update({
'topic_id': topic.id,
'topic_name': topic.name,
Expand All @@ -180,6 +185,13 @@ def get(self, topic_name: str) -> None:
'skill_descriptions': skill_descriptions,
'practice_tab_is_displayed': topic.practice_tab_is_displayed,
'meta_tag_content': topic.meta_tag_content,
'page_title_fragment_for_web': topic.page_title_fragment_for_web
'page_title_fragment_for_web': topic.page_title_fragment_for_web,
'classroom_name': (
None if (
classroom_name
==
str(constants.CLASSROOM_NAME_FOR_UNATTACHED_TOPICS)
) else classroom_name
)
})
self.render_json(self.values)
45 changes: 36 additions & 9 deletions core/controllers/topic_viewer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from core import feconf
from core.constants import constants
from core.domain import classroom_config_services
from core.domain import platform_parameter_list
from core.domain import question_services
from core.domain import skill_services
Expand Down Expand Up @@ -99,6 +100,8 @@ def setUp(self) -> None:
skill_services.create_user_skill_mastery(
self.user_id, self.skill_id_2, 0.5)

self.math_classroom = self.save_new_valid_classroom()


class TopicViewerPageTests(BaseTopicViewerControllerTests):

Expand Down Expand Up @@ -127,8 +130,13 @@ class TopicPageDataHandlerTests(
BaseTopicViewerControllerTests, test_utils.EmailTestBase):

def test_get_with_no_user_logged_in(self) -> None:
self.math_classroom.topic_id_to_prerequisite_topic_ids = {
self.topic_id: []
}
classroom_config_services.update_classroom(self.math_classroom)

json_response = self.get_json(
'%s/staging/%s' % (feconf.TOPIC_DATA_HANDLER, 'public'))
'%s/math/%s' % (feconf.TOPIC_DATA_HANDLER, 'public'))
expected_dict = {
'topic_name': 'public_topic_name',
'topic_id': self.topic_id,
Expand Down Expand Up @@ -173,8 +181,20 @@ def test_get_with_no_user_logged_in(self) -> None:
self.skill_id_1: 'Skill Description 1',
self.skill_id_2: 'Skill Description 2'
},
'practice_tab_is_displayed': False
'practice_tab_is_displayed': False,
'classroom_name': 'math'
}

self.assertDictContainsSubset(expected_dict, json_response)

# Test with no classroom assigned.
self.math_classroom.topic_id_to_prerequisite_topic_ids = {}
expected_dict['classroom_name'] = None
classroom_config_services.update_classroom(self.math_classroom)

json_response = self.get_json(
'%s/staging/%s' % (feconf.TOPIC_DATA_HANDLER, 'public'))

self.assertDictContainsSubset(expected_dict, json_response)

@test_utils.set_platform_parameters(
Expand Down Expand Up @@ -239,7 +259,8 @@ def test_get_with_user_logged_in(self) -> None:
'skill_descriptions': {
self.skill_id_2: 'Skill Description 2'
},
'practice_tab_is_displayed': False
'practice_tab_is_displayed': False,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)

Expand Down Expand Up @@ -290,7 +311,8 @@ def test_get_with_no_skills_ids(self) -> None:
'subtopics': [],
'degrees_of_mastery': {},
'skill_descriptions': {},
'practice_tab_is_displayed': False
'practice_tab_is_displayed': False,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)

Expand Down Expand Up @@ -346,7 +368,8 @@ def test_get_with_five_or_more_questions(self) -> None:
'skill_descriptions': {
self.skill_id_1: 'Skill Description 1'
},
'practice_tab_is_displayed': True
'practice_tab_is_displayed': True,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)
self.logout()
Expand Down Expand Up @@ -403,7 +426,8 @@ def test_get_with_twenty_or_more_questions(self) -> None:
'skill_descriptions': {
self.skill_id_1: 'Skill Description 1',
},
'practice_tab_is_displayed': True
'practice_tab_is_displayed': True,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)
self.logout()
Expand Down Expand Up @@ -459,7 +483,8 @@ def test_get_with_twenty_or_more_questions_with_multiple_skills(
'topic_id': self.topic_id,
'canonical_story_dicts': [],
'additional_story_dicts': [],
'practice_tab_is_displayed': True
'practice_tab_is_displayed': True,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)
self.logout()
Expand Down Expand Up @@ -516,7 +541,8 @@ def test_get_with_lesser_questions_with_fifty_or_more_skills(
'topic_id': self.topic_id,
'canonical_story_dicts': [],
'additional_story_dicts': [],
'practice_tab_is_displayed': False
'practice_tab_is_displayed': False,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)
self.logout()
Expand Down Expand Up @@ -573,7 +599,8 @@ def test_get_with_more_questions_with_fifty_or_more_skills(self) -> None:
'topic_id': self.topic_id,
'canonical_story_dicts': [],
'additional_story_dicts': [],
'practice_tab_is_displayed': True
'practice_tab_is_displayed': True,
'classroom_name': None
}
self.assertDictContainsSubset(expected_dict, json_response)
self.logout()
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('Read only topic object Factory', () => {
practice_tab_is_displayed: false,
meta_tag_content: 'Topic meta tag content',
page_title_fragment_for_web: 'topic page title',
classroom_name: 'math',
};

_sampleReadOnlyTopic =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface ReadOnlyTopicBackendDict {
practice_tab_is_displayed: boolean;
meta_tag_content: string;
page_title_fragment_for_web: string;
classroom_name: string | null;
}

export class ReadOnlyTopic {
Expand All @@ -64,6 +65,7 @@ export class ReadOnlyTopic {
_practiceTabIsDisplayed: boolean;
_metaTagContent: string;
_pageTitleFragmentForWeb: string;
_classroomName: string | null;

constructor(
topicName: string,
Expand All @@ -77,7 +79,8 @@ export class ReadOnlyTopic {
skillDescriptions: SkillIdToDescriptionMap,
practiceTabIsDisplayed: boolean,
metaTagContent: string,
pageTitleFragmentForWeb: string
pageTitleFragmentForWeb: string,
classroomName: string | null
) {
this._topicName = topicName;
this._topicId = topicId;
Expand All @@ -91,6 +94,7 @@ export class ReadOnlyTopic {
this._practiceTabIsDisplayed = practiceTabIsDisplayed;
this._metaTagContent = metaTagContent;
this._pageTitleFragmentForWeb = pageTitleFragmentForWeb;
this._classroomName = classroomName;
}

getTopicName(): string {
Expand Down Expand Up @@ -140,6 +144,10 @@ export class ReadOnlyTopic {
getPageTitleFragmentForWeb(): string {
return this._pageTitleFragmentForWeb;
}

getClassroomName(): string | null {
return this._classroomName;
}
}

@Injectable({
Expand Down Expand Up @@ -233,7 +241,8 @@ export class ReadOnlyTopicObjectFactory {
skillDescriptions,
topicDataDict.practice_tab_is_displayed,
topicDataDict.meta_tag_content,
topicDataDict.page_title_fragment_for_web
topicDataDict.page_title_fragment_for_web,
topicDataDict.classroom_name
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ describe('Topic viewer backend API service', () => {
practice_tab_is_displayed: false,
meta_tag_content: 'Topic meta tag content',
page_title_fragment_for_web: 'topic page title',
classroom_name: 'math',
};

sampleDataResultsObjects =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('Learner view info component', () => {
practice_tab_is_displayed: false,
meta_tag_content: 'content',
page_title_fragment_for_web: 'title',
classroom_name: 'math',
} as ReadOnlyTopicBackendDict)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('Lesson player header component', () => {
practice_tab_is_displayed: false,
meta_tag_content: 'content',
page_title_fragment_for_web: 'title',
classroom_name: 'math',
} as ReadOnlyTopicBackendDict)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
}

.oppia-story-navbar-topic {
color: #fff;
color: white;
font-family: 'Roboto', Arial, sans-serif;
font-size: 12px;
}

.oppia-story-navbar-topic:hover {
color: #fff;
.oppia-story-navbar-topic span {
color: white;
}

.oppia-story-viewer-nav-separator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('Subtopic viewer navbar breadcrumb component', () => {
practice_tab_is_displayed: false,
meta_tag_content: 'content',
page_title_fragment_for_web: 'title',
classroom_name: 'math',
} as ReadOnlyTopicBackendDict)
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
[topicDescription]="topic.getDescription()"
[canonicalStorySummaries]="canonicalStorySummaries"
[classroomUrlFragment]="''"
[classroomName]="''"
[topicUrlFragment]="''">
</stories-list>
</div>
Expand Down

This file was deleted.

Loading

0 comments on commit dd0f495

Please sign in to comment.