diff --git a/.env b/.env index 7f8ddabd9..9eb5d44c7 100644 --- a/.env +++ b/.env @@ -197,3 +197,6 @@ REACT_APP_DISABLE_USER_LEADERBOARD_CONFIGS='' #Disable Country Leaderboard Configuration REACT_APP_DISABLE_COUNTRY_LEADERBOARD_CONFIG='' + +# For setting the minimum character count for challenge instructions +REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH=150 diff --git a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/BulkSchemas/InstructionsSchema.js b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/BulkSchemas/InstructionsSchema.js index 625a054f7..d49edb38d 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/BulkSchemas/InstructionsSchema.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/BulkSchemas/InstructionsSchema.js @@ -1,6 +1,7 @@ import messages from '../Messages' export const jsSchema = (intl) => { + const instructionsMinLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150 const schemaFields = { "$schema": "http://json-schema.org/draft-07/schema#", type: "object", @@ -8,8 +9,8 @@ export const jsSchema = (intl) => { instruction: { title: intl.formatMessage(messages.instructionLabel), type: "string", - minLength: 150, - description: intl.formatMessage(messages.instructionsDescription), + minLength: instructionsMinLength, + description: intl.formatMessage(messages.instructionsDescription, {minLength: `${instructionsMinLength}`}) }, }, } diff --git a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js index ccbada659..82139c939 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js @@ -765,7 +765,7 @@ will not be able to make sense of it. instructionsDescription: { id: "Admin.EditChallenge.form.instructionsDescription", - defaultMessage: "Instructions must have more than 150 characters.", + defaultMessage: "Instructions must be longer than {minLength} characters.", }, nameDescription: { diff --git a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js index 4af028def..82a82b2d4 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js @@ -17,6 +17,7 @@ import messages from '../Messages' * @author [Neil Rotstan](https://github.com/nrotstan) */ export const jsSchema = (intl) => { + const instructionsMinLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150 const schemaFields = { "$schema": "http://json-schema.org/draft-07/schema#", type: "object", @@ -24,8 +25,8 @@ export const jsSchema = (intl) => { instruction: { title: intl.formatMessage(messages.instructionLabel), type: "string", - minLength: 150, - description: intl.formatMessage(messages.instructionsDescription), + minLength: instructionsMinLength, + description: intl.formatMessage(messages.instructionsDescription, {minLength: `${instructionsMinLength}`}) }, difficulty: { title: intl.formatMessage(messages.difficultyLabel), diff --git a/src/lang/en-US.json b/src/lang/en-US.json index 1954606fe..0d150eb87 100644 --- a/src/lang/en-US.json +++ b/src/lang/en-US.json @@ -163,7 +163,7 @@ "Admin.EditChallenge.form.includeCheckinHashtag.value.true.label": "Automatically append `#maproulette` hashtag (highly recommended)", "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.", "Admin.EditChallenge.form.instruction.label": "Detailed Instructions for Mappers", - "Admin.EditChallenge.form.instructionsDescription": "Instructions must have more than 150 characters.", + "Admin.EditChallenge.form.instructionsDescription": "Instructions must be longer than {minLength} characters.", "Admin.EditChallenge.form.limitReviewTags.description": "Allow other tags during task review?", "Admin.EditChallenge.form.limitTags.description": "Allow other tags during task completion?", "Admin.EditChallenge.form.localGeoJson.description": "Please upload the local GeoJSON file from your computer", @@ -857,7 +857,7 @@ "Errors.challengeSaveFailure.challengeSaveDescriptionFailure": "The 'DESCRIPTION OF YOUR CHALLENGE' field is required.", "Errors.challengeSaveFailure.challengeSaveDetailsFailure": "Unable to save your changes. It is likely a duplicate challenge name.", "Errors.challengeSaveFailure.challengeSaveEditPolicyAgreementFailure": "You must check the box at the bottom of the page to indicate that you acknowledge OpenStreetMap's Automated Edits code of conduct.", - "Errors.challengeSaveFailure.challengeSaveInstructionFailure": "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than 150 characters.", + "Errors.challengeSaveFailure.challengeSaveInstructionFailure": "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than {minLength} characters.", "Errors.challengeSaveFailure.challengeSaveNameFailure": "The 'NAME OF YOUR CHALLENGE' field is required and must be more than 3 characters long.", "Errors.clusteredTask.fetchFailure": "Unable to fetch task clusters", "Errors.file.formatIncorrect": "File format is unrecognized or unsupported for this operation", diff --git a/src/services/Challenge/Challenge.js b/src/services/Challenge/Challenge.js index ae7245a55..f8dd12698 100644 --- a/src/services/Challenge/Challenge.js +++ b/src/services/Challenge/Challenge.js @@ -1044,11 +1044,12 @@ export const fetchChallenges = function ( name } = challengeData; + const instructionsMinLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150 if ( challengeData.parent != undefined && ( !instruction || - instruction.length < 150 || + instruction.length < instructionsMinLength || !description?.trim()?.length || !name || name.length <= 3 @@ -1065,6 +1066,7 @@ export const fetchChallenges = function ( instruction.length < 150 ) { errorMessage = AppErrors.challengeSaveFailure.saveInstructionsFailure; + errorMessage.values = { minLength: `${instructionsMinLength}` }; } else { errorMessage = AppErrors.challengeSaveFailure.saveDetailsFailure; } diff --git a/src/services/Error/Messages.js b/src/services/Error/Messages.js index 3977faa55..76a2d3db7 100644 --- a/src/services/Error/Messages.js +++ b/src/services/Error/Messages.js @@ -203,7 +203,7 @@ export default defineMessages({ }, challengeSaveInstructionFailure: { id: "Errors.challengeSaveFailure.challengeSaveInstructionFailure", - defaultMessage: "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than 150 characters.", + defaultMessage: "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than {minLength} characters.", }, challengeSaveEditPolicyAgreementFailure: { id: "Errors.challengeSaveFailure.challengeSaveEditPolicyAgreementFailure",