Skip to content
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Build out your graphic in ```child_template.html```, and put your javascript in
| ![Table](https://raw.githubusercontent.com/nprapps/dailygraphics/master/graphic_templates/_thumbs/table.png) | Responsive HTML table | ```fab add_table:$SLUG``` |
| ![Issue Matrix](https://raw.githubusercontent.com/nprapps/dailygraphics/master/graphic_templates/_thumbs/issue-matrix.png) | A table comparing a list of candidates' positions on various issues | ```fab add_issue_matrix:$SLUG``` |
| ![Animated photo](https://raw.githubusercontent.com/nprapps/dailygraphics/master/graphic_templates/_thumbs/animated-photo.gif) | Animated photo (GIF alternative) | ```fab add_animated_photo:$SLUG``` |

| ![Quiz](https://raw.githubusercontent.com/nprapps/dailygraphics/master/graphic_templates/_thumbs/quiz.png) | A quiz | ```fab add_quiz:$SLUG``` |
**Note**: `$SLUG` should be URL-safe, e.g., lowercase and with dashes instead of spaces and no special characters.

Here are some examples:
Expand Down
7 changes: 7 additions & 0 deletions fabfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@ def add_table(slug):
"""
_add_graphic(slug, 'table')

@task
def add_quiz(slug):
"""
Create a quiz.
"""
_add_graphic(slug, 'quiz')

@task
def add_issue_matrix(slug):
"""
Expand Down
2 changes: 1 addition & 1 deletion graphic_templates/_base/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

// Global config
var DEFAULT_WIDTH = 600;
var DEFAULT_WIDTH = 300;
var MOBILE_THRESHOLD = 500;

// D3 formatters
Expand Down
Binary file added graphic_templates/_thumbs/quiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions graphic_templates/quiz/child_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{% extends 'base_template.html' %}

{% block content %}

{% if COPY.labels.headline %}<h1>{{ COPY.labels.headline|smarty }}</h1>{% endif %}
{% if COPY.labels.subhed %}<h2>{{ render(COPY.labels.subhed)|smarty }}</h2>{% endif %}

<div id="quiz">
<div class="question">
<div class="q">
</div>
<div class="a">
<ul>
</ul>
</div>
</div>

<p id="results"></p>
<div class="btn_div"><button class="btn next">Next</button></div>
</div>

{% if COPY.labels.footnote %}
<div class="footnotes">
<p><strong>Notes:</strong> {{ COPY.labels.footnote|smarty }}</p>
</div>
{% endif %}

<div class="footer">
{% if COPY.labels.source %}<p>Source: {{ COPY.labels.source|smarty }}</p>{% endif %}
{% if COPY.labels.credit %}<p>Credit: {{ COPY.labels.credit|smarty }}</p>{% endif %}
</div>

<script type="text/javascript">
var LBL_RIGHT = "{{ COPY.labels.lbl_right }}";
var LBL_WRONG = "{{ COPY.labels.lbl_wrong }}";
var FINAL_LOW = "{{ COPY.labels.final_low }}";
var FINAL_MID = "{{ COPY.labels.final_mid }}";
var FINAL_HIGH = "{{ COPY.labels.final_high }}";
var FINAL_LOW_UPPER = "{{ COPY.labels.final_low_upper }}";
var FINAL_MID_UPPER = "{{ COPY.labels.final_mid_upper }}";
var FINAL_HIGH_UPPER = "{{ COPY.labels.final_high_upper }}";
var QUIZ = {{ COPY.quiz.json() }};
</script>
{% endblock content %}

{% block js %}
{{ JS.push('js/lib/jquery.js') }}
{{ JS.push('js/lib/underscore.js') }}
{{ JS.push('js/graphic.js') }}
{{ JS.render('js/graphic-footer.js') }}
{% endblock js %}
124 changes: 124 additions & 0 deletions graphic_templates/quiz/child_template_alternate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{% extends 'base_template.html' %}

{% block content %}

{% if COPY.labels.headline %}<h1>{{ COPY.labels.headline|smarty }}</h1>{% endif %}
{% if COPY.labels.subhed %}<h2>{{ render(COPY.labels.subhed)|smarty }}</h2>{% endif %}

<div id="quiz">
{% for row in COPY.quiz %}
<div class="question">
<div class="q">
<p>{{ row.question|smarty }}</p>
</div>
<div class="a">
<ul>
{% if row.status_1 != 'None' %}
<li class="{{ row.status_1 }}">
<strong>{{ row.option_1 }}</strong>
{% if row.status_1 == 'correct' %}
<div class="answer">
{% if row.answer_image_name != 'None' %}
<figure>
<img src="img/{{ row.answer_image_name }}" class="answer-image-{{ row.number }}">
<figcaption>{{ row.answer_image_credits }}</figcaption>
</figure>
{% endif %}
<div class="explanation">
{{ row.answer|smarty }}
</div>
</div>
{% endif %}
</li>
{% endif %}
{% if row.status_2 != 'None' %}
<li class="{{ row.status_2 }}">
<strong>{{ row.option_2 }}</strong>
{% if row.status_2 == 'correct' %}
{% if row.answer_image_name != 'None' %}
<figure>
<img src="img/{{ row.answer_image_name }}" class="answer-image-{{ row.number }}">
<figcaption>{{ row.answer_image_credits }}</figcaption>
</figure>
{% endif %}
<div class="explanation">
{{ row.answer|smarty }}
</div>
{% endif %}
</li>
{% endif %}
{% if row.status_3 != 'None' %}
<li class="{{ row.status_3 }}">
<strong>{{ row.option_3 }}</strong>
{% if row.status_3 == 'correct' %}
<div class="answer">
{% if row.answer_image_name != 'None' %}
<figure>
<img src="img/{{ row.answer_image_name }}" class="answer-image-{{ row.number }}">
<figcaption>{{ row.answer_image_credits }}</figcaption>
</figure>
{% endif %}
<div class="explanation">
{{ row.answer|smarty }}
</div>
</div>
{% endif %}
</li>
{% endif %}
{% if row.status_4 != 'None' %}
<li class="{{ row.status_4 }}">
<strong>{{ row.option_4 }}</strong>
{% if row.status_4 == 'correct' %}
<div class="answer">
{% if row.answer_image_name != 'None' %}
<figure>
<img src="img/{{ row.answer_image_name }}" class="answer-image-{{ row.number }}">
<figcaption>{{ row.answer_image_credits }}</figcaption>
</figure>
{% endif %}
<div class="explanation">
{{ row.answer|smarty }}
</div>
</div>
{% endif %}
</li>
{% endif %}
</ul>
</div>
</div>
{% endfor %}
<p id="results"></p>
<div class="btn_div"><button class="btn next">Next</button></div>
</div>

{% if COPY.labels.footnote %}
<div class="footnotes">
<h4>Notes</h4>
<p>{{ COPY.labels.footnote|smarty }}</p>
</div>
{% endif %}

<div class="footer">
{% if COPY.labels.source %}<p>Source: {{ COPY.labels.source|smarty }}</p>{% endif %}
{% if COPY.labels.credit %}<p>Credit: {{ COPY.labels.credit|smarty }}</p>{% endif %}
</div>

<script type="text/javascript">
var LBL_RIGHT = "{{ COPY.labels.lbl_right }}";
var LBL_WRONG = "{{ COPY.labels.lbl_wrong }}";
var FINAL_LOW = "{{ COPY.labels.final_low }}";
var FINAL_MID = "{{ COPY.labels.final_mid }}";
var FINAL_HIGH = "{{ COPY.labels.final_high }}";
var FINAL_LOW_UPPER = "{{ COPY.labels.final_low_upper }}";
var FINAL_MID_UPPER = "{{ COPY.labels.final_mid_upper }}";
var FINAL_HIGH_UPPER = "{{ COPY.labels.final_high_upper }}";
var QUIZ = {{ COPY.quiz.json() }};
</script>
{% endblock content %}

{% block js %}
{{ JS.push('js/lib/jquery.js') }}
{{ JS.push('js/lib/underscore.js') }}
{{ JS.push('js/graphic.js') }}
{{ JS.render('js/graphic-footer.js') }}
{% endblock js %}
Loading