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

add instructions length environment variable #2234

Merged
merged 6 commits into from
Feb 6, 2024
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
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
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",
properties: {
instruction: {
title: intl.formatMessage(messages.instructionLabel),
type: "string",
minLength: 150,
description: intl.formatMessage(messages.instructionsDescription),
minLength: instructionsMinLength,
description: intl.formatMessage(messages.instructionsDescription, {minLength: `${instructionsMinLength}`})
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ 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",
properties: {
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),
Expand Down
4 changes: 2 additions & 2 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/services/Challenge/Challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1065,6 +1066,7 @@ export const fetchChallenges = function (
instruction.length < 150
) {
errorMessage = AppErrors.challengeSaveFailure.saveInstructionsFailure;
errorMessage.values = { minLength: `${instructionsMinLength}` };
} else {
errorMessage = AppErrors.challengeSaveFailure.saveDetailsFailure;
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/Error/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading