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

Assessments: Style free responses assessments question #23515

Merged
merged 15 commits into from Jul 6, 2018
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
1 change: 1 addition & 0 deletions apps/i18n/common/en_us.json
Expand Up @@ -981,6 +981,7 @@
"searchForCountry": "Search for your country.",
"searchForSchool": "Search for your school.",
"seeFullResponse": " ...see full response",
"seeFullQuestion": " ...see full question",
"school": "School",
"schoolCity": "School City",
"schoolCityTown": "City / Town",
Expand Down
Expand Up @@ -6,6 +6,16 @@ import {
import { connect } from 'react-redux';
import i18n from "@cdo/locale";

const QUESTION_CHARACTER_LIMIT = 260;

const styles = {
text: {
font: 10,
paddingTop: 20,
paddingBottom: 20,
},
};

const freeResponseQuestionsPropType = PropTypes.shape({
questionNumber: PropTypes.number,
questionText: PropTypes.string,
Expand All @@ -17,14 +27,34 @@ class FreeResponseBySurveyQuestionContainer extends Component {
freeResponsesByQuestion: PropTypes.arrayOf(freeResponseQuestionsPropType),
};

state = {
isExpanded: false,
};

expandText = () => {
this.setState({isExpanded: true});
};

render() {
const {freeResponsesByQuestion} = this.props;
return (
<div>
<h2>{i18n.studentFreeResponseAnswers()}</h2>
{freeResponsesByQuestion.map((question, index) => (
<div key={index}>
<h3>{`${question.questionNumber}. ${question.questionText}`}</h3>
{!this.state.isExpanded &&
<div style={styles.text}>
{`${question.questionNumber}. ${question.questionText.slice(0, QUESTION_CHARACTER_LIMIT)}`}
{question.questionText.length >= QUESTION_CHARACTER_LIMIT &&
<a onClick={this.expandText}><span>{i18n.seeFullQuestion()}</span></a>
}
</div>
}
{this.state.isExpanded &&
<div style={styles.text}>
{`${question.questionNumber}. ${question.questionText}`}
</div>
}
<FreeResponsesSurveyTable
freeResponses={question.answers}
/>
Expand Down
Expand Up @@ -9,6 +9,16 @@ import {
import { connect } from 'react-redux';
import i18n from "@cdo/locale";

const QUESTION_CHARACTER_LIMIT = 260;

const styles = {
text: {
font: 10,
paddingTop: 20,
paddingBottom: 20,
},
};

export const freeResponseSummaryPropType = PropTypes.shape({
questionText: PropTypes.string,
responses: PropTypes.arrayOf(freeResponsesDataPropType),
Expand All @@ -21,6 +31,14 @@ class FreeResponsesAssessmentsContainer extends Component {
currentStudentHasResponses: PropTypes.bool,
};

state = {
isExpanded: false,
};

expandText = () => {
this.setState({isExpanded: true});
};

render() {
const {freeResponseQuestions, studentId, currentStudentHasResponses} = this.props;
return (
Expand All @@ -32,7 +50,19 @@ class FreeResponsesAssessmentsContainer extends Component {
}
{freeResponseQuestions.map((question, index) => (
<div key={index}>
<h3>{`${question.questionNumber}. ${question.questionText}`}</h3>
{!this.state.isExpanded &&
<div style={styles.text}>
{`${question.questionNumber}. ${question.questionText.slice(0, QUESTION_CHARACTER_LIMIT)}`}
{question.questionText.length >= QUESTION_CHARACTER_LIMIT &&
<a onClick={this.expandText}><span>{i18n.seeFullQuestion()}</span></a>
}
</div>
}
{this.state.isExpanded &&
<div style={styles.text}>
{`${question.questionNumber}. ${question.questionText}`}
</div>
}
<FreeResponsesAssessmentsTable
freeResponses={question.responses}
/>
Expand All @@ -52,4 +82,3 @@ export default connect(state => ({
studentId: state.sectionAssessments.studentId,
currentStudentHasResponses: currentStudentHasResponses(state),
}))(FreeResponsesAssessmentsContainer);