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
    def my_sum(first, second):
    
  • 1
    return sum
    
  • 1
    sum = 0
    
  • 1
    sum += second
    
  • 1
    sum &= first
    
  • 1
    sum + second
    
  • 1
    sum + first
    
  • 1
    sum += first
    
Construct your solution here:

Correct answer

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-05 00:35:18 (CDT)
Duration:
0s
Show/Hide answer
{
  "python-ordered": [
    {
      "tag": "beff48f9-a4ea-4b27-be75-018db3dd3ef2",
      "uuid": "ec289867-fc3d-44c0-bb59-89c531ae26cf",
      "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": "ae9cee70-cd59-40cc-b10f-717accadc88b",
      "uuid": "d613f01c-794f-4de0-bed2-a8fb964f08e8",
      "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": "d32803f5-abb7-49cc-8aed-da15eddcfb7e",
      "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": "a2b034ef-404c-4f8a-babd-f7420e7fa56a",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    },
    {
      "tag": "addsecond",
      "uuid": "b89287c0-8ad3-428d-a805-71af5e43c463",
      "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": "bcce250e-b839-4bb3-8a02-e3326ec1aec0",
      "distractor_for": null,
      "initially_placed": false,
      "ordering_feedback": null,
      "distractor_feedback": null
    },
    {
      "tag": "b7f438aa-c066-45c4-9236-fc68f1f9ad2f",
      "uuid": "dbd93546-647f-4904-8e4a-cc26b47ddf2a",
      "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