Skip to content

Commit

Permalink
Merge pull request #23417 from code-dot-org/dtp_candidate_12ec0825
Browse files Browse the repository at this point in the history
DTP (Test > Production: 12ec082)
  • Loading branch information
aoby committed Jun 29, 2018
2 parents 40187b9 + 12ec082 commit 2cc9ec8
Show file tree
Hide file tree
Showing 22 changed files with 347 additions and 211 deletions.
2 changes: 2 additions & 0 deletions apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@
"emptyExampleBlockErrorMsg": "You need at least two examples in function {functionName}. Make sure each example has a call and a result.",
"emptyFunctionBlocksErrorMsg": "The function block needs to have other blocks inside it to work.",
"emptyFunctionalBlock": "You have a block with an unfilled input.",
"emptySurveyOverviewTable": "Because this survey is anonymous, we can only show aggregated results once there are at least 5 submissions.",
"emptyAssessmentSubmissions": "There are currently no submissions for this assessment.",
"emptyTextResponsesTable": "Most of our classes are designed to work for younger ages and do not require students to type text responses to questions, so you will not see any text responses here. For older students in middle and high school courses, you can see their submissions to open-ended text response questions by choosing the assigned course from the drop down above.",
"emptyTopLevelBlock": "There are no blocks to run. You must attach a block to the {topLevelBlockName} block.",
"enable": "Enable",
Expand Down
2 changes: 1 addition & 1 deletion apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"devDependencies": {
"@cdo/apps": "file:src",
"@code-dot-org/artist": "0.2.1",
"@code-dot-org/blockly": "2.4.1",
"@code-dot-org/blockly": "2.4.2",
"@code-dot-org/bramble": "0.1.26",
"@code-dot-org/craft": "0.1.3",
"@code-dot-org/johnny-five": "0.11.1-cdo.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export const UnconnectedMCAssessmentsOverviewContainer = MCAssessmentsOverviewCo

export default connect(state => ({
questionAnswerData: getMultipleChoiceSectionSummary(state),
totalStudentSubmissions: countSubmissionsForCurrentAssessment(state, false),
totalStudentSubmissions: countSubmissionsForCurrentAssessment(state),
totalStudentCount: getTotalStudentCount(state),
}))(MCAssessmentsOverviewContainer);
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export const UnconnectedMCSurveyOverviewContainer = MCSurveyOverviewContainer;

export default connect(state => ({
multipleChoiceSurveyData: getMultipleChoiceSurveyResults(state),
totalStudentSubmissions: countSubmissionsForCurrentAssessment(state, true),
totalStudentSubmissions: countSubmissionsForCurrentAssessment(state),
totalStudentCount: getTotalStudentCount(state),
}))(MCSurveyOverviewContainer);
43 changes: 36 additions & 7 deletions apps/src/templates/sectionAssessments/SectionAssessments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
asyncLoadAssessments,
getCurrentScriptAssessmentList,
setAssessmentId,
isCurrentAssessmentSurvey,
countSubmissionsForCurrentAssessment,
} from '@cdo/apps/templates/sectionAssessments/sectionAssessmentsRedux';
import {connect} from 'react-redux';
import {h3Style} from "../../lib/ui/Headings";
Expand Down Expand Up @@ -37,6 +39,8 @@ class SectionAssessments extends Component {
setAssessmentId: PropTypes.func.isRequired,
asyncLoadAssessments: PropTypes.func.isRequired,
multipleChoiceSurveyResults: PropTypes.array,
isCurrentAssessmentSurvey: PropTypes.bool,
totalStudentSubmissions: PropTypes.number,
};

