You are viewing this question as it will appear in the manual grading interface. Return to the normal view when you are done.

Element pl-order-blocks: code with ranking and indentation

This question illustrates the grading-method="ranking" mode of pl-order-blocks, which is useful for Parsons-style coding problems.


Implement the Python function my_sum, which takes 2 numbers, first and second, and returns their sum. Note that the ordering of instantiation, computation, and returning of the value must be correct. Remember to indent your code!

This example uses grading-method="ranking" to control how the correct solution is ordered, the indent attribute in pl-answer to define expected code indentation, and the distractor-for attribute to visually pair blocks with their distractors.

Drag from here:
  • 1
    return sum
    
  • 1
    def my_sum(first, second):
    
  • 1
    sum = 0
    
  • 1
    sum += first
    
  • 1
    sum &= first
    
  • 1
    sum + second
    
  • 1
    sum += second
    
  • 1
    sum + first
    
Construct your solution here:

Correct answer

Correct answer (there may be other correct orders, correct indentation required):
  • 1
    def my_sum(first, second):
    
  • 1
    sum = 0
    
  • 1
    sum += first
    
  • 1
    sum += second
    
  • 1
    return sum
    


Incorrect Blocks (these blocks should not be included in your solution):
  • 1
    sum &= first
    
    • 1
      sum + second
      
    You need to store the result of the sum in a variable!
    • 1
      sum + first
      
    You need to store the result of the sum in a variable!

Student view placeholder

In student views this area is used for assessment and score info.
Tools

Staff information

Question

Title:
Element pl-order-blocks: code with ranking and indentation

Variant

Started at:
2026-08-04 23:51:00 (CDT)
Duration:
0s
Show/Hide answer
{
  "python-ordered": [
    {
      "tag": "c10774fa-afba-49f7-a888-bdfd244359db",
      "uuid": "da1112ec-e996-44e1-8f57-2037c6fa6711",
      "final": false,
      "index": 0,
      "indent": 0,
      "depends": [],
      "ranking": 1,
      "group_info": {
        "tag": null,
        "depends": null
      },
      "inner_html": "<pl-code language=\"python\">def my_sum(first, second):</pl-code>",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    },
    {
      "tag": "fcbf10de-7c5c-4d6b-a990-8531cc475323",
      "uuid": "d37addd9-eaea-4d80-9b0c-8184f4b04a70",
      "final": false,
      "index": 1,
      "indent": 1,
      "depends": [],
      "ranking": 2,
      "group_info": {
        "tag": null,
        "depends": null
      },
      "inner_html": "<pl-code language=\"python\">sum = 0</pl-code>",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    },
    {
      "tag": "addfirst",
      "uuid": "c615c323-093f-4354-8029-0c76894e874e",
      "final": false,
      "index": 2,
      "indent": 1,
      "depends": [],
      "ranking": 3,
      "group_info": {
        "tag": null,
        "depends": null
      },
      "inner_html": "<pl-code language=\"python\">sum += first</pl-code>",
      "distractor_bin": "c4212af1-60df-4c78-a1cb-010c01cf5d7d",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    },
    {
      "tag": "addsecond",
      "uuid": "daac03a0-a4b5-4840-9aef-a1937eb91f43",
      "final": false,
      "index": 3,
      "indent": 1,
      "depends": [],
      "ranking": 3,
      "group_info": {
        "tag": null,
        "depends": null
      },
      "inner_html": "<pl-code language=\"python\">sum += second</pl-code>",
      "distractor_bin": "ecb9bfee-3330-4128-83f9-3291872b685e",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    },
    {
      "tag": "d72dae3b-630e-483b-86a6-32ae9acad691",
      "uuid": "ed66e21e-46a6-4ab4-a01d-078d2051aa03",
      "final": false,
      "index": 4,
      "indent": 1,
      "depends": [],
      "ranking": 4,
      "group_info": {
        "tag": null,
        "depends": null
      },
      "inner_html": "<pl-code language=\"python\">return sum</pl-code>",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    }
  ]
}
History
dec frac
rad deg