-
Notifications
You must be signed in to change notification settings - Fork 363
Save user solutions and show them on page #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
e7f8aa3
17eb7bf
9f43723
05bcebb
9ed9f0f
d7ce00b
0652715
0a39d2d
8dbff3b
17c2bb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -689,23 +689,37 @@ orange { | |
| line-height: 150%; | ||
| } | ||
|
|
||
| .display-help .examples-title { | ||
| .display-help .examples-title, | ||
| .display-help .solutions-title{ | ||
| margin: 45px 0 10px 0; | ||
| padding: 0; | ||
| } | ||
|
|
||
| .display-help .hint, | ||
| .display-help solution, | ||
| .display-help .example { | ||
| color: #888; | ||
| font-size: 15px; | ||
| } | ||
|
|
||
| .display-help .example { | ||
| .display-help .example, | ||
| .display-help solution { | ||
| border-bottom: solid 1px rgba(255,255,255,.1); | ||
| padding: 10px 0 12px 0; | ||
| line-height: 170%; | ||
| } | ||
|
|
||
| .display-help .solutions:not(empty) { | ||
| padding: 10px 0 12px 0; | ||
| line-height: 170%; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .display-help .solutions:empty { | ||
| padding: 0; | ||
| line-height: 170%; | ||
| } | ||
|
|
||
| .display-help .example:last-child { | ||
| border: none; | ||
| } | ||
|
|
@@ -721,6 +735,18 @@ orange { | |
| font-weight: normal; | ||
| } | ||
|
|
||
| .display-help solution { | ||
| display: inline-block; | ||
| color: #AAA; | ||
| background: rgba(255,255,255,.1); | ||
| border: none; | ||
| padding: 0 6px 0 6px; | ||
| margin: 2px 4px 2px 0; | ||
| font-size: 13px; | ||
| font-family: menlo,monospace; | ||
| font-weight: normal; | ||
| } | ||
|
|
||
| .display-help .example strong:first-of-type { | ||
| margin-left: 0px; | ||
| } | ||
|
|
@@ -1256,6 +1282,14 @@ tag:after { | |
| content: ">"; | ||
| } | ||
|
|
||
| solution { | ||
| cursor: pointer; | ||
| padding: 0 3px; | ||
| color: #AAA; | ||
| font-size: 13px; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
|
Comment on lines
+1296
to
+1303
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Show it's clickable via |
||
| .nametags { | ||
| z-index: 1; | ||
| width: 100%; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,8 @@ <h3 class="selector-name"></h3> | |
| <h2 class="title"></h2> | ||
| <h3 class="syntax"></h3> | ||
| <div class="hint"></div> | ||
| <h4 class="solutions-title">Solutions</h4> | ||
| <div class="solutions"></div> | ||
|
Comment on lines
+155
to
+156
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Sulotions title and container much like |
||
| <h4 class="examples-title">Examples</h4> | ||
| <div class="examples"></div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,6 +324,12 @@ function showHelp() { | |
| var help = level.help || ""; | ||
| var examples = level.examples ||[]; | ||
| var selector = level.selector || ""; | ||
| var solutions = [] | ||
| if (progress.guessHistory[currentLevel]) { | ||
| if (progress.guessHistory[currentLevel].solutions) { | ||
| solutions = progress.guessHistory[currentLevel].solutions; | ||
| } | ||
| } | ||
|
Comment on lines
+385
to
+390
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get |
||
| var syntax = level.syntax || ""; | ||
| var syntaxExample = level.syntaxExample || ""; | ||
| var selectorName = level.selectorName || ""; | ||
|
|
@@ -332,8 +338,19 @@ function showHelp() { | |
| $(".display-help .syntax-example").html(syntaxExample); | ||
| $(".display-help .selector-name").html(selectorName); | ||
| $(".display-help .title").html(helpTitle); | ||
| $(".display-help .examples").html(""); | ||
| $(".display-help .solutions-title").hide(); // Hide the "Solutions" heading | ||
| $(".display-help .solutions").html(""); | ||
| $(".display-help .examples-title").hide(); // Hide the "Examples" heading | ||
| $(".display-help .examples").html(""); | ||
|
|
||
| for(var s of solutions){ | ||
| var solution = $("<solution>" + s + "</solution>"); | ||
| solution.click(function(event){ | ||
| $("input").val(event.target.textContent).focus(); | ||
| }) | ||
| $(".display-help .solutions").append(solution); | ||
| $(".display-help .solutions-title").show(); // Show it if there are examples | ||
| } | ||
|
|
||
| for(var i = 0; i < examples.length; i++){ | ||
| var example = $("<div class='example'>" + examples[i] + "</div>"); | ||
|
|
@@ -414,6 +431,22 @@ function fireRule(rule) { | |
| } | ||
|
|
||
| if(win){ | ||
| if (progress.guessHistory[currentLevel]) { | ||
| if (progress.guessHistory[currentLevel].solutions) { | ||
| if (!progress.guessHistory[currentLevel].solutions.includes(rule)) { | ||
| $(".display-help .solutions-title").show(); | ||
|
||
| let solution = $("<solution>" + rule + "</solution>"); | ||
| $(".display-help .solutions").append(solution); | ||
| } | ||
| } | ||
| } | ||
| else { | ||
| console.log('shit') | ||
| $(".display-help .solutions-title").show(); | ||
| let solution = $("<solution>" + rule + "</solution>"); | ||
| $(".display-help .solutions").append(solution); | ||
| } | ||
|
|
||
|
Comment on lines
+434
to
+549
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are |
||
| ruleSelected.removeClass("strobe"); | ||
| ruleSelected.addClass("clean"); | ||
| $("input").val(""); | ||
|
|
@@ -444,7 +477,7 @@ function fireRule(rule) { | |
| // If answer is correct, let's track progress | ||
|
|
||
| if(win){ | ||
| trackProgress(currentLevel-1, "correct"); | ||
| trackProgress(currentLevel-1, "correct", rule); | ||
| } else { | ||
| trackProgress(currentLevel, "incorrect"); | ||
| } | ||
|
|
@@ -461,12 +494,13 @@ function updateProgressUI(levelNumber, completed){ | |
| } | ||
| } | ||
|
|
||
| function trackProgress(levelNumber, type){ | ||
| function trackProgress(levelNumber, type, rule = null){ | ||
| if(!progress.guessHistory[levelNumber]) { | ||
| progress.guessHistory[levelNumber] = { | ||
| correct : false, | ||
| incorrectCount : 0, | ||
| gaSent : false | ||
| solutions : [], | ||
| gaSent : false, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -484,6 +518,14 @@ function trackProgress(levelNumber, type){ | |
| levelStats.gaSent = true; | ||
| sendEvent("guess", "correct", levelNumber + 1); // Send event | ||
| } | ||
| if(levelStats.solutions) { | ||
| if (!levelStats.solutions.includes(rule.toString())) { | ||
| levelStats.solutions.push(rule.toString()); | ||
| } | ||
| } | ||
| else { | ||
| levelStats.solutions = [rule] | ||
| } | ||
| } | ||
|
|
||
| // Increments the completion percentage by 10%, and sends an event every time | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy paste from
tagbut with slighlty different margins to look good inline