summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/includes/book/exercise.html39
-rw-r--r--templates/page.html26
2 files changed, 39 insertions, 26 deletions
diff --git a/templates/includes/book/exercise.html b/templates/includes/book/exercise.html
index b94e39e..8b1fd1f 100644
--- a/templates/includes/book/exercise.html
+++ b/templates/includes/book/exercise.html
@@ -1,37 +1,24 @@
<div class="header">
- <h2>Exercise #{{ section.id }}</h2>
+ <h2>Exercise</h2>
</div>
+<div class="alert alert-success hidden">
+ <b>Correct!</b>
+</div>
+
+<div class="alert alert-error hidden">
+ <b>False!</b>
+</div>
+
<div class="message">
{% autoescape false %}{{ section.content }}{% endautoescape %}
</div>
-<div class="editor" style="height: {{ section.content.split("\n").length*20 }};">{{ section.codes.base }}</div>
+<div class="editor" style="height: {{ section.content.split("\n").length*20 }};">{{ section.code.base }}</div>
-<pre class="hidden code-solution">{{ section.codes.solution }}</pre>
-<pre class="hidden code-validation">{{ section.codes.validation }}</pre>
+<pre class="hidden code-solution">{{ section.code.solution }}</pre>
+<pre class="hidden code-validation">{{ section.code.validation }}</pre>
<div class="btn-group btn-group-justified">
<a href="#" class="btn btn-default action-submit">Submit</a>
<a href="#" class="btn btn-default action-solution">Solution</a>
<a href="https://github.com/{{ githubId }}/issues/new" target="_blank" class="btn btn-default">Have a Question?</a>
-</div>
-
-<script>
-$(document).ready(function() {
- var $exercise = $("#section-{{ section.id }}");
-
- var editor = ace.edit($exercise.find(".editor").get(0));
- editor.setTheme("ace/theme/tomorrow");
- editor.getSession().setMode("ace/mode/javascript");
-
- $exercise.find(".action-submit").click(function(e) {
- e.preventDefault();
-
- alert("submit");
- });
- $exercise.find(".action-solution").click(function(e) {
- e.preventDefault();
-
- editor.setValue($exercise.find(".code-solution").html());
- });
-});
-</script> \ No newline at end of file
+</div> \ No newline at end of file
diff --git a/templates/page.html b/templates/page.html
index 3c2eb89..d7a23ac 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -22,4 +22,30 @@
</div>
</div>
</div>
+
+<script>
+$(document).ready(function() {
+ $("section.exercise").each(function() {
+ var $exercise = $(this);
+
+ var codeSolution = $exercise.find(".code-solution").html();
+ var codeValidation = $exercise.find(".code-validation").html();
+
+ var editor = ace.edit($exercise.find(".editor").get(0));
+ editor.setTheme("ace/theme/tomorrow");
+ editor.getSession().setMode("ace/mode/javascript");
+
+ $exercise.find(".action-submit").click(function(e) {
+ e.preventDefault();
+
+ alert("submit");
+ });
+ $exercise.find(".action-solution").click(function(e) {
+ e.preventDefault();
+
+ editor.setValue(codeSolution);
+ });
+ })
+});
+</script>
{% endblock %} \ No newline at end of file