Skip to content

Commit 4f10683

Browse files
committed
Show the docs some love
1 parent 7c83e1d commit 4f10683

File tree

11 files changed

+233
-164
lines changed

11 files changed

+233
-164
lines changed

README.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ features:
4646
* Facilitates live quizzes in the classroom.
4747
* In-class instant messaging via XMPP.
4848
Works well with `xmpp-popup <https://github.com/inducer/xmpp-popup>`_.
49-
* Built-in support for `VideoJS <http://www.videojs.com/>`_ offers
50-
easy-to-use support for integrating HTML5 video into course content
51-
without the need for third-party content hosting.
5249

5350
Links
5451
-----

course/page/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,18 @@
8282
8383
.. exception:: InvalidPageData
8484
85+
Base Classes For Pages
86+
======================
87+
8588
.. autoclass:: PageBase
89+
.. autoclass:: PageBaseWithTitle
90+
.. autoclass:: PageBaseWithHumanTextFeedback
91+
.. autoclass:: PageBaseWithCorrectAnswer
92+
93+
Automatic Feedback
94+
==================
95+
96+
.. autofunction:: get_auto_feedback
8697
"""
8798

8899
mark_safe_lazy = lazy(mark_safe, str)

course/page/choice.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,29 @@ class ChoiceQuestion(ChoiceQuestionBase):
257257
"""
258258
A page asking the participant to choose one of multiple answers.
259259
260+
Example:
261+
262+
.. code-block:: yaml
263+
264+
type: ChoiceQuestion
265+
id: fp_accuracy
266+
shuffle: True
267+
prompt: |
268+
# Floating point "machine epsilon"
269+
For a (binary) floating point system of the form
270+
$(s_1.s_2s_3)_2\\cdot 2^{p}$ that has an exponent range from $-128$ to
271+
$127$ and that uses three bits to store the significand $s$, what is the
272+
difference between 1 and the smallest representable number greater than
273+
one?
274+
choices:
275+
- $2^{-3}$
276+
- $2^{-4}$
277+
- $2^{-1}$
278+
- ~CORRECT~ $2^{-2}$
279+
answer_explanation: |
280+
281+
That's just what it is.
282+
260283
.. attribute:: id
261284
262285
|id-page-attr|

course/page/code.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,41 @@ class PythonCodeQuestion(CodeQuestion):
10721072
All user code as well as all code specified as part of the problem
10731073
is in Python 3.
10741074
1075+
Example:
1076+
1077+
.. code-block:: yaml
1078+
1079+
type: PythonCodeQuestion
1080+
id: addition
1081+
access_rules:
1082+
add_permissions:
1083+
- change_answer
1084+
value: 1
1085+
timeout: 10
1086+
prompt: |
1087+
# Adding two numbers in Python
1088+
Your code will receive two variables, *a* and *b*. Compute their sum and
1089+
assign it to *c*.
1090+
setup_code: |
1091+
import random
1092+
a = random.uniform(-10, 10)
1093+
b = random.uniform(-10, 10)
1094+
names_for_user: [a, b]
1095+
1096+
correct_code: |
1097+
c = a + b
1098+
names_from_user: [c]
1099+
1100+
test_code: |
1101+
if not isinstance(c, float):
1102+
feedback.finish(0, "Your computed c is not a float.")
1103+
correct_c = a + b
1104+
rel_err = abs(correct_c-c)/abs(correct_c)
1105+
if rel_err < 1e-7:
1106+
feedback.finish(1, "Your computed c was correct.")
1107+
else:
1108+
feedback.finish(0, "Your computed c was incorrect.")
1109+
10751110
If you are not including the
10761111
:attr:`course.constants.flow_permission.change_answer`
10771112
permission for your entire flow, you likely want to

course/page/inline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,9 @@ class InlineMultiQuestion(TextQuestionBase, PageBaseWithValue):
570570
571571
Text justifying the answer, written in :ref:`markup`.
572572
573-
Here is an example of :class:`InlineMultiQuestion`::
573+
Example:
574+
575+
.. code-block:: yaml
574576
575577
type: InlineMultiQuestion
576578
id: inlinemulti

course/page/text.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,30 @@ def is_answer_gradable(self):
814814

