fix: make help button use subforum topics (#37741)
* fix: make help button use subforum topics * fix: add test to check that block exists Co-authored-by: ojeytonwilliams <ojeytonwilliams@gmail.com> * fix: improve error message * Update curriculum/test/test-challenges.js Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -29,9 +29,7 @@ function createQuestionEpic(action$, state$, { window }) {
|
|||||||
tap(() => {
|
tap(() => {
|
||||||
const state = state$.value;
|
const state = state$.value;
|
||||||
const files = challengeFilesSelector(state);
|
const files = challengeFilesSelector(state);
|
||||||
const { title: challengeTitle, challengeType } = challengeMetaSelector(
|
const { block, title: challengeTitle } = challengeMetaSelector(state);
|
||||||
state
|
|
||||||
);
|
|
||||||
const {
|
const {
|
||||||
navigator: { userAgent },
|
navigator: { userAgent },
|
||||||
location: { href }
|
location: { href }
|
||||||
@ -77,9 +75,7 @@ function createQuestionEpic(action$, state$, { window }) {
|
|||||||
\`\`\`\n${endingText}`
|
\`\`\`\n${endingText}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const category = window.encodeURIComponent(
|
const category = window.encodeURIComponent(helpCategory[block] || 'Help');
|
||||||
helpCategory[challengeType] || 'Help'
|
|
||||||
);
|
|
||||||
|
|
||||||
const studentCode = window.encodeURIComponent(textMessage);
|
const studentCode = window.encodeURIComponent(textMessage);
|
||||||
const altStudentCode = window.encodeURIComponent(altTextMessage);
|
const altStudentCode = window.encodeURIComponent(altTextMessage);
|
||||||
|
@ -21,6 +21,7 @@ const initialState = {
|
|||||||
canFocusEditor: true,
|
canFocusEditor: true,
|
||||||
challengeFiles: {},
|
challengeFiles: {},
|
||||||
challengeMeta: {
|
challengeMeta: {
|
||||||
|
block: '',
|
||||||
id: '',
|
id: '',
|
||||||
nextChallengePath: '/',
|
nextChallengePath: '/',
|
||||||
prevChallengePath: '/',
|
prevChallengePath: '/',
|
||||||
|
@ -69,8 +69,47 @@ exports.submitTypes = {
|
|||||||
|
|
||||||
// determine which help forum questions should be posted to
|
// determine which help forum questions should be posted to
|
||||||
exports.helpCategory = {
|
exports.helpCategory = {
|
||||||
[html]: 'HTML-CSS',
|
'basic-html-and-html5': 'HTML-CSS',
|
||||||
[js]: 'JavaScript',
|
'basic-css': 'HTML-CSS',
|
||||||
[backend]: 'JavaScript',
|
'applied-visual-design': 'HTML-CSS',
|
||||||
[modern]: 'JavaScript'
|
'applied-accessibility': 'HTML-CSS',
|
||||||
|
'responsive-web-design-principles': 'HTML-CSS',
|
||||||
|
'css-flexbox': 'HTML-CSS',
|
||||||
|
'css-grid': 'HTML-CSS',
|
||||||
|
'responsive-web-design-projects': 'Certification Projects',
|
||||||
|
'basic-javascript': 'JavaScript',
|
||||||
|
es6: 'JavaScript',
|
||||||
|
'regular-expressions': 'JavaScript',
|
||||||
|
debugging: 'JavaScript',
|
||||||
|
'basic-data-structures': 'JavaScript',
|
||||||
|
'basic-algorithm-scripting': 'JavaScript',
|
||||||
|
'object-oriented-programming': 'JavaScript',
|
||||||
|
'functional-programming': 'JavaScript',
|
||||||
|
'intermediate-algorithm-scripting': 'JavaScript',
|
||||||
|
'javascript-algorithms-and-data-structures-projects':
|
||||||
|
'Certification Projects',
|
||||||
|
bootstrap: 'HTML-CSS',
|
||||||
|
jquery: 'JavaScript',
|
||||||
|
sass: 'HTML-CSS',
|
||||||
|
react: 'JavaScript',
|
||||||
|
redux: 'JavaScript',
|
||||||
|
'react-and-redux': 'JavaScript',
|
||||||
|
'front-end-libraries-projects': 'Certification Projects',
|
||||||
|
'data-visualization-with-d3': 'JavaScript',
|
||||||
|
'json-apis-and-ajax': 'JavaScript',
|
||||||
|
'data-visualization-projects': 'Certification Projects',
|
||||||
|
'managing-packages-with-npm': 'JavaScript',
|
||||||
|
'basic-node-and-express': 'JavaScript',
|
||||||
|
'mongodb-and-mongoose': 'JavaScript',
|
||||||
|
'apis-and-microservices-projects': 'Certification Projects',
|
||||||
|
'information-security-with-helmetjs': 'JavaScript',
|
||||||
|
'quality-assurance-and-testing-with-chai': 'JavaScript',
|
||||||
|
'advanced-node-and-express': 'JavaScript',
|
||||||
|
'information-security-and-quality-assurance-projects':
|
||||||
|
'Certification Projects',
|
||||||
|
algorithms: 'JavaScript',
|
||||||
|
'data-structures': 'JavaScript',
|
||||||
|
'take-home-projects': 'Certification Projects',
|
||||||
|
'rosetta-code': 'JavaScript',
|
||||||
|
'project-euler': 'JavaScript'
|
||||||
};
|
};
|
||||||
|
@ -61,6 +61,7 @@ const getIntroIfRequired = (node, index, nodeArray) => {
|
|||||||
|
|
||||||
exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
|
exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
|
||||||
const {
|
const {
|
||||||
|
block,
|
||||||
fields: { slug },
|
fields: { slug },
|
||||||
required = [],
|
required = [],
|
||||||
template,
|
template,
|
||||||
@ -76,6 +77,7 @@ exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
|
|||||||
component: getTemplateComponent(challengeType),
|
component: getTemplateComponent(challengeType),
|
||||||
context: {
|
context: {
|
||||||
challengeMeta: {
|
challengeMeta: {
|
||||||
|
block: block,
|
||||||
introPath: getIntroIfRequired(node, index, thisArray),
|
introPath: getIntroIfRequired(node, index, thisArray),
|
||||||
template,
|
template,
|
||||||
required,
|
required,
|
||||||
|
@ -36,7 +36,12 @@ const { getChallengesForLang } = require('../getChallenges');
|
|||||||
const MongoIds = require('./utils/mongoIds');
|
const MongoIds = require('./utils/mongoIds');
|
||||||
const ChallengeTitles = require('./utils/challengeTitles');
|
const ChallengeTitles = require('./utils/challengeTitles');
|
||||||
const { challengeSchemaValidator } = require('../schema/challengeSchema');
|
const { challengeSchemaValidator } = require('../schema/challengeSchema');
|
||||||
const { challengeTypes } = require('../../client/utils/challengeTypes');
|
const {
|
||||||
|
challengeTypes,
|
||||||
|
helpCategory
|
||||||
|
} = require('../../client/utils/challengeTypes');
|
||||||
|
|
||||||
|
const { dasherize } = require('../../utils/slugs');
|
||||||
|
|
||||||
const { testedLangs } = require('../utils');
|
const { testedLangs } = require('../utils');
|
||||||
|
|
||||||
@ -150,6 +155,15 @@ async function getChallenges(lang) {
|
|||||||
return { lang, challenges };
|
return { lang, challenges };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateBlock(challenge) {
|
||||||
|
const dashedBlock = dasherize(challenge.block);
|
||||||
|
if (!helpCategory.hasOwnProperty(dashedBlock)) {
|
||||||
|
return `'${dashedBlock}' block not found as a helpCategory in client/utils/challengeTypes.js file for the '${challenge.title}' challenge`;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function populateTestsForLang({ lang, challenges }) {
|
function populateTestsForLang({ lang, challenges }) {
|
||||||
const mongoIds = new MongoIds();
|
const mongoIds = new MongoIds();
|
||||||
const challengeTitles = new ChallengeTitles();
|
const challengeTitles = new ChallengeTitles();
|
||||||
@ -162,9 +176,14 @@ function populateTestsForLang({ lang, challenges }) {
|
|||||||
describe(challenge.title || 'No title', function() {
|
describe(challenge.title || 'No title', function() {
|
||||||
it('Common checks', function() {
|
it('Common checks', function() {
|
||||||
const result = validateChallenge(challenge);
|
const result = validateChallenge(challenge);
|
||||||
|
const invalidBlock = validateBlock(challenge);
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
throw new AssertionError(result.error);
|
throw new AssertionError(result.error);
|
||||||
}
|
}
|
||||||
|
if (challenge.challengeType !== 7 && invalidBlock) {
|
||||||
|
throw new Error(invalidBlock);
|
||||||
|
}
|
||||||
const { id, title } = challenge;
|
const { id, title } = challenge;
|
||||||
mongoIds.check(id, title);
|
mongoIds.check(id, title);
|
||||||
challengeTitles.check(title);
|
challengeTitles.check(title);
|
||||||
|
Reference in New Issue
Block a user