public function test_decompose_rename_operation_complex()
 {
     $this->assertEquals(array('i' => 'j', 'h' => 'i', 'a' => 'temp1', 'e' => 'a', 'g' => 'e', 'temp1' => 'g', 'd' => 'temp2', 'f' => 'd', 'temp2' => 'f'), stack_utils::decompose_rename_operation(array('a' => 'g', 'b' => 'b', 'd' => 'f', 'd' => 'f', 'e' => 'a', 'f' => 'd', 'g' => 'e', 'h' => 'i', 'i' => 'j')));
 }
        // Rename the PRT nodes.
        foreach ($question->prts as $prtname => $prt) {
            $noderenames = array();
            foreach ($prt->get_nodes_summary() as $nodekey => $notused) {
                $noderenames[$nodekey] = $data->{'nodename_' . $prtname . '_' . $nodekey} - 1;
            }
            foreach (stack_utils::decompose_rename_operation($noderenames) as $from => $to) {
                $qtype->rename_prt_node($question->id, $prtname, $from, $to);
            }
        }
        // Rename the PRTs. Much easier to do this after the nodes.
        $prtrenames = array();
        foreach ($question->prts as $prtname => $notused) {
            $prtrenames[$prtname] = $data->{'prtname_' . $prtname};
        }
        foreach (stack_utils::decompose_rename_operation($prtrenames) as $from => $to) {
            $qtype->rename_prt($question->id, $from, $to);
        }
        // Done.
        $transaction->allow_commit();
        redirect($returnurl);
    }
}
// Start output.
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
// Display the question.
echo $OUTPUT->heading(stack_string('questionpreview'), 3);
echo $quba->render_question($slot, $options);
// Display the form to rename bits of the question.
$form->display();