onChangeScript = scriptId => {
Expand All @@ -46,7 +50,8 @@ class SectionAssessments extends Component {
};

render() {
const {validScripts, scriptId, assessmentList, assessmentId, isLoading} = this.props;
const {validScripts, scriptId, assessmentList, assessmentId,
isLoading, isCurrentAssessmentSurvey, totalStudentSubmissions} = this.props;

return (
<div>
Expand Down Expand Up @@ -75,13 +80,35 @@ class SectionAssessments extends Component {
{!isLoading &&
<div>
{/* Assessments */}
<MCAssessmentsOverviewContainer />
<StudentsMCSummaryContainer />
<MultipleChoiceByStudentContainer />
<FreeResponsesAssessmentsContainer />
{!isCurrentAssessmentSurvey &&
<div>
{totalStudentSubmissions > 0 &&
<div>
<MCAssessmentsOverviewContainer />
<StudentsMCSummaryContainer />
<MultipleChoiceByStudentContainer />
<FreeResponsesAssessmentsContainer />
</div>
}
{totalStudentSubmissions <= 0 &&
<h3>{i18n.emptyAssessmentSubmissions()}</h3>
}
</div>
}
{/* Surveys */}
<MCSurveyOverviewContainer />
<FreeResponseBySurveyQuestionContainer />
{isCurrentAssessmentSurvey &&
<div>
{totalStudentSubmissions > 0 &&
<div>
<MCSurveyOverviewContainer />
<FreeResponseBySurveyQuestionContainer />
</div>
}
{totalStudentSubmissions <=0 &&
<h3>{i18n.emptySurveyOverviewTable()}</h3>
}
</div>
}
</div>
}
{isLoading &&
Expand All @@ -101,6 +128,8 @@ export default connect(state => ({
assessmentList: getCurrentScriptAssessmentList(state),
scriptId: state.scriptSelection.scriptId,
assessmentId: state.sectionAssessments.assessmentId,
isCurrentAssessmentSurvey: isCurrentAssessmentSurvey(state),
totalStudentSubmissions: countSubmissionsForCurrentAssessment(state),
}), dispatch => ({
setScriptId(scriptId) {
dispatch(setScriptId(scriptId));
Expand Down
16 changes: 13 additions & 3 deletions apps/src/templates/sectionAssessments/sectionAssessmentsRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ export const getMultipleChoiceSurveyResults = (state) => {
});
};

// Returns a boolean. The selector function checks if the current assessment Id
// is in the surveys structure.
export const isCurrentAssessmentSurvey = (state) => {
const scriptId = state.scriptSelection.scriptId;
const surveysStructure = state.sectionAssessments.surveysByScript[scriptId] || {};

const currentAssessmentId = state.sectionAssessments.assessmentId;
return Object.keys(surveysStructure).includes(currentAssessmentId.toString());
};

/** Get data for students assessments multiple choice table
* Returns an object, each of type studentOverviewDataPropType with
* the value of the key being an object that contains the number
Expand Down Expand Up @@ -467,13 +477,13 @@ export const getMultipleChoiceSectionSummary = (state) => {
};

/**
* Selector function that takes in the state and a boolean indicating
* if the current assessment is a survey.
* Selector function that takes in the state.
* @returns {number} total count of students who have submitted
* the current assessment.
*/
export const countSubmissionsForCurrentAssessment = (state, isSurvey) => {
export const countSubmissionsForCurrentAssessment = (state) => {
const currentAssessmentId = state.sectionAssessments.assessmentId;
const isSurvey = isCurrentAssessmentSurvey(state);
if (isSurvey) {
const surveysStructure = state.sectionAssessments.surveysByScript[state.scriptSelection.scriptId] || {};
const currentSurvey = surveysStructure[currentAssessmentId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import sectionAssessments, {
getCorrectAnswer,
indexesToAnswerString,
countSubmissionsForCurrentAssessment,
isCurrentAssessmentSurvey,
} from '@cdo/apps/templates/sectionAssessments/sectionAssessmentsRedux';
import {setSection} from '@cdo/apps/redux/sectionDataRedux';

Expand Down Expand Up @@ -391,6 +392,42 @@ describe('sectionAssessmentsRedux', () => {
});
});

describe('isCurrentAssessmentSurvey', () => {
it('returns true when the current assessment is a survey', () => {
const stateWithSurvey = {
...rootState,
sectionAssessments: {
...rootState.sectionAssessments,
assessmentId: 123,
surveysByScript: {
3: {
123: {}
}
}
}
};
const result = isCurrentAssessmentSurvey(stateWithSurvey);
assert.deepEqual(result, true);
});

it('returns false when the current assessment is not a survey', () => {
const stateWithSurvey = {
...rootState,
sectionAssessments: {
...rootState.sectionAssessments,
assessmentId: 123,
surveysByScript: {
3: {
234: {}
}
}
}
};
const result = isCurrentAssessmentSurvey(stateWithSurvey);
assert.deepEqual(result, false);
});
});

describe('getMultipleChoiceSectionSummary', () => {
it('returns an empty array when no assessments in redux', () => {
const result = getMultipleChoiceSectionSummary(rootState);
Expand Down Expand Up @@ -575,7 +612,7 @@ describe('sectionAssessmentsRedux', () => {
}
};

const totalSubmissions = countSubmissionsForCurrentAssessment(stateWithAssessment, false);
const totalSubmissions = countSubmissionsForCurrentAssessment(stateWithAssessment);
assert.deepEqual(totalSubmissions, 2);
});

Expand Down Expand Up @@ -611,7 +648,7 @@ describe('sectionAssessmentsRedux', () => {
}
};

const totalSubmissions = countSubmissionsForCurrentAssessment(stateWithSurvey, true);
const totalSubmissions = countSubmissionsForCurrentAssessment(stateWithSurvey);
assert.deepEqual(totalSubmissions, 1);
});
});
Expand Down
6 changes: 3 additions & 3 deletions apps/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
version "0.2.1"
resolved "https://registry.yarnpkg.com/@code-dot-org/artist/-/artist-0.2.1.tgz#fcfe7ea5cfb3f19ddb6b912e70e922ba4b7ef0b1"

"@code-dot-org/blockly@2.4.1":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@code-dot-org/blockly/-/blockly-2.4.1.tgz#46a979f1e7c8616ab21d006985ca81cc8a2388cb"
"@code-dot-org/blockly@2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@code-dot-org/blockly/-/blockly-2.4.2.tgz#83ac8c7904274972e1f7ba57cda308e544e095a7"

"@code-dot-org/bramble@0.1.26":
version "0.1.26"
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ def set_email
false
elsif needs_password?(current_user, params)
if current_user.valid_password?(params[:user][:current_password])
current_user.update_primary_authentication_option(user: set_email_params)
current_user.update_primary_contact_info(user: set_email_params)
else
false
end
else
current_user.update_primary_authentication_option(user: set_email_params)
current_user.update_primary_contact_info(user: set_email_params)
end
else
if forbidden_change?(current_user, params)
Expand Down

0 comments on commit 2cc9ec8

Please sign in to comment.