diff --git a/challenges.json b/challenges.json index c29da8f..5e34d59 100644 --- a/challenges.json +++ b/challenges.json @@ -1 +1 @@ -{"name":"Python Beginner Challenges","last_edit":1496278825778,"challenges":[[],[{"id":"592f1cc969cf862d8a7bb7f2","title":"Input Edit","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":1,"lesson":3}],[],[],[{"id":"592893767a194ee412ae2e1f","title":"Addition Edit","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":1},{"id":"592895b87a194ee412ae2e20","title":"Subtraction","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":2},{"id":"592895ef7a194ee412ae2e21","title":"Multiplication","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":3},{"id":"5928961e7a194ee412ae2e22","title":"Float Division","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":4},{"id":"592896397a194ee412ae2e23","title":"Integer Division","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":5},{"id":"5928965a7a194ee412ae2e24","title":"Exponents","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":6},{"id":"592896717a194ee412ae2e25","title":"Remainder","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":7},{"id":"592898c97a194ee412ae2e26","title":"Divmod","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":8},{"id":"592898dc7a194ee412ae2e27","title":"Square Root","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":9},{"id":"592899f67a194ee412ae2e28","title":"Sum","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":10},{"id":"59289a1a7a194ee412ae2e29","title":"Rounding","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":11},{"id":"59289a2f7a194ee412ae2e2a","title":"Absolute Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":12},{"id":"59289a477a194ee412ae2e2b","title":"Min Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":13},{"id":"59289a5a7a194ee412ae2e2c","title":"Max Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":14}],[]]} \ No newline at end of file +{"name":"Python Beginner Challenges","last_edit":1496291556934,"chapters":["Introduction","Input","Dummy","Dummy 2","Math"],"challenges":[[],[],[],[],[{"id":"592893767a194ee412ae2e1f","title":"Addition","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":1},{"id":"592895b87a194ee412ae2e20","title":"Subtraction","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":2},{"id":"592895ef7a194ee412ae2e21","title":"Multiplication","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":3},{"id":"5928961e7a194ee412ae2e22","title":"Float Division","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":4},{"id":"592896397a194ee412ae2e23","title":"Integer Division","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":5},{"id":"5928965a7a194ee412ae2e24","title":"Exponents","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":6},{"id":"592896717a194ee412ae2e25","title":"Remainder","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":7},{"id":"592898c97a194ee412ae2e26","title":"Divmod","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":8},{"id":"592898dc7a194ee412ae2e27","title":"Square Root","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":9},{"id":"592899f67a194ee412ae2e28","title":"Sum","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":10},{"id":"59289a1a7a194ee412ae2e29","title":"Rounding","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":11},{"id":"59289a2f7a194ee412ae2e2a","title":"Absolute Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":12},{"id":"59289a477a194ee412ae2e2b","title":"Min Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":13},{"id":"59289a5a7a194ee412ae2e2c","title":"Max Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":14}],[]]} diff --git a/challenges/4.1.Addition/lesson_settings.json b/challenges/4.1.Addition/lesson_settings.json index fb7a17e..f9db25d 100644 --- a/challenges/4.1.Addition/lesson_settings.json +++ b/challenges/4.1.Addition/lesson_settings.json @@ -1,5 +1,5 @@ { - "lesson_title": "Addition Edit", + "lesson_title": "Addition", "chapter_number": 4, "lesson_number": 1, "id":"592893767a194ee412ae2e1f", diff --git a/generate-challenge-json.js b/generate-challenge-json.js index 8535a64..0df66fe 100644 --- a/generate-challenge-json.js +++ b/generate-challenge-json.js @@ -53,8 +53,26 @@ dir_list.forEach((dir) => { "lesson": lesson_number }; + // attempt to autofill 'missing' challenges + // + // const blank_lesson_obj = { + // "id": null, + // "title": "NA", + // "repl": default_repl, + // "completed": false, + // "chapter": null, + // "lesson": null + // } + if (!challenges_id_list.includes(id)) { let chapter = challenges_list[chapter_number]; + // if ( lesson_number !== 1 && chapter.length < lesson_number ) { + // for (let i = 1; i < lesson_number; i++ ) { + // blank_lesson_obj.chapter = chapter_number; + // blank_lesson_obj.lesson = i; + // chapter.push(blank_lesson_obj); + // } + // } let a = chapter.slice(0, lesson_number); let b = chapter.slice(lesson_number + 1, chapter.length); a.push(lesson_obj); diff --git a/index.html b/index.html index 26be322..c9ed298 100644 --- a/index.html +++ b/index.html @@ -71,15 +71,10 @@
× -
- Addition - Subtraction - Dummy 1 - Dummy 2 -
+ diff --git a/renderMap.js b/renderMap.js new file mode 100644 index 0000000..a2c23dc --- /dev/null +++ b/renderMap.js @@ -0,0 +1,58 @@ +/*global $*/ +function createLesson(title, id) { + const linkNode = document.createElement("a"); + linkNode.classList.add("lesson-link"); + linkNode.appendChild(document.createTextNode(title)); + linkNode.setAttribute("href", ""); + linkNode.setAttribute("onclick", `loadChallengeFromMap('${id}')`); + const listNode = document.createElement("li"); + listNode.classList.add("lesson-list-element"); + + listNode.appendChild(linkNode); + + return listNode; +} +function createChapter(title, lessonList) { + const chapterNode = document.createElement("div"); + chapterNode.classList.add("chapter"); + + const titleSpanNode = document.createElement("span"); + titleSpanNode.classList.add("chapter-title"); + titleSpanNode.appendChild(document.createTextNode(title)); + + chapterNode.appendChild(titleSpanNode); + + const lessonListNode = document.createElement("ul"); + lessonListNode.classList.add("lesson-list"); + + lessonList.forEach((lesson) => { + lessonListNode.appendChild(createLesson(lesson.title, lesson.id)); + }); + + chapterNode.appendChild(lessonListNode); + + return chapterNode; +} +function renderMap() { + const map = document.getElementById("map"); + + const challengeList = document.createElement("div"); + challengeList.classList.add("challenge-list"); + + + $.getJSON("./challenges.json") + .done(({chapters, challenges}) => { + challenges.forEach((lessons, i) => { + const title = chapters[i]; + challengeList.appendChild(createChapter(title, lessons)); + }); + }) + .fail((jqxhr, textStatus, error ) => { + console.log(`Req failed: ${textStatus}, ${error}`); + }); + + map.appendChild(challengeList); + +} + +renderMap(); diff --git a/stylesheet.css b/stylesheet.css index 0317bcb..2c7e626 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -215,3 +215,21 @@ h2 { .challenge-list { border-top: 2px solid #006400; } + +.chapter { + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; +} +.chapter-title { + color: #006400; + font-size: 1.5rem; + padding-left: 10px; +} +.lesson-list { + list-style: none; + align-self: left; + padding-left: 5px; + margin-top: 0; +}