815815
class TextQuestion(TextQuestionBase, PageBaseWithValue):
816816
"""
817-
A page asking for a textual answer
817+
A page asking for a textual answer.
818+
819+
Example:
820+
821+
.. code-block:: yaml
822+
823+
type: TextQuestion
824+
id: fwd_err
825+
prompt: |
826+
# Forward Error
827+
Consider the function $f(x)=1/x$, which we approximate by its Taylor
828+
series about 1:
829+
$$
830+
f(x)\\approx 1-(x-1)+\\cdots
831+
$$
832+
What is the **forward error** of using this approximation at $x=0.5$?
833+
answers:
834+
- type: float
835+
value: 0.5
836+
rtol: 0.01
837+
- <plain>HI THERE
838+
answer_explanation: |
839+
840+
That's just what it is.
818841
819842
.. attribute:: id
820843

doc/faq.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Frequently Asked Questions
2-
==========================
2+
##########################
3+
4+
Getting Started
5+
===============
36

47
How do I get started with Relate?
58
---------------------------------
@@ -61,7 +64,7 @@ Getting everything set up
6164

6265
The course identifier is final and cannot be changed once the course
6366
is created.
64-
67+
6568
When choosing the course identifier, note that this will appear as
6669
part of the URL when students browse your course, so it is best to
6770
choose something that is easy to type and does not look out of place
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Internals
2-
^^^^^^^^^
2+
=========
33

44
Flow Page Interface
5-
===================
5+
-------------------
66

77
This describes the programming interface between Relate and a page in a flow.
88

@@ -13,23 +13,8 @@ Validation
1313

1414
.. automodule:: course.validation
1515

16-
Canonicalization of Django Names
17-
================================
18-
19-
.. currentmodule:: django.forms.forms
20-
21-
.. class:: Form
22-
23-
See :class:`django.forms.Form`.
24-
25-
.. currentmodule:: django.http.request
26-
27-
.. class:: HttpRequest
28-
29-
See :class:`django.http.HttpRequest`.
30-
3116
Stub Docs
32-
=========
17+
---------
3318

3419
.. currentmodule:: course.models
3520

@@ -43,3 +28,18 @@ Stub Docs
4328
.. currentmodule:: course.utils
4429

4530
.. class:: FlowPageContext
31+
32+
Canonicalization of Django Names
33+
--------------------------------
34+
35+
.. currentmodule:: django.forms.forms
36+
37+
.. class:: Form
38+
39+
See :class:`django.forms.Form`.
40+
41+
.. currentmodule:: django.http.request
42+
43+
.. class:: HttpRequest
44+
45+
See :class:`django.http.HttpRequest`.

doc/flow.rst

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -295,132 +295,6 @@ For example, to grant permission to revise an answer on a
295295
- change_answer
296296
value: 1
297297

298-
Predefined Page Types
299-
---------------------
300-
301-
.. currentmodule:: course.page
302-
303-
The following page types are predefined:
304-
305-
* :class:`Page` -- a page of static text
306-
* :class:`TextQuestion` -- a page allowing a textual answer
307-
* :class:`SurveyTextQuestion` -- a page allowing an ungraded textual answer
308-
* :class:`HumanGradedTextQuestion` -- a page allowing an textual answer graded by a human
309-
* :class:`InlineMultiQuestion` -- a page allowing answers to be given in-line of a block of text
310-
* :class:`ChoiceQuestion` -- a one-of-multiple-choice question
311-
* :class:`MultipleChoiceQuestion` -- a many-of-multiple-choice question
312-
* :class:`SurveyChoiceQuestion` -- a page allowing an ungraded multiple-choice answer
313-
* :class:`PythonCodeQuestion` -- an autograded code question
314-
* :class:`PythonCodeQuestionWithHumanTextFeedback`
315-
-- a code question with automatic *and* human grading
316-
* :class:`FileUploadQuestion`
317-
-- a question allowing a file upload and human grading
318-
319-
.. warning::
320-
321-
If you change the type of a question, you *must* also change its ID.
322-
Otherwise, RELATE will assume that existing answer data for this
323-
question applies to the new question type, and will likely get very
324-
confused, for one because the answer data found will not be of the
325-
expected type.
326-
327-
.. |id-page-attr| replace::
328-
329-
A short identifying name, unique within the page group. Alphanumeric
330-
with underscores, no spaces.
331-
332-
.. |title-page-attr| replace::
333-
334-
The page's title, a string. No markup allowed. Required. If not supplied,
335-
the first ten lines of the page body are searched for a
336-
Markdown heading (``# My title``) and this heading is used as a title.
337-
338-
.. |access-rules-page-attr| replace::
339-
340-
Optional. See :ref:`page-permissions`.
341-
342-
.. |value-page-attr| replace::
343-
344-
An integer or a floating point number, representing the
345-
point value of the question.
346-
347-
.. |is-optional-page-attr| replace::
348-
349-
Optional. A Boolean value indicating whether the page is an optional page
350-
which does not require answer for full completion of the flow. If
351-
``true``, the attribute *value* should not present. Defaults to ``false``
352-
if not present. Note that ``is_optional_page: true`` differs from ``value:
353-
0`` in that finishing flows with unanswered page(s) with the latter will be
354-
warned of "unanswered question(s)", while with the former won't. When using
355-
not-for-grading page(s) to collect answers from students, it's to better
356-
use ``value: 0``.
357-
358-
.. |text-widget-page-attr| replace::
359-
360-
Optional.
361-
One of ``text_input`` (default), ``textarea``, ``editor:MODE``
362-
(where ``MODE`` is a valid language mode for the CodeMirror editor,
363-
e.g. ``yaml``, or ``python`` or ``markdown``)
364-
365-
Show a Page of Text/HTML (Ungraded)
366-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
367-
.. autoclass:: Page()
368-
369-
Fill-in-the-Blank (Automatically Graded)
370-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
371-
.. autoclass:: TextQuestion()
372-
373-
Free-Answer Survey (Ungraded)
374-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
375-
.. autoclass:: SurveyTextQuestion()
376-
377-
Fill-in-the-Blank (long-/short-form) (Human-graded)
378-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
379-
.. autoclass:: HumanGradedTextQuestion()
380-
381-
Fill-in-Multiple-Blanks (Automatically Graded)
382-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
383-
.. autoclass:: InlineMultiQuestion()
384-
385-
One-out-of-Many Choice (Automatically Graded)
386-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
387-
.. autoclass:: ChoiceQuestion()
388-
389-
Many-out-of-Many Choice (Automatically Graded)
390-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
391-
.. autoclass:: MultipleChoiceQuestion()
392-
393-
One-out-of-Many Survey (Ungraded)
394-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
395-
.. autoclass:: SurveyChoiceQuestion()
396-
397-
Write Python Code (Automatically Graded)
398-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
399-
.. autoclass:: PythonCodeQuestion()
400-
401-
Write Python Code (Automatically and Human-Graded)
402-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
403-
.. autoclass:: PythonCodeQuestionWithHumanTextFeedback()
404-
405-
Upload a File (Human-Graded)
406-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
407-
408-
.. autoclass:: FileUploadQuestion()
409-
410-
Definining your own page types
411-
------------------------------
412-
413-
.. autoclass:: PageContext
414-
.. autoclass:: PageBehavior
415-
.. autofunction:: get_auto_feedback
416-
.. autoclass:: AnswerFeedback
417-
.. autoclass:: PageBase
418-
419-
.. currentmodule:: course.page.base
420-
.. autoclass:: PageBaseWithTitle
421-
.. autoclass:: PageBaseWithHumanTextFeedback
422-
.. autoclass:: PageBaseWithCorrectAnswer
423-
424298
.. _flow-life-cycle:
425299

426300
Life cycle

doc/index.rst

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ features:
3737
* Facilitates live quizzes in the classroom.
3838
* In-class instant messaging via XMPP.
3939
Works well with `xmpp-popup <https://github.com/inducer/xmpp-popup>`_.
40-
* Built-in support for `VideoJS <http://www.videojs.com/>`_ offers
41-
easy-to-use support for integrating HTML5 video into course content
42-
without the need for third-party content hosting.
4340

4441
RELATE is a based on the popular `Django <https://docs.djangoproject.com/>`_
4542
web framework for Python. It lets students participate in online activities,
@@ -48,24 +45,17 @@ pages, each of which can be both static or interactive content, for exapmle a
4845
video, a quiz question, a page of text, or, within the confines of HTML,
4946
something completely different.
5047

51-
Links
52-
-----
53-
54-
More information around the web:
55-
56-
* `Documentation <http://documen.tician.de/relate>`_
57-
* `Source code <https://github.com/inducer/relate>`_
58-
5948
Table of Contents
6049
-----------------
6150

6251
.. toctree::
63-
:maxdepth: 3
52+
:maxdepth: 2
6453

6554
content
6655
flow
56+
page-types
6757
api
68-
page
58+
flow-page-api
6959
faq
7060
misc
7161
🚀 Github <https://github.com/inducer/relate>

0 commit comments

Comments
 (0)