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

Revert "Standards instrumentation" #33712

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/src/templates/MultiCheckboxSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MultiCheckboxSelector extends Component {
} else {
selectedItems = _.concat(this.props.selected, item);
}
this.props.onChange(selectedItems, item);
this.props.onChange(selectedItems);
} else {
const index = this.props.selected.indexOf(item);
if (index >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const styles = {
};

/**
* A toggle that provides a way to switch between detail, summary, and standards views of
* A toggle that provides a way to switch between detail and summary views of
* the progress a section of students have made in a course. Teacher view.
*/
class SectionProgressToggle extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class CreateStandardsReportStep1 extends Component {
{i18n.createStandardsReportStep1() + ' '}
{i18n.completedUnpluggedLessons()}
</h3>
{this.props.unpluggedLessons.length > 0 && (
<LessonStatusList dialog={'CreateStandardsReportDialog'} />
)}
{this.props.unpluggedLessons.length > 0 && <LessonStatusList />}
{this.props.unpluggedLessons.length === 0 && (
<p style={styles.noUnplugged}>
{i18n.standardsReportNoUnpluggedLessons()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class LessonStatusDialog extends Component {
<h2>{i18n.updateUnpluggedLessonProgress()}</h2>
<p>{i18n.updateUnpluggedLessonProgressSubHeading()}</p>
<h3>{i18n.completedUnpluggedLessons()}</h3>
<LessonStatusList dialog={'LessonStatusDialog'} />
<LessonStatusList />
<p>{i18n.pluggedLessonsNote()}</p>
<DialogFooter rightAlign>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import {createStore, combineReducers} from 'redux';
import {Provider} from 'react-redux';
import sectionStandardsProgress from './sectionStandardsProgressRedux';
import sectionProgress from '@cdo/apps/templates/sectionProgress/sectionProgressRedux';
import sectionData from '@cdo/apps/redux/sectionDataRedux';
import scriptSelection from '@cdo/apps/redux/scriptSelectionRedux';

export default storybook => {
const store = createStore(
combineReducers({
sectionStandardsProgress,
sectionProgress,
scriptSelection,
sectionData
scriptSelection
})
);

Expand Down
64 changes: 5 additions & 59 deletions apps/src/templates/sectionProgress/standards/LessonStatusList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
getUnpluggedLessonsForScript,
setSelectedLessons
} from './sectionStandardsProgressRedux';
import firehoseClient from '../../../lib/util/firehose';
import color from '@cdo/apps/util/color';

const styles = {
Expand All @@ -23,43 +22,16 @@ const styles = {

class LessonStatusList extends Component {
static propTypes = {
dialog: PropTypes.string,
// redux
unpluggedLessonList: PropTypes.array,
setSelectedLessons: PropTypes.func.isRequired,
selectedLessons: PropTypes.array.isRequired,
sectionId: PropTypes.number,
scriptId: PropTypes.number
selectedLessons: PropTypes.array.isRequired
};

handleChange = (selectedLessons, changedLesson) => {
firehoseClient.putRecord(
{
study: 'teacher_dashboard_actions',
study_group: 'standards',
event: 'update_unplugged_lesson_list',
data_json: JSON.stringify({
section_id: this.props.sectionId,
script_id: this.props.scriptId,
changed_lesson_id: changedLesson.id,
lesson_selected: !changedLesson.completed,
dialog: this.props.dialog
})
},
{includeUserId: true}
);
handleChange = selectedLessons => {
this.props.setSelectedLessons(selectedLessons);
};

render() {
// Add the scriptId and sectionId so that we can use them to log metrics
this.props.unpluggedLessonList.forEach(lesson =>
Object.assign(lesson, {
sectionId: this.props.sectionId,
scriptId: this.props.scriptId
})
);

return (
<MultiCheckboxSelector
noHeader={true}
Expand All @@ -75,22 +47,6 @@ class LessonStatusList extends Component {
}
}

const handleLessonLinkClick = function(lesson) {
firehoseClient.putRecord(
{
study: 'teacher_dashboard_actions',
study_group: 'standards',
event: 'click_unplugged_lesson_link',
data_json: JSON.stringify({
link: lesson.url,
section_id: lesson.sectionId,
script_id: lesson.scriptId
})
},
{includeUserId: true}
);
};

const ComplexLessonComponent = function({lesson}) {
return (
<div style={styles.lessonListItem}>
Expand All @@ -99,15 +55,9 @@ const ComplexLessonComponent = function({lesson}) {
completed={lesson.completed}
inProgress={lesson.inProgress}
lessonNumber={lesson.number}
linkToLessonPlan={lesson.url}
/>
</div>
<a
style={styles.links}
href={lesson.url}
target={'_blank'}
onClick={() => handleLessonLinkClick(lesson)}
>
<a style={styles.links} href={lesson.url} target={'_blank'}>
{lesson.name}
</a>
</div>
Expand All @@ -121,19 +71,15 @@ ComplexLessonComponent.propTypes = {
url: PropTypes.string,
completed: PropTypes.bool,
inProgress: PropTypes.bool
}),
sectionId: PropTypes.number,
scriptId: PropTypes.number
})
};

export const UnconnectedLessonStatusList = LessonStatusList;

export default connect(
state => ({
unpluggedLessonList: getUnpluggedLessonsForScript(state),
selectedLessons: state.sectionStandardsProgress.selectedLessons,
sectionId: state.sectionData.section.id,
scriptId: state.scriptSelection.scriptId
selectedLessons: state.sectionStandardsProgress.selectedLessons
}),
dispatch => ({
setSelectedLessons(selected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import {Provider} from 'react-redux';
import sectionStandardsProgress from './sectionStandardsProgressRedux';
import sectionProgress from '@cdo/apps/templates/sectionProgress/sectionProgressRedux';
import scriptSelection from '@cdo/apps/redux/scriptSelectionRedux';
import sectionData from '@cdo/apps/redux/sectionDataRedux';

export default storybook => {
const store = createStore(
combineReducers({
sectionProgress,
sectionStandardsProgress,
scriptSelection,
sectionData
scriptSelection
})
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import PropTypes from 'prop-types';
import React, {Component} from 'react';
import ProgressBox from '../ProgressBox';
import firehoseClient from '../../../lib/util/firehose';
import {connect} from 'react-redux';

const styles = {
lessonBox: {
Expand All @@ -11,32 +9,13 @@ const styles = {
}
};

class ProgressBoxForLessonNumber extends Component {
export default class ProgressBoxForLessonNumber extends Component {
static propTypes = {
completed: PropTypes.bool,
inProgress: PropTypes.bool,
lessonNumber: PropTypes.number,
tooltipId: PropTypes.string,
linkToLessonPlan: PropTypes.string,
sectionId: PropTypes.number,
scriptId: PropTypes.number
};

handleClick = () => {
firehoseClient.putRecord(
{
study: 'teacher_dashboard_actions',
study_group: 'standards',
event: 'click_lesson_progress_box',
data_json: JSON.stringify({
link: this.props.linkToLessonPlan,
section_id: this.props.sectionId,
script_id: this.props.scriptId,
in_report: window.location.pathname.includes('standards_report')
})
},
{includeUserId: true}
);
linkToLessonPlan: PropTypes.string
};

render() {
Expand All @@ -49,38 +28,17 @@ class ProgressBoxForLessonNumber extends Component {
} = this.props;
const started = completed || inProgress;
const workingOn = inProgress && !completed;
const progressBox = (
<ProgressBox
style={styles.lessonBox}
started={started}
incomplete={started ? 0 : 20}
imperfect={workingOn ? 20 : 0}
perfect={completed ? 20 : 0}
lessonNumber={lessonNumber}
/>
return (
<a href={linkToLessonPlan} target="_blank" data-for={tooltipId} data-tip>
<ProgressBox
style={styles.lessonBox}
started={started}
incomplete={started ? 0 : 20}
imperfect={workingOn ? 20 : 0}
perfect={completed ? 20 : 0}
lessonNumber={lessonNumber}
/>
</a>
);

if (linkToLessonPlan) {
return (
<a
href={linkToLessonPlan}
target="_blank"
data-for={tooltipId}
data-tip
onClick={this.handleClick}
>
{progressBox}
</a>
);
} else {
return progressBox;
}
}
}

export const UnconnectedProgressBoxForLessonNumber = ProgressBoxForLessonNumber;

export default connect(state => ({
sectionId: state.sectionData.section.id,
scriptId: state.scriptSelection.scriptId
}))(ProgressBoxForLessonNumber);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
fetchStudentLevelScores
} from './sectionStandardsProgressRedux';
import {teacherDashboardUrl} from '@cdo/apps/templates/teacherDashboard/urlHelpers';
import firehoseClient from '../../../lib/util/firehose';
import {TeacherScores} from './standardsConstants';

const styles = {
Expand Down Expand Up @@ -40,24 +39,11 @@ class StandardsViewHeaderButtons extends Component {
state = {
isLessonStatusDialogOpen: false,
isCreateReportDialogOpen: false,
comment: '',
commentUpdated: false
comment: ''
};

openLessonStatusDialog = () => {
this.setState({isLessonStatusDialogOpen: true});
firehoseClient.putRecord(
{
study: 'teacher_dashboard_actions',
study_group: 'standards',
event: 'click_update_unplugged_lessons',
data_json: JSON.stringify({
section_id: this.props.sectionId,
script_id: this.props.scriptId
})
},
{includeUserId: true}
);
};

closeLessonStatusDialog = () => {
Expand All @@ -66,18 +52,6 @@ class StandardsViewHeaderButtons extends Component {

openCreateReportDialog = () => {
this.setState({isCreateReportDialogOpen: true});
firehoseClient.putRecord(
{
study: 'teacher_dashboard_actions',
study_group: 'standards',
event: 'open_generate_report_dialog',
data_json: JSON.stringify({
section_id: this.props.sectionId,
script_id: this.props.scriptId
})
},
{includeUserId: true}
);
};

closeCreateReportDialog = () => {
Expand All @@ -97,25 +71,10 @@ class StandardsViewHeaderButtons extends Component {
teacherComment: this.state.comment,
scriptId: this.props.scriptId
};
firehoseClient.putRecord(
{
study: 'teacher_dashboard_actions',
study_group: 'standards',
event: 'generate_report',
data_json: JSON.stringify({
section_id: this.props.sectionId,
script_id: this.props.scriptId,
added_or_changed_comment: this.state.commentUpdated
})
},
{includeUserId: true}
);
this.setState({commentUpdated: false});
};

onCommentChange = value => {
this.setState({comment: value}, () => {
this.setState({commentUpdated: true});
this.props.setTeacherCommentForReport(this.state.comment);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe('StandardDescriptionCell', () => {

it('shows the correct number of progress boxes for lessons', () => {
const wrapper = shallow(<StandardDescriptionCell {...DEFAULT_PROPS} />);
expect(
wrapper.find('Connect(ProgressBoxForLessonNumber)')
).to.have.lengthOf(lessonCompletedByStandard[1].length);
expect(wrapper.find('ProgressBoxForLessonNumber')).to.have.lengthOf(
lessonCompletedByStandard[1].length
);
});
it('does not show the tooltip in the standards report view', () => {
const wrapper = shallow(
Expand Down