diff --git a/src/backend/ExerciseGenerator.js b/src/backend/ExerciseGenerator.js index 2eeb4472..06d21ee2 100644 --- a/src/backend/ExerciseGenerator.js +++ b/src/backend/ExerciseGenerator.js @@ -9,6 +9,8 @@ import conceptInventory from '../data/ConceptMap'; // So, we import all of ConceptKnowledge import {ConceptKnowledge, MasteryModel} from '../data/MasteryModel'; +var exercises = require('../data/Exercises'); + /** * Generates exercises associated with concepts * @class @@ -20,6 +22,32 @@ class ExerciseGenerator { this.counter = 0; } + /** + * Returns and array of exercises for the given exercise type and concept + * @param exerciseType - String ("READ" or "WRITE") + * @param concept - String (Camel Cased) + */ + getExercisesByTypeAndConcept(exerciseType: string, concept: string) { + var exerciseInventory = [exercises.variable17061, exercises.variable18916, exercises.variable51520, + exercises.variable60932, exercises.variable88688]; // Add variable to this array as exercise inventory grows + var exerciseList = []; + for (var i = 0; i < exerciseInventory.length; i++) { + exerciseList = exerciseList.concat(exerciseInventory[i]); + } + var results = []; + var readTypes = ["highlightCode", "multipleChoice", "shortResponse"]; + exerciseList.forEach((item) => { + if (item.exercise.concepts.includes(concept)) { + if ((exerciseType === "READ" && readTypes.includes(item.exercise.type)) || + (exerciseType === "WRITE" && !readTypes.includes(item.exercise.type))) { + results.push(item); + } + } + }); + return results; + } + + /** * Gives optimal index of the next concept to generate questions for. * Index is based on a list of concepts, sorted in this order: diff --git a/src/data/ExercisePool.js b/src/data/ExercisePool.js index b5bbe934..feb365f5 100644 --- a/src/data/ExercisePool.js +++ b/src/data/ExercisePool.js @@ -29,6 +29,8 @@ class ExercisePoolClass { getAnswer(exercise: Exercise): ?string { return this.pool.get(exercise); } + + } let ExercisePool = new ExercisePoolClass(); diff --git a/src/data/Exercises.js b/src/data/Exercises.js index c1626b3f..2c99fbf9 100644 --- a/src/data/Exercises.js +++ b/src/data/Exercises.js @@ -31,7 +31,7 @@ export const stubExercise: { exercise: Exercise, answer: ?string } = { answer: 'abc', }; -let variable17061 = [ +export let variable17061 = [ { 'exercise': { 'prompt': 'What does this expression simplify to?', @@ -192,7 +192,7 @@ let variable17061 = [ }, 'answer': 'x = x * 4', }]; -let variable60932 = [ +export let variable60932 = [ { 'exercise': { 'prompt': 'Highlight the integer literal', @@ -248,7 +248,7 @@ let variable60932 = [ }, 'answer': 'new', }]; -let variable18916 = [ +export let variable18916 = [ { 'exercise': { 'prompt': 'What is the value of x after the following code executes?', @@ -337,7 +337,7 @@ let variable18916 = [ }, 'answer': '\'3\'', }]; -let variable88688 = [ +export let variable88688 = [ { 'exercise': { 'prompt': 'Choose the correct output of the following code', @@ -437,7 +437,7 @@ let variable88688 = [ }, 'answer': 'false', }]; -let variable51520 = [ +export let variable51520 = [ { 'exercise': { 'prompt': 'Fill in the blank so that the method behaves as follows:\naddTen(15); //would evaluate to 25\naddTen(1); //would evaluate to 11', @@ -483,7 +483,7 @@ let variable51520 = [ 'answer': '7', }]; -let survey = +export let survey = { exercise: { prompt: 'Take this survey before we begin. Rate how confident you are in your abilities for each concept.', diff --git a/src/ui/containers/App.js b/src/ui/containers/App.js index 9535d5eb..d29d961f 100644 --- a/src/ui/containers/App.js +++ b/src/ui/containers/App.js @@ -28,7 +28,8 @@ const displayType = { exercise: 'EXERCISE', feedback: 'FEEDBACK', concept: 'CONCEPT', - world: 'WORLD' + world: 'WORLD', + load: 'LOAD' }; /** * Renders the koconut application view. diff --git a/src/ui/containers/WorldView.js b/src/ui/containers/WorldView.js index a8c48287..634a0630 100644 --- a/src/ui/containers/WorldView.js +++ b/src/ui/containers/WorldView.js @@ -3,6 +3,7 @@ import React, {Component} from 'react'; import {ConceptKnowledge, MasteryModel} from '../../data/MasteryModel'; import {conceptInventory} from '../../data/ConceptMap.js'; import ConceptCard from './../components/ConceptCard'; +import ExerciseGenerator from '../../backend/ExerciseGenerator'; /** * WorldView is the world view for the app, where the user can see all the @@ -23,7 +24,6 @@ class WorldView extends Component { a.dependencyKnowledge / a.knowledge)); } - render() { let conceptList = this.getOrderedConcepts(); return (