Simplify the non-English curriculum challenge markdown files
See original GitHub issueSince the challenge tests are no longer relying on the assert message and using the yaml text
, I was wondering if the non-English .md
challenge files could be simplified to only contain translations and no code at all. For example, the following is the English version of:
---
id: 56533eb9ac21ba0edf2244cc
title: Accessing Nested Objects
challengeType: 1
guideUrl: 'https://www.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json'
---
## Description
<section id='description'>
The sub-properties of objects can be accessed by chaining together the dot or bracket notation.
Here is a nested object:
<blockquote>var ourStorage = {<br> "desk": {<br> "drawer": "stapler"<br> },<br> "cabinet": {<br> "top drawer": { <br> "folder1": "a file",<br> "folder2": "secrets"<br> },<br> "bottom drawer": "soda"<br> }<br>};<br>ourStorage.cabinet["top drawer"].folder2; // "secrets"<br>ourStorage.desk.drawer; // "stapler"</blockquote>
</section>
## Instructions
<section id='instructions'>
Access the <code>myStorage</code> object and assign the contents of the <code>glove box</code> property to the <code>gloveBoxContents</code> variable. Use bracket notation for properties with a space in their name.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>gloveBoxContents</code> should equal "maps"
testString: assert(gloveBoxContents === "maps", '<code>gloveBoxContents</code> should equal "maps"');
- text: Use dot and bracket notation to access <code>myStorage</code>
testString: assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(code), 'Use dot and bracket notation to access <code>myStorage</code>');
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
var gloveBoxContents = undefined; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
(function(x) {
if(typeof x != 'undefined') {
return "gloveBoxContents = " + x;
}
return "gloveBoxContents is undefined";
})(gloveBoxContents);
```
</div>
</section>
## Solution
<section id='solution'>
```js
var myStorage = {
"car":{
"inside":{
"glove box":"maps",
"passenger seat":"crumbs"
},
"outside":{
"trunk":"jack"
}
}
};
var gloveBoxContents = myStorage.car.inside["glove box"];
```
</section>
Maybe there is a way to write the tests runner logic to use a simplified markdown file like the following (Spanish version shown below):
---
id: 56533eb9ac21ba0edf2244cc
guideUrl: 'https://spanish.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json'
localeTitle: Accediendo a objetos anidados
---
## Description
<section id="description"> Se puede acceder a las sub-propiedades de los objetos encadenando la notación de punto o corchete. Aquí hay un objeto anidado: <blockquote> var ourStorage = { <br> "escritorio": { <br> "cajón": "grapadora" <br> } <br> "gabinete": { <br> "cajón de arriba": { <br> "folder1": "un archivo", <br> "folder2": "secretos" <br> } <br> "cajón inferior": "soda" <br> } <br> }; <br> ourStorage.cabinet ["cajón superior"]. folder2; // "secretos" <br> ourStorage.desk.drawer; // "engrapadora" </blockquote></section>
## Instructions
<section id="instructions"> Acceda al objeto <code>myStorage</code> y asigne el contenido de la propiedad <code>glove box</code> a la variable <code>gloveBoxContents</code> . Utilice la notación de corchete para las propiedades con un espacio en su nombre. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>gloveBoxContents</code> debe ser igual a "mapas"
- text: Usa la notación de puntos y corchetes para acceder a <code>myStorage</code>
```
</section>
You could possibly get rid of the front matter title
along with tests section testString
. The only tricky part would be getting rid of the Challenge Seed
, because sometimes there are comments in the code (think React challenges) that would need some translations. Maybe there is a way to add some placeholders for comments in the English code (like a ref #) and then have a Challenge Seed Comments
section in the non-English markdown with references to the #s like:
## Challenge Seed Comments
<section id='challenge-seed-comments'>
```yml
comments:
- comment1: // Setup
- comment2: // Change this line
```
</section>
Then in the English version of the Challenge Seed
, any comments would look something like:
//comment1 Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
var gloveBoxContents = undefined; //comment2 Change this line
This is probably not the simplest way to achieve this, but hopefully you get the idea of what I am talking about. I am hoping to use this issue as a way to discuss how this could be achieved.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@lynxlynxlynx Not sure if you are aware, but we can already write the test section like (due to a PR @ValeraS already merged:
Instead of:
we can now do this:
I had already started working on changing all the
testString
s when I started thinking about how we could possibly remove thetestString
from the non-English versions. One way I can think about doing that is to use something like the following in the English version:and then something like this in the non-English version:
I am sure there are a lot of reasons why the above suggestion may not work, but there must be a way to get it to work without being too “hacky”.
Would you be interested in working together on a PR to accomplish this?
What, has all the hacktoberfest review been for nothing?!