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 tab: Gray out text when no response given #23551

Merged
merged 2 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
2 changes: 1 addition & 1 deletion apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
"emptyBlockInVariable": "The variable {name} has an unfilled input.",
"emptyBlocksErrorMsg": "The \"Repeat\" or \"If\" block needs to have other blocks inside it to work. Make sure the inner block fits properly inside the containing block.",
"emptyExampleBlockErrorMsg": "You need at least two examples in function {functionName}. Make sure each example has a call and a result.",
"emptyFreeResponse": "No response given for this question",
"emptyFreeResponse": "No response given for this question.",
"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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {freeResponsesDataPropType} from './assessmentDataShapes';
import i18n from '@cdo/locale';
import wrappedSortable from '../tables/wrapped_sortable';
import orderBy from 'lodash/orderBy';
import color from "@cdo/apps/util/color";

const PADDING = 15;

Expand All @@ -23,6 +24,9 @@ const styles = {
responseColumnHeader: {
padding: PADDING,
},
noResponse: {
color: color.lighter_gray,
}
};

export const COLUMNS = {
Expand Down Expand Up @@ -60,6 +64,19 @@ class FreeResponsesAssessmentsTable extends Component {
});
};

responseCellFormatter = (response, {rowData, rowIndex}) => {
return (
<div>
{response &&
<div>{response}</div>
}
{!response &&
<div style={styles.noResponse}>{i18n.emptyFreeResponse()}</div>
}
</div>
);
};

getColumns = (sortable, index) => {
let dataColumns = [
{
Expand Down Expand Up @@ -94,6 +111,7 @@ class FreeResponsesAssessmentsTable extends Component {
},
},
cell: {
format: this.responseCellFormatter,
props: {style:tableLayoutStyles.cell},
}
},
Expand Down
22 changes: 17 additions & 5 deletions apps/src/templates/sectionAssessments/FreeResponsesSurveyTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import {tableLayoutStyles, sortableOptions} from "../tables/tableConstants";
import i18n from '@cdo/locale';
import wrappedSortable from '../tables/wrapped_sortable';
import orderBy from 'lodash/orderBy';
import color from "@cdo/apps/util/color";

const styles = {
noResponse: {
color: color.lighter_gray,
}
};

export const COLUMNS = {
RESPONSE: 0,
Expand Down Expand Up @@ -44,11 +51,16 @@ class FreeResponsesSurveyTable extends Component {
};

studentResponseColumnFormatter = (response, {rowIndex}) => {
const numStudentResponses = this.props.freeResponses.length;

if (numStudentResponses >= 5) {
return response;
}
return (
<div>
{response &&
<div>{response}</div>
}
{!response &&
<div style={styles.noResponse}>{i18n.emptyFreeResponse()}</div>
}
</div>
);
};

getColumns = (sortable) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ const MultiAnswerStatus = {

const ANSWER_LETTERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];

const EMPTY_FREE_RESPONSE_MESSAGE = i18n.emptyFreeResponse();

// Action type constants
const SET_ASSESSMENT_RESPONSES = 'sectionAssessments/SET_ASSESSMENT_RESPONSES';
const SET_ASSESSMENTS_QUESTIONS = 'sectionAssessments/SET_ASSESSMENTS_QUESTIONS';
Expand Down Expand Up @@ -308,7 +306,7 @@ export const getAssessmentsFreeResponseResults = (state) => {
questionsAndResults[index].responses.push({
id: studentId,
name: studentObject.student_name,
response: response.student_result || EMPTY_FREE_RESPONSE_MESSAGE,
response: response.student_result,
});
});
});
Expand All @@ -334,7 +332,7 @@ export const getSurveyFreeResponseQuestions = (state) => {
questionText: question.question,
questionNumber: question.question_index + 1,
answers: question.results.map((response, index) => {
return {index: index, response: response.result || EMPTY_FREE_RESPONSE_MESSAGE};
return {index: index, response: response.result};
}),
};
});
Expand Down