Description for All quiz question and codeblock types

Quiz questions

choose_all

choose_best

You can supply any in the answer array to allow any option selected to award full points:

free_text

A user can type in the exact or a partial match for the correct answer. For example, if the correct answer is Ruby, the user can type in Ruby, R, r, etc. as the answer checking is done with a lenient regex.

free_text that needs approval

This type of question requires approval from an instructor before points are awarded. Navigate to the instructor dashboard to approve the submission. Only the best attempt can be approved.

free_text_number

You can supply “any” in the answer array to allow any number to be entered:

You can supply “any” as an option when creating this type of question to provide a fallback incorrect message:

Runnable and graded codeblocks

Runnable Ruby

Runnable Ruby with Additional Attributes

  • readonly_lines

    • Some lines can be marked as “readonly”. The user will not be able to modify these lines. This attribute accepts an array of line numbers.

    • Example: readonly_lines="[10, 16, 17]"

  • setup_code

    • A single line or a range of lines can be marked as setup code. These lines will not be shown to the user. The line numbers shown on the left margin of the code editor will not include those lines marked as setup_code.

    • Example: setup_code="1"

    • Example: setup_code="1-4"

Graded Ruby

  • First graded code block should print 'Hello, world!'

    0 / 1 tests passed

    1 2 3 4 5 6
    describe "First graded code block" do
      it "should print 'Hello, world!'" do
        path = "/tmp/code.rb"
        expect { require_relative(path) }.to output(/Hello, world!/).to_stdout, "Expected output to be 'Hello, world!', but it was something else."
      end
    end
    
  • First graded code block should print 'Nice to meet you!'

    0 / 1 tests passed

    1 2 3 4 5 6
    describe "First graded code block" do
      it "should print 'Nice to meet you!'" do
        path = "/tmp/code.rb"
        expect { require_relative(path) }.to output(/Nice to meet you!/).to_stdout, "Expected output to be 'Nice to meet you!', but it was something else."
      end
    end
    
  • More examples of graded code blocks

    The source code for a few lessons with extensive graded code blocks are helpful for reference (search the source code for .repl-test to find the relevant examples):

    Runnable HTML

    Assessment Details
    Review your overall progress for this lesson
    Assessment Title Earned Points Current Progress Assessment Points
    The choose_all question type 0.0
    0%
    2
    The choose_best question type 0.0
    0%
    1
    The choose_best question type with any correct 0.0
    0%
    1
    The free_text question type 0.0
    0%
    1
    free_text 0.0
    0%
    1
    Time taken 0.0
    0%
    1
    Free text number 0.0
    0%
    1
    Runnable Ruby (with readonly and setup) 0.0
    0%
    1
    First graded code block 0.0
    0%
    1
    Runnable HTML 0.0
    0%
    1
    Runnable Ruby 0.0
    0%
    1
    Totals 0 0% 12