Skip to content

Commit 0228e84

Browse files
committed
Change instruction length validation from hard requirement to just a recommendation
1 parent c72fcc8 commit 0228e84

6 files changed

Lines changed: 26 additions & 19 deletions

File tree

lang/en-US.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"Admin.EditChallenge.form.includeCheckinHashtag.value.true.label": "Automatically append `#maproulette` hashtag (highly recommended)",
151151
"Admin.EditChallenge.form.instruction.description": "The instruction tells a mapper how to resolve a Task in your Challenge. This is what mappers see in the Instructions box every time a task is loaded, and is the primary piece of information for the mapper about how to solve the task, so think about this field carefully. You can include links to the OSM wiki or any other hyperlink if you want, because this field supports [Markdown](https://learn.maproulette.org/documentation/markdown/). You can also reference feature properties from your GeoJSON with simple [mustache tags](https://learn.maproulette.org/documentation/mustache-tag-replacement/): e.g. `'{{address}}'` would be replaced with the value of the `address` property, allowing for basic customization of instructions for each task. This field is required.",
152152
"Admin.EditChallenge.form.instruction.label": "Detailed Instructions for Mappers",
153-
"Admin.EditChallenge.form.instructionsDescription": "Instructions must be longer than {minLength} characters.",
153+
"Admin.EditChallenge.form.instructionsDescription": "We recommend instructions be longer than {minLength} characters.",
154154
"Admin.EditChallenge.form.limitReviewTags.description": "Allow other tags during task review?",
155155
"Admin.EditChallenge.form.limitTags.description": "Allow other tags during task completion?",
156156
"Admin.EditChallenge.form.localGeoJson.description": "Please upload the local GeoJSON file from your computer",
@@ -924,14 +924,14 @@
924924
"Form.textUpload.promptGeoJSON": "Drop GeoJSON file here or click to select file",
925925
"Form.textUpload.promptJSON": "Drop JSON file here or click to select file",
926926
"Form.textUpload.readonly": "Existing file will be used",
927+
"GeoJSONUploadModal.countingTasks": "Counting tasks…",
927928
"GeoJSONUploadModal.dropzone.label": "Drop a GeoJSON file here or click to upload",
928929
"GeoJSONUploadModal.error.invalid": "Invalid GeoJSON: {error}",
929930
"GeoJSONUploadModal.error.noPolygons": "No Polygon features found in file",
931+
"GeoJSONUploadModal.error.tooManyTasks": "Too many tasks ({count}). Maximum allowed is {max}.",
930932
"GeoJSONUploadModal.header": "Create Virtual Challenge from GeoJSON",
931933
"GeoJSONUploadModal.success.polygonsLoaded": "{count, plural, one {# polygon} other {# polygons}} loaded",
932934
"GeoJSONUploadModal.taskCount": "{count, plural, one {# task} other {# tasks}} found in area",
933-
"GeoJSONUploadModal.countingTasks": "Counting tasks\u2026",
934-
"GeoJSONUploadModal.error.tooManyTasks": "Too many tasks ({count}). Maximum allowed is {max}.",
935935
"GlobalActivity.title": "Global Activity",
936936
"Grant.Role.admin": "Admin",
937937
"Grant.Role.read": "Read",
@@ -1510,6 +1510,7 @@
15101510
"WidgetWorkspace.controls.editConfiguration.label": "Edit Layout",
15111511
"WidgetWorkspace.controls.exportConfiguration.label": "Export Layout",
15121512
"WidgetWorkspace.controls.importConfiguration.label": "Import Layout",
1513+
"WidgetWorkspace.controls.layoutName.label": "Layout Name",
15131514
"WidgetWorkspace.controls.resetConfiguration.label": "Reset Layout to Default",
15141515
"WidgetWorkspace.controls.saveAsDefault.label": "Save as My Default",
15151516
"WidgetWorkspace.controls.saveConfiguration.label": "Done Editing",

src/components/AdminPane/Manage/ManageChallenges/EditChallenge/EditChallenge.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ export class EditChallenge extends Component {
231231
.finally(() => {
232232
this.validationPromise = null;
233233
});
234+
234235
return errors;
235236
};
236237

src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ will not be able to make sense of it.
831831

832832
instructionsDescription: {
833833
id: "Admin.EditChallenge.form.instructionsDescription",
834-
defaultMessage: "Instructions must be longer than {minLength} characters.",
834+
defaultMessage: "We recommend instructions be longer than {minLength} characters.",
835835
},
836836

