From 7ee8da4d2be400f58a40a1eaf1bcac02da7f73ec Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Wed, 10 Jan 2024 20:02:49 -0600 Subject: [PATCH 1/5] add instructions length environment variable --- .env | 3 +++ .../EditChallenge/BulkSchemas/InstructionsSchema.js | 5 +++-- .../Manage/ManageChallenges/EditChallenge/Messages.js | 4 ++-- .../EditChallenge/Schemas/InstructionsSchema.js | 5 +++-- src/services/Challenge/Challenge.js | 4 +++- src/services/Error/Messages.js | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.env b/.env index f91227cc7..bb7544594 100644 --- a/.env +++ b/.env @@ -194,3 +194,6 @@ REACT_APP_DISABLE_TASK_CLUSTERS='' # Disable User Leaderboard configurations REACT_APP_DISABLE_USER_LEADERBOARD_CONFIGS='' + +# Character requirement for challenge instructions +REACT_APP_CHALLENGE_INSTRUCTIONS_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..4a923327b 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 instructionsLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_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: instructionsLength, + description: intl.formatMessage(messages.instructionsDescription, {details: `${instructionsLength}`}) }, }, } diff --git a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js index ccbada659..4785f4edb 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js @@ -764,8 +764,8 @@ will not be able to make sense of it. }, instructionsDescription: { - id: "Admin.EditChallenge.form.instructionsDescription", - defaultMessage: "Instructions must have more than 150 characters.", + id: "Admin.EditChallenge.form.instructionsDescriptiojn", + defaultMessage: "Instructions must be longer than {details} 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..21811c429 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 instructionsLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_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: instructionsLength, + description: intl.formatMessage(messages.instructionsDescription, {details: `${instructionsLength}`}) }, difficulty: { title: intl.formatMessage(messages.difficultyLabel), diff --git a/src/services/Challenge/Challenge.js b/src/services/Challenge/Challenge.js index ae7245a55..a4057616c 100644 --- a/src/services/Challenge/Challenge.js +++ b/src/services/Challenge/Challenge.js @@ -1044,11 +1044,12 @@ export const fetchChallenges = function ( name } = challengeData; + const instructionsLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_LENGTH || 150 if ( challengeData.parent != undefined && ( !instruction || - instruction.length < 150 || + instruction.length < (instructionsLength) || !description?.trim()?.length || !name || name.length <= 3 @@ -1065,6 +1066,7 @@ export const fetchChallenges = function ( instruction.length < 150 ) { errorMessage = AppErrors.challengeSaveFailure.saveInstructionsFailure; + errorMessage.values = { details: `${instructionsLength}` }; } else { errorMessage = AppErrors.challengeSaveFailure.saveDetailsFailure; } diff --git a/src/services/Error/Messages.js b/src/services/Error/Messages.js index 3977faa55..f154f218d 100644 --- a/src/services/Error/Messages.js +++ b/src/services/Error/Messages.js @@ -202,8 +202,8 @@ export default defineMessages({ defaultMessage: "The 'DESCRIPTION OF YOUR CHALLENGE' field is required.", }, challengeSaveInstructionFailure: { - id: "Errors.challengeSaveFailure.challengeSaveInstructionFailure", - defaultMessage: "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than 150 characters.", + id: "Errors.challengeSaveFailure.challengeSaveInstructionFailurke", + defaultMessage: "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than {details} characters.", }, challengeSaveEditPolicyAgreementFailure: { id: "Errors.challengeSaveFailure.challengeSaveEditPolicyAgreementFailure", From a9d7aefc9e8d684a95ef3c338e49bf31129c6b9e Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Wed, 10 Jan 2024 23:15:47 -0600 Subject: [PATCH 2/5] fix typos and fix comments --- .env | 2 +- .../AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js | 2 +- src/services/Error/Messages.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.env b/.env index bb7544594..7f4c089a0 100644 --- a/.env +++ b/.env @@ -195,5 +195,5 @@ REACT_APP_DISABLE_TASK_CLUSTERS='' # Disable User Leaderboard configurations REACT_APP_DISABLE_USER_LEADERBOARD_CONFIGS='' -# Character requirement for challenge instructions +# For setting the minimum character count for challenge instructions REACT_APP_CHALLENGE_INSTRUCTIONS_LENGTH=150 diff --git a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js index 4785f4edb..cbe40074e 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js @@ -764,7 +764,7 @@ will not be able to make sense of it. }, instructionsDescription: { - id: "Admin.EditChallenge.form.instructionsDescriptiojn", + id: "Admin.EditChallenge.form.instructionsDescription", defaultMessage: "Instructions must be longer than {details} characters.", }, diff --git a/src/services/Error/Messages.js b/src/services/Error/Messages.js index f154f218d..655e3b44e 100644 --- a/src/services/Error/Messages.js +++ b/src/services/Error/Messages.js @@ -202,7 +202,7 @@ export default defineMessages({ defaultMessage: "The 'DESCRIPTION OF YOUR CHALLENGE' field is required.", }, challengeSaveInstructionFailure: { - id: "Errors.challengeSaveFailure.challengeSaveInstructionFailurke", + id: "Errors.challengeSaveFailure.challengeSaveInstructionFailure", defaultMessage: "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than {details} characters.", }, challengeSaveEditPolicyAgreementFailure: { From 3a2aa57c7119c20aad1168500ca1431f67288318 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Wed, 10 Jan 2024 23:25:43 -0600 Subject: [PATCH 3/5] update variable names for instruction minimum length environment variable --- .env | 2 +- .../EditChallenge/BulkSchemas/InstructionsSchema.js | 6 +++--- .../Manage/ManageChallenges/EditChallenge/Messages.js | 2 +- .../EditChallenge/Schemas/InstructionsSchema.js | 4 ++-- src/services/Challenge/Challenge.js | 4 ++-- src/services/Error/Messages.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 7f4c089a0..b81756ab8 100644 --- a/.env +++ b/.env @@ -196,4 +196,4 @@ REACT_APP_DISABLE_TASK_CLUSTERS='' REACT_APP_DISABLE_USER_LEADERBOARD_CONFIGS='' # For setting the minimum character count for challenge instructions -REACT_APP_CHALLENGE_INSTRUCTIONS_LENGTH=150 +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 4a923327b..d49edb38d 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/BulkSchemas/InstructionsSchema.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/BulkSchemas/InstructionsSchema.js @@ -1,7 +1,7 @@ import messages from '../Messages' export const jsSchema = (intl) => { - const instructionsLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_LENGTH || 150 + const instructionsMinLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150 const schemaFields = { "$schema": "http://json-schema.org/draft-07/schema#", type: "object", @@ -9,8 +9,8 @@ export const jsSchema = (intl) => { instruction: { title: intl.formatMessage(messages.instructionLabel), type: "string", - minLength: instructionsLength, - description: intl.formatMessage(messages.instructionsDescription, {details: `${instructionsLength}`}) + 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 cbe40074e..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 be longer than {details} 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 21811c429..059785b5f 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js @@ -17,7 +17,7 @@ import messages from '../Messages' * @author [Neil Rotstan](https://github.com/nrotstan) */ export const jsSchema = (intl) => { - const instructionsLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_LENGTH || 150 + const instructionsMinLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150 const schemaFields = { "$schema": "http://json-schema.org/draft-07/schema#", type: "object", @@ -26,7 +26,7 @@ export const jsSchema = (intl) => { title: intl.formatMessage(messages.instructionLabel), type: "string", minLength: instructionsLength, - description: intl.formatMessage(messages.instructionsDescription, {details: `${instructionsLength}`}) + description: intl.formatMessage(messages.instructionsDescription, {minLength: `${instructionsMinLength}`}) }, difficulty: { title: intl.formatMessage(messages.difficultyLabel), diff --git a/src/services/Challenge/Challenge.js b/src/services/Challenge/Challenge.js index a4057616c..e7af20264 100644 --- a/src/services/Challenge/Challenge.js +++ b/src/services/Challenge/Challenge.js @@ -1044,7 +1044,7 @@ export const fetchChallenges = function ( name } = challengeData; - const instructionsLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_LENGTH || 150 + const instructionsMinLength = process.env.REACT_APP_CHALLENGE_INSTRUCTIONS_MIN_LENGTH || 150 if ( challengeData.parent != undefined && ( @@ -1066,7 +1066,7 @@ export const fetchChallenges = function ( instruction.length < 150 ) { errorMessage = AppErrors.challengeSaveFailure.saveInstructionsFailure; - errorMessage.values = { details: `${instructionsLength}` }; + errorMessage.values = { minLength: `${instructionsMinLength}` }; } else { errorMessage = AppErrors.challengeSaveFailure.saveDetailsFailure; } diff --git a/src/services/Error/Messages.js b/src/services/Error/Messages.js index 655e3b44e..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 {details} characters.", + defaultMessage: "The 'DETAILED INSTRUCTIONS FOR MAPPERS' field must have more than {minLength} characters.", }, challengeSaveEditPolicyAgreementFailure: { id: "Errors.challengeSaveFailure.challengeSaveEditPolicyAgreementFailure", From d364bba561fc74c9ce8885a202d35643d234fb0d Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Tue, 23 Jan 2024 16:35:14 -0600 Subject: [PATCH 4/5] update variables --- .../EditChallenge/Schemas/InstructionsSchema.js | 2 +- src/services/Challenge/Challenge.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js index 059785b5f..82a82b2d4 100644 --- a/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js +++ b/src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/InstructionsSchema.js @@ -25,7 +25,7 @@ export const jsSchema = (intl) => { instruction: { title: intl.formatMessage(messages.instructionLabel), type: "string", - minLength: instructionsLength, + minLength: instructionsMinLength, description: intl.formatMessage(messages.instructionsDescription, {minLength: `${instructionsMinLength}`}) }, difficulty: { diff --git a/src/services/Challenge/Challenge.js b/src/services/Challenge/Challenge.js index e7af20264..f8dd12698 100644 --- a/src/services/Challenge/Challenge.js +++ b/src/services/Challenge/Challenge.js @@ -1049,7 +1049,7 @@ export const fetchChallenges = function ( challengeData.parent != undefined && ( !instruction || - instruction.length < (instructionsLength) || + instruction.length < instructionsMinLength || !description?.trim()?.length || !name || name.length <= 3 From 43054f735451999954d6ed01c9ca0d9531ba582f Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Sun, 28 Jan 2024 14:58:21 -0600 Subject: [PATCH 5/5] add intl --- src/lang/en-US.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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",