Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[instrument_builder] ADDED: field warnings for maximum length in Instrument Builder module #8112

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion modules/instrument_builder/jsx/react.questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,12 +996,60 @@ class AddElement extends Component {
});
}

if (questionName.length > 64 && selected !== 'textbox'
&& selected !== 'textarea' && selected !== 'date'
&& selected !== 'numeric') {
// Error, question name is needed for the desired type. Set the element
// error flag for the questionName with message. Set the hasError flag
let temp = (this.state.error) ? this.state.error : {};
temp.questionName = 'Please shorten to 64 characters maximum';
this.setState({
error: temp,
});
hasError = true;
} else if (this.state.error) {
// No error, remove the element's questionName error flag if set
let temp = this.state.error;
delete temp.questionName;
this.setState({
error: temp,
});
}
if (hasError) {
// An error is present, return
return;
}

if (questionName.length > 57 && (selected === 'textbox'
|| selected === 'textarea' || selected === 'date'
|| selected === 'numeric')) {
// Error, question name is needed for the desired type. Set the element
// error flag for the questionName with message. Set the hasError flag
let temp = (this.state.error) ? this.state.error : {};
temp.questionName = 'Please shorten to 57 characters maximum';
this.setState({
error: temp,
});
hasError = true;
} else if (this.state.error) {
// No error, remove the elememt's questionName error flag if set
let temp = this.state.error;
delete temp.questionName;
this.setState({
error: temp,
});
}
if (hasError) {
// An error is present, return
return;
}

if (questionName === '' && selected !== 'header' && selected !== 'label' &&
selected !== 'line' && selected !== 'page-break') {
// Error, question name is needed for the desired type. Set the element
// error flag for the questionName with message. Set the hasError flag
let temp = (this.state.error) ? this.state.error : {};
temp.questionName = 'Must specifiy name for database to save value into';
temp.questionName = 'Must specify name for database to save value into';
this.setState({
error: temp,
});
Expand Down
21 changes: 16 additions & 5 deletions modules/instrument_builder/test/TestPlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@ Instrument builder Test Plan
* 1.a Add Header
* 1.b Add Label
* 1.c Add Scored Field
* 1.c.1 Validate that this requires both QuestionName and QuestionText
* 1.c.1 Validate that this requires both QuestionName and QuestionText
* 1.c.2 Validate that both QuestionName and QuestionText require less than 65 characters
* 1.d Add Textbox
* 1.d.1 Validate that this requires both QuestionName and QuestionText
* 1.d.1 Validate that this requires both QuestionName and QuestionText
* 1.d.2 Validate that QuestionName requires less than 58 characters
* 1.d.3 Validate that QuestionText requires less than 65 characters
* 1.e Add Textarea
* 1.e.1 Validate that this requires both QuestionName and QuestionText
* 1.e.1 Validate that this requires both QuestionName and QuestionText
* 1.e.2 Validate that QuestionName requires less than 58 characters
* 1.e.3 Validate that QuestionText requires less than 65 characters
* 1.f Add Dropdown
* 1.f.1 Validate that this requires both QuestionName and QuestionText
* 1.f.1 Validate that this requires both QuestionName and QuestionText
* 1.f.2 Validate that both QuestionName and QuestionText require less than 65 characters
* 1.g Add Multiselect
* 1.g.1 Validate that this requires both QuestionName and QuestionText
* 1.g.1 Validate that this requires both QuestionName and QuestionText
* 1.g.2 Validate that both QuestionName and QuestionText require less than 65 characters
* 1.h Add Date
* 1.h.1 Validate that this requires both QuestionName and QuestionText
* 1.h.2 Validate adding range (startyear-endyear)
* 1.h.3 Validate that QuestionName requires less than 58 characters
* 1.h.4 Validate that QuestionText requires less than 65 characters
* 1.i Add Numeric
* 1.i.1 Validate that this requires both QuestionName and QuestionText
* 1.i.2 Validate adding range
* 1.i.3 Validate that QuestionName requires less than 58 characters
* 1.i.4 Validate that QuestionText requires less than 65 characters
* 1.j Add Blank Line
* 1.k Add Page break
2. Edit Question Name and Question Text in the table directly and check if it sticks.
Expand Down