837837
nameDescription: {

src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,13 @@ const validateMinLength = (val) => {
3131
};
3232

3333
export const jsSchema = (intl) => {
34-
const minLengthEnvValue = window.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH;
35-
const instructionsMinLength = validateMinLength(minLengthEnvValue);
36-
3734
const schemaFields = {
3835
$schema: "http://json-schema.org/draft-07/schema#",
3936
type: "object",
4037
properties: {
4138
instruction: {
4239
title: intl.formatMessage(messages.instructionLabel),
4340
type: "string",
44-
minLength: instructionsMinLength,
45-
description: intl.formatMessage(messages.instructionsDescription, {
46-
minLength: `${instructionsMinLength}`,
47-
}),
4841
},
4942
difficulty: {
5043
title: intl.formatMessage(messages.difficultyLabel),
@@ -75,12 +68,19 @@ export const jsSchema = (intl) => {
7568
* > proper markup
7669
*/
7770
export const uiSchema = (intl, user, challengeData, extraErrors, options = {}) => {
71+
const minLengthEnvValue = 150;
72+
const instructionsMinLength = validateMinLength(minLengthEnvValue);
73+
7874
const uiSchemaFields = {
7975
"ui:order": ["instruction", "difficulty"],
8076
instruction: {
8177
"ui:field": "markdown",
8278
"ui:help": intl.formatMessage(messages.instructionDescription),
8379
"ui:previewNote": intl.formatMessage(messages.addMustachePreviewNote),
80+
"ui:recommendedMinLength": instructionsMinLength,
81+
"ui:recommendedMinLengthMessage": intl.formatMessage(messages.instructionsDescription, {
82+
minLength: `${instructionsMinLength}`,
83+
}),
8484
"ui:groupHeader": options.longForm
8585
? intl.formatMessage(messages.instructionsStepHeader)
8686
: undefined,

src/components/Custom/RJSFFormFieldAdapter/RJSFFormFieldAdapter.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,20 @@ export const MarkdownEditField = (props) => {
294294
const [showingPreview, setShowingPreview] = useState(false);
295295
const [formValues, setFormValues] = useState({});
296296

297+
const recommendedMinLength = props.uiSchema["ui:recommendedMinLength"];
298+
const recommendedMinLengthMessage = props.uiSchema["ui:recommendedMinLengthMessage"];
299+
const isBelowRecommended =
300+
recommendedMinLength > 0 &&
301+
(props.formData || "").length < recommendedMinLength;
302+
297303
return (
298304
<Fragment>
299305
<LabelWithHelp {...props} />
306+
{isBelowRecommended && recommendedMinLengthMessage && (
307+
<div className="mr-text-orange mr-text-xs mr-mb-2">
308+
{recommendedMinLengthMessage} (current character count: {(props.formData || "").length})
309+
</div>
310+
)}
300311
<div className="mr-flex mr-items-center mr-mb-2 mr-leading-tight mr-text-xxs">
301312
<button
302313
type="button"

src/services/Challenge/Challenge.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,14 +1043,11 @@ export const saveChallenge = function (originalChallengeData, storeResponse = tr
10431043
}
10441044

10451045
// Validate the fields before saving
1046-
const { instruction, description, name, checkinComment } = challengeData;
1046+
const { description, name, checkinComment } = challengeData;
10471047

1048-
const instructionsMinLength = window.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150;
10491048
if (
10501049
challengeData.parent != undefined &&
1051-
(!instruction ||
1052-
instruction.length < instructionsMinLength ||
1053-
!description?.trim()?.length ||
1050+
(!description?.trim()?.length ||
10541051
!name ||
10551052
name.length <= 3 ||
10561053
!checkinComment ||
@@ -1062,9 +1059,6 @@ export const saveChallenge = function (originalChallengeData, storeResponse = tr
10621059
errorMessage = AppErrors.challengeSaveFailure.saveNameFailure;
10631060
} else if (description === undefined || description === "") {
10641061
errorMessage = AppErrors.challengeSaveFailure.saveDescriptionFailure;
1065-
} else if (instruction === undefined || instruction.length < instructionsMinLength) {
1066-
errorMessage = AppErrors.challengeSaveFailure.saveInstructionsFailure;
1067-
errorMessage.values = { minLength: `${instructionsMinLength}` };
10681062
} else if (
10691063
checkinComment === undefined ||
10701064
checkinComment === "" ||

0 commit comments

Comments
 (0)