Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 1794
Image: ubuntu2004
Kernel: SageMath 9.1

CheckIt Tutorial

Use this notebook to quickly write your first randomized exercise.

You can refer to a read-only copy of the original tutorial as needed while editing (in case you delete the example).

First, write a generator

Edit the below Code cell to create a function to generate the random data used in your exercise.

Use [Ctrl]+[Enter] to see sample output used for your exercise.

load("main.sage") def generator(): # define any variables you'll use x,y = var("x y") # use functions like `choice` and `randrange` to make random choices A = choice([-1,1])*randrange(1,10) B = choice([-1,1])*randrange(1,10) C = choice([-1,1])*randrange(1,10) # Ask for slope or y-intercept? version = choice(['slope','yint']) #Randomly use standard form or silly form equations if choice([True,False]): equations = [ (A*x+B*y==C), (B*x-C*y==A), ] # standard form else: equations = [ [y, "\\times", B, "+", x, "\\times", A, "=", C], [y, "\\times", -C, "+", x, "\\times", B, "=", A] ] # silly form -- must construct LaTeX by hand # build the objects you need return { "equations": equations, "slopes": [ -A/B, B/C, ], "yints": [ C/B, -A/C, ], "version": version, } # preview example data in this notebook print(generator())
{'equations': [[y, '\\times', 1, '+', x, '\\times', -8, '=', -8], [y, '\\times', 8, '+', x, '\\times', 1, '=', -8]], 'slopes': [8, -1/8], 'yints': [-8, -1], 'version': 'slope'}

Now, write a template

Edit the following PreTeXt exercise template to write your exercise's statement and answer.

Randomized data from the generator can be accessed using <xsl:value-of select="name"/>.

Use [Ctrl]+[Enter] to display your randomly generated exercise in a variety of formats, including HTML and LaTeX.

template = r""" <exercise> <statement> <p> Find the <xsl:choose> <xsl:when test="version='slope'"> slopes </xsl:when> <xsl:otherwise> y-intercepts </xsl:otherwise> </xsl:choose> for each of the following equations. </p> <ul> <xsl:for-each select="equations/*"> <li><m><xsl:value-of select="."/></m></li> </xsl:for-each> </ul> </statement> <answer> <ul> <xsl:choose> <xsl:when test="version='slope'"> <xsl:for-each select="slopes/*"> <li><m><xsl:value-of select="."/></m></li> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:for-each select="yints/*"> <li><m><xsl:value-of select="."/></m></li> </xsl:for-each> </xsl:otherwise> </xsl:choose> </ul> </answer> </exercise> """ exercise = Exercise( title="Slopes and Intercepts of Lines", slug="example", generator=generator, template=template seed=randrange(1000) ) from IPython.core.display import display, HTML display(HTML(exercise.html())) exercise.preview()

Find the y-intercepts for each of the following equations.

  • 8x5y=2 8 \, x - 5 \, y = 2
  • 5x2y=8 -5 \, x - 2 \, y = 8

Answer:

  • 25 -\frac{2}{5}
  • 4 -4
Data XML ----------- <data> <equations> <item> 8 \, x - 5 \, y = 2 </item> <item> -5 \, x - 2 \, y = 8 </item> </equations> <slopes> <item> \frac{8}{5} </item> <item> -\frac{5}{2} </item> </slopes> <yints> <item> -\frac{2}{5} </item> <item> -4 </item> </yints> <version>yint</version> </data> HTML source ----------- <div class="exercise"> <div class="exercise-statement"> <p> Find the y-intercepts for each of the following equations. </p> <ul> <li>\( 8 \, x - 5 \, y = 2 \)</li> <li>\( -5 \, x - 2 \, y = 8 \)</li> </ul> </div> <div class="exercise-answer"> <p> <b>Answer:</b> </p> <ul> <li>\( -\frac{2}{5} \)</li> <li>\( -4 \)</li> </ul> </div> </div> LaTeX source ------------ \begin{exerciseStatement} Find the y-intercepts for each of the following equations. \begin{itemize} \item \( 8 \, x - 5 \, y = 2 \) \item \( -5 \, x - 2 \, y = 8 \) \end{itemize} \end{exerciseStatement} \begin{exerciseAnswer} \begin{itemize} \item \( -\frac{2}{5} \) \item \( -4 \) \end{itemize} \end{exerciseAnswer} QTI source ------------ <item ident="-" title=" | | ver. "> <itemmetadata> <qtimetadata> <qtimetadatafield> <fieldlabel>question_type</fieldlabel> <fieldentry>essay_question</fieldentry> </qtimetadatafield> </qtimetadata> </itemmetadata> <presentation> <material> <mattextxml> <div class="exercise-statement"> <p> <strong>.</strong> </p> <p> Find the y-intercepts for each of the following equations. </p> <ul> <li> <img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?8 \, x - 5 \, y = 2" alt="8 \, x - 5 \, y = 2" title="8 \, x - 5 \, y = 2" data-latex="8 \, x - 5 \, y = 2"/> </li> <li> <img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?-5 \, x - 2 \, y = 8" alt="-5 \, x - 2 \, y = 8" title="-5 \, x - 2 \, y = 8" data-latex="-5 \, x - 2 \, y = 8"/> </li> </ul> </div> </mattextxml> <mattext texttype="text/html">&lt;div class="exercise-statement"&gt; &lt;p&gt; &lt;strong&gt;.&lt;/strong&gt; &lt;/p&gt; &lt;p&gt; Find the y-intercepts for each of the following equations. &lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?8%20%5C,%20x%20-%205%20%5C,%20y%20=%202" alt="8 \, x - 5 \, y = 2" title="8 \, x - 5 \, y = 2" data-latex="8 \, x - 5 \, y = 2"&gt; &lt;/li&gt; &lt;li&gt; &lt;img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?-5%20%5C,%20x%20-%202%20%5C,%20y%20=%208" alt="-5 \, x - 2 \, y = 8" title="-5 \, x - 2 \, y = 8" data-latex="-5 \, x - 2 \, y = 8"&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </mattext> </material> <response_str ident="response1" rcardinality="Single"> <render_fib> <response_label ident="answer1" rshuffle="No"/> </render_fib> </response_str> </presentation> <itemfeedback ident="general_fb"> <flow_mat> <material> <mattextxml> <div class="exercise-answer"> <h4>Partial Answer:</h4> <ul> <li> <img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?-\frac{2}{5}" alt="-\frac{2}{5}" title="-\frac{2}{5}" data-latex="-\frac{2}{5}"/> </li> <li> <img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?-4" alt="-4" title="-4" data-latex="-4"/> </li> </ul> </div> </mattextxml> <mattext texttype="text/html">&lt;div class="exercise-answer"&gt; &lt;h4&gt;Partial Answer:&lt;/h4&gt; &lt;ul&gt; &lt;li&gt; &lt;img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?-%5Cfrac%7B2%7D%7B5%7D" alt="-\frac{2}{5}" title="-\frac{2}{5}" data-latex="-\frac{2}{5}"&gt; &lt;/li&gt; &lt;li&gt; &lt;img style="border:1px #ddd solid;padding:5px;border-radius:5px;" src="https://latex.codecogs.com/svg.latex?-4" alt="-4" title="-4" data-latex="-4"&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </mattext> </material> </flow_mat> </itemfeedback> </item> PreTeXt source ------------ <exercise checkit-seed="6183" checkit-slug="example" checkit-name="Slopes and Intercepts of Lines"> <statement> <p> Find the y-intercepts for each of the following equations. </p> <ul> <li> <m> 8 \, x - 5 \, y = 2 </m> </li> <li> <m> -5 \, x - 2 \, y = 8 </m> </li> </ul> </statement> <answer> <ul> <li> <m> -\frac{2}{5} </m> </li> <li> <m> -4 </m> </li> </ul> </answer> </exercise>

Start building your exercise bank!

Join us in the #checkit-app channel in the Mastery Grading Slack workspace to learn how to create exercise banks like those found at https://checkit.clontz.org.