Skip to content

Feature/Block names added to challenge and document titles#11251

Merged
BerkeleyTrue merged 1 commit intofreeCodeCamp:stagingfrom
Bouncey:Feature/BlockNamesAddedToTitles
Dec 15, 2016
Merged

Feature/Block names added to challenge and document titles#11251
BerkeleyTrue merged 1 commit intofreeCodeCamp:stagingfrom
Bouncey:Feature/BlockNamesAddedToTitles

Conversation

@Bouncey
Copy link
Copy Markdown
Member

@Bouncey Bouncey commented Oct 17, 2016

Pre-Submission Checklist

  • Your pull request targets the staging branch of FreeCodeCamp.
  • Branch starts with either fix/, feature/, or translate/ (e.g. fix/signin-issue)
  • You have only one commit (if not, squash them into one commit).
  • All new and existing tests pass the command npm run test-challenges. Use git commit --amend to amend any fixes.

Type of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Add new translation (feature adding new translations)

Checklist:

Description

Re-opend under new branch name

Credit for the original idea goes to @andmckvr13

@BerkeleyTrue BerkeleyTrue added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Oct 17, 2016
Copy link
Copy Markdown
Contributor

@BerkeleyTrue BerkeleyTrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the property block already on the challenge object instead of creating a new property.

{
[types.updateTitle]: (state, { payload = 'Learn To Code' }) => ({
[types.updateTitle]:
(state,

This comment was marked as off-topic.

title: payload + ' | Free Code Camp'
}),

title: `${updatedTitle} | Free Code Camp`

This comment was marked as off-topic.

state => state.challengesApp.challenge,
state => state.challengesApp.superBlocks,
({ challenge: { title } = {}, viewType }, challenge, superBlocks = []) => ({
({ challenge: { title = 'Learn to Code', blockType } = {},

This comment was marked as off-topic.

state => state.challengesApp.isCodeLocked,
(
{ challenge: { title, description, hints = [] } = {} },
{ challenge: { title, description, hints = [], blockType } = {} },

This comment was marked as off-topic.

style.height = height + 'px';
}

let titleString = () => {

This comment was marked as off-topic.

render() {
const { title, description, isCompleted } = this.props;
const { title, description, isCompleted, blockType } = this.props;
let titleString = () => {

This comment was marked as off-topic.

const { updateTitle } = this.props;
updateTitle(this.props.title);
const { updateTitle, title, blockType } = this.props;
updateTitle({blockType, title});

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

@Bouncey
Copy link
Copy Markdown
Member Author

Bouncey commented Oct 19, 2016

I couldn't find block on any challenge object, but found it on the entities object

@BerkeleyTrue
Copy link
Copy Markdown
Contributor

It's challenge.block

@Bouncey
Copy link
Copy Markdown
Member Author

Bouncey commented Oct 20, 2016

challenges.block refers to the block used in the path

I want to use challengeSpec.name, which is only available from state.entities.block[block].name

Looking at ./seed/index.js, it looks like it should be on the challenge object passed to the updateCurrentChallenge action, but when I log that object as it goes through the reducer, it's not there:

{ id: 'bd7123c8c441eddfaeb5bdef',
  name: 'Say Hello to HTML Elements',
  title: 'Say Hello to HTML Elements',
  type: 'waypoint',
  order: 2,
  suborder: 1,
  checksum: 3097141541,
  isBeta: false,
  isComingSoon: false,
  dashedName: 'say-hello-to-html-elements',
  superBlock: 'Front End Development Certification',
  superOrder: 1,
  hint: [],
  block: 'html5-and-css',
  difficulty: undefined,
  description: 
   [ 'Welcome to Free Code Camp\'s first coding challenge.',
     'You can edit <code>code</code> in your <code>text editor</code>, which we\'ve embedded into this web page.',
     'Do you see the code in your text editor that says <code>&#60;h1&#62;Hello&#60;/h1&#62;</code>? That\'s an HTML <code>element</code>.',
     'Most HTML elements have an <code>opening tag</code> and a <code>closing tag</code>.',
     'Opening tags look like this:',
     '<code>&#60;h1&#62;</code>',
     'Closing tags look like this:',
     '<code>&#60;/h1&#62;</code>',
     'Note that the only difference between opening tags and closing tags is that closing tags have a slash after their opening angle bracket.',
     'Each challenge has tests that you can run at any time by clicking the "Run tests" button. Once you get all tests passing, you can advance to the next challenge.',
     'To pass the test on this challenge, change your <code>h1</code> element\'s text to say "Hello World" instead of "Hello". Then click the "Run tests" button.' ],
  tests: 
   [ { text: 'Your <code>h1</code> element should have the text "Hello World".',
       testString: 'assert.isTrue((/hello(\\s)+world/gi).test($(\'h1\').text()), \'Your <code>h1</code> element should have the text "Hello World".\');' } ],
  head: [],
  tail: [],
  helpRoom: 'Help',
  fileName: '01-front-end-development-certification/html5-and-css.json',
  challengeSeed: [ '<h1>Hello</h1>' ],
  challengeType: 0,
  MDNlinks: undefined,
  solutions: [],
  releasedOn: undefined,
  required: [],
  blockId: 5807cf87d8438f138bf14304,
  isLocked: false,
  time: '5 hours' }

@BerkeleyTrue, if you can shed some light on how state.entities.block[block].name comes to be, I will certainly update the challenge object with challengeSpec.name.

I've followed it back as far as fetch-challenges-saga.js, but I get lost from there.

@BerkeleyTrue
Copy link
Copy Markdown
Contributor

BerkeleyTrue commented Oct 21, 2016

think of entities as a database of documents

entities: { challenge, block }

challenge is a map of challenge dashedNames to challenge objects.

{
 "say-hello-to-css": { ... }
  ....
}

Same with block

{ 
  "html-css": { ... },
 ...
}

challenge.block is the dashedName of the block that challenge belongs to. to get the title of the block you need access to the block itself.

Check out https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/common/app/routes/challenges/components/map/Block.jsx#L18

To get the title of the block

const block = entites.block[challenge.block]

const blockTitle = block.title;

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

@Bouncey
Copy link
Copy Markdown
Member Author

Bouncey commented Oct 21, 2016

The nice title like HMTL5 and CSS and Basic Javascript (challengeSpec.name) is not on entities.challenge[dashedname].

I am using entities.block[challenge.block].name which relates to challengeSpec.name

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

1 similar comment
@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

seed/index.js Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

seed/index.js Outdated

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

1 similar comment
@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

1 similar comment
@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

1 similar comment
@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

2 similar comments
@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

This comment was marked as off-topic.

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

@Bouncey
Copy link
Copy Markdown
Member Author

Bouncey commented Dec 13, 2016

I have refactored the challenge selector to act more like the server when constructing the title. entities.block was taking too long to resolve, and it was noticeable from the UI. Plus, after the rebase, it started to return undefined constantly. I think this was in part because entities.block wasn't resloved in time.

I had to move blockNameify to common/app/utils because I was getting that weird Unexpected token export again when trying to import from server/utils

PR has been rebased to clear merge conflicts

@camperbot
Copy link
Copy Markdown
Contributor

@Bouncey updated the pull request.

@BerkeleyTrue BerkeleyTrue merged commit b08fd05 into freeCodeCamp:staging Dec 15, 2016
@BerkeleyTrue BerkeleyTrue removed the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Dec 15, 2016
@Bouncey Bouncey deleted the Feature/BlockNamesAddedToTitles branch December 15, 2016 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants