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

Allow teachers to hide all lessons in a unit with one click #48863

Merged
merged 9 commits into from
Nov 2, 2022

Conversation

rshipp
Copy link
Contributor

@rshipp rshipp commented Oct 26, 2022

Add two buttons to the top of the unit overview page (right above the first lesson tile) that have the option to "show all" and "hide all" with a tooltip to the right of it that says "Make all lessons in this Unit visible or hidden for your students".

image

The new buttons tie in to the existing logic for the toggle buttons down the rest of the page, and flip them dynamically.

Questions:

  • Should I add a storybook file? I looked at it briefly and it seemed like it would take some work to figure out how to hook up all the redux stuff. Or should there be any other types of tests?
  • Do I want the new buttons to show disabled when all the lessons are either hidden or visible? right now they feel a little low feedback when you click them
  • I'm making one network call per lesson in the unit, which is probably not too many, but still seems less than ideal. Is it worth adding a bulk endpoint or something to the controller so I can do one call, and adding all the JS to handle that appropriately? It seems like that might increase the scope of this task by quite a bit.
  • There's a warning in the console about "componentWillUpdate has been renamed, and is not recommended for use... Please update the following components: Connect(BulkLessonVisibilityToggle)" - is that something I should be concerned about here?

Links

Testing story

  • Manual testing, and one new basic unit test case.

Comment on lines 1 to 11
import React from 'react';
import {connect} from 'react-redux';
import {getStore} from '../../../redux';
import PropTypes from 'prop-types';
import Button from '@cdo/apps/templates/Button';
import FontAwesome from '../../../templates/FontAwesome';
import ReactTooltip from 'react-tooltip';
import {toggleHiddenLesson} from '@cdo/apps/code-studio/hiddenLessonRedux';
import {unitCalendarLesson} from '../../../templates/progress/unitCalendarLessonShapes';
import _ from 'lodash';
import style from './bulk-lesson-visibility-toggle.module.scss';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are entirely unordered, and some use an absolute syntax while others use a relative syntax. are there any standards for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any standards for order unfortunately :(

For absolute vs relative syntax: I'll use relative if it's in the the files is in the same directory and otherwise use @cdo/apps. I'm not sure if that's just a personal preference though

scriptName: PropTypes.string.isRequired
};

function toggleHiddenLessons(scriptName, sectionId, lessons, hidden) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok that this function is just floating around down here, or should it be somewhere else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I normally put these at the top, but, again, not sure if that's just personal preference

function toggleHiddenLessons(scriptName, sectionId, lessons, hidden) {
lessons.forEach(lesson => {
// For some reason, sectionId is a number here, and needs to be a string
// for the redux toggle stuff to work.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 69 to 74
}) /*,
dispatch => ({
toggleHiddenLesson(unitName, sectionId, lessonId, hidden) {
dispatch(toggleHiddenLesson(unitName, sectionId, lessonId, hidden));
}
}) */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i copied this from ProgressLessonTeacherInfo.jsx, but it seems to work fine without it? do I need this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the commented out code here. Not sure why it's in ProgressLessonTeacherInfo

<p>
Make all lessons in this Unit visible or hidden for your students.
</p>
</ReactTooltip>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HelpTip has a Portal here, should I use one too? i'm not sure what the benefit is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why didn't you use HelpTip here? (I'm not sure what benefit a Portal gets you either though)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just doesn't look very good, and doesn't have a way to pass in options to override the default look. I suppose I also could have modified it to let me pass in classNames/icons stuff, would that make more sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine in that case! Was just curious

@rshipp rshipp marked this pull request as ready for review October 26, 2022 20:50
@rshipp rshipp marked this pull request as draft October 26, 2022 20:50
@rshipp rshipp marked this pull request as ready for review October 26, 2022 20:58
@rshipp rshipp requested a review from a team as a code owner October 26, 2022 20:58
@rshipp rshipp requested a review from a team October 26, 2022 20:58
import style from './bulk-lesson-visibility-toggle.module.scss';
import i18n from '@cdo/locale';

function BulkLessonVisibilityToggle({lessons, sectionId, scriptName}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's not too much trouble, it would be great to use unitName instead of scriptName. We're in the process of change the term "script" to "unit"

Copy link
Contributor

@bethanyaconnor bethanyaconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions but looks good!

Copy link
Contributor

@hannahbergam hannahbergam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question you ask about how it looks a little low feedback without disabling whichever button was just pressed- do the 'visible/hidden' fields in each lesson update automatically, or does it require a page load?

@rshipp
Copy link
Contributor Author

rshipp commented Nov 1, 2022

The visible/hidden toggle for each lesson updates immediately, without a page load. They're just lower on the screen, so depending on the screen size/etc it might not be visible, or immediately clear that something happened.

@rshipp rshipp merged commit 93f8853 into staging Nov 2, 2022
@rshipp rshipp deleted the hide-all-lessons branch November 2, 2022 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants