Examples from element documentation

Examples below are taken from the documentation page for PrairieLearn Elements in question.html .


Submission Elements


pl-multiple-choice
Example of a multiple choice element.

Correct Input: negative

pl-checkbox
Example of a multiple selection element.

Correct Input: A-B, B-C, and D-E.

Select all possible options that apply.
pl-number-input
Example of a fill in the blank element that accepts numeric values.

Correct Input: 1.4481914750631597

$x =$

Correct Input: 1.45

$x =$
pl-integer-input
Example of a fill in the blank element that accepts integer values.

Correct Input: 42

$y =$
pl-symbolic-input
Example of a fill in the blank element that accepts mathematical expression values.

Correct Input: x + y + 1

$z =$
pl-string-input
Example of a fill in the blank element that accepts string values.

Correct Input: Learn

Prairie
pl-matrix-component-input
Example of a fill in the blank element that provides input fields for each entry of a matrix.

Correct Input:

  • 1 in location 1x1
  • 2 in location 1x2
  • 3 in location 2x1
  • 4 in location 2x2
pl-matrix-input
Example of a fill in the blank element that provides an input field for supplying the underlying code required to create the matrix.

Correct Input:

  • MATLAB: [1 2; 3 4]
  • Python: [[1, 2], [3, 4]]
pl-file-editor
Example of an inbrowser code file editor submission element.
fib.py
pl-file-upload
Example of a file submission element.

Correct Input: foo.py, bar.c, and filename with, comma.txt

Drop files here or click to upload.
Only the files listed below will be accepted—others will be ignored.
The combined size limit of all uploaded files is 5MB.
Files

Decorative Elements


pl-code

Example of embedding code blocks with syntax highlighting.

1
2
def square(x):
    return x * x
pl-figure

Example of displaying an image in a question.

pl-file-download

Example of providing a file download option.

data.txt
pl-variable-output

Example of displaying matrices using a code export.

1
2
C = [5.000 6.000; 7.000 8.000];
D = [-1.000 4.000; 3.000 2.000];
1
2
Cm = {{5, 6}, {7, 8}};
Dm = {{-1,  4}, { 3,  2}};
1
2
3
4
import numpy as np

C = np.array([[5, 6], [7, 8]])
D = np.array([[-1,  4], [ 3,  2]])
1
2
C = matrix(c(5, 6, 7, 8), nrow = 2, ncol = 2, byrow = TRUE)
D = matrix(c(-1,  4,  3,  2), nrow = 2, ncol = 2, byrow = TRUE)
1
2
3
4
from sympy import *

C = Matrix([[5, 6], [7, 8]])
D = Matrix([[-1,  4], [ 3,  2]])
pl-matrix-latex

Example of displaying a matrix using latex.

$C = \begin{bmatrix} 5 & 6\\ 7 & 8\\\end{bmatrix}$
pl-graph

Example of a graphviz visualization.

G A A B B A->B

Example of a graphviz visualization.

A A A->A 0.50 B B A->B 0.09 C C A->C 0.41 B->A 0.26 B->B 0.29 B->C 0.45 C->A 0.26 C->B 0.27 C->C 0.46
pl-python-variable

Displaying contents of a Python dictionary.

1
{'a': 1, 'b': 2, 'c': 3}
pl-dataframe

Displaying contents of a Pandas DataFrame from Python.

  col1 col2
0 1 3
1 2 4

2 rows x 2 columns

pl-overlay

What is the length of the hypotenuse?

$$3$$
$$3$$
Correct answer
Student view placeholder
In student views this area is used for assessment and score info.
Staff information
Staff user:
Dev User
dev@example.com

Question:
Title:
Examples from element documentation
Started at:
2024-09-19 17:56:33 (CDT)
Duration:
0 s
Show/Hide answer
{
  "c": 4.242640687119285,
  "acc": {
    "key": "a",
    "html": "negative",
    "score": 1,
    "feedback": null
  },
  "vpos": [
    {
      "key": "a",
      "html": "D-E",
      "feedback": null
    },
    {
      "key": "b",
      "html": "B-C",
      "feedback": null
    },
    {
      "key": "c",
      "html": "A-B",
      "feedback": null
    }
  ],
  "ans_sig": 1.45,
  "matrixA": {
    "_type": "ndarray",
    "_dtype": "int64",
    "_value": [
      [
        1,
        2
      ],
      [
        3,
        4
      ]
    ]
  },
  "matrixB": {
    "_type": "ndarray",
    "_dtype": "int64",
    "_value": [
      [
        1,
        2
      ],
      [
        3,
        4
      ]
    ]
  },
  "ans_rtol": 1.4481914750631597,
  "int_value": 42,
  "string_value": "Learn",
  "symbolic_math": {
    "_type": "sympy",
    "_value": "x + y + 1",
    "_variables": [
      "x",
      "y"
    ],
    "_assumptions": {
      "x": {
        "commutative": true
      },
      "y": {
        "commutative": true
      }
    },
    "_custom_functions": []
  }
}