$i = 0;
            foreach ($testcases as $tstObj => $tstValue) {
                $toform["input[{$i}]"] = $tstValue->input;
                $toform["output[{$i}]"] = $tstValue->output;
                $toform["feedback[{$i}]"] = $tstValue->feedback;
                $toform["subgrade[{$i}]"] = $tstValue->subgrade;
                $toform["usefile[{$i}]"] = $tstValue->usefile;
                $toform["caseid[{$i}]"] = $tstValue->id;
                file_prepare_draft_area($toform["inputfile[{$i}]"], $context->id, 'mod_assignment', 'onlinejudge_input', $tstValue->id, array('subdirs' => 0, 'maxfiles' => 1));
                file_prepare_draft_area($toform["outputfile[{$i}]"], $context->id, 'mod_assignment', 'onlinejudge_output', $tstValue->id, array('subdirs' => 0, 'maxfiles' => 1));
                $i++;
            }
        }
        $testform->set_data($toform);
        $testform->display();
        $assignmentinstance->view_footer();
    }
}
function emptycase(&$form, $i)
{
    if ($form->subgrade[$i] != 0.0) {
        return false;
    }
    if (isset($form->usefile[$i])) {
        return empty($form->inputfile[$i]) && empty($form->outputfile[$i]);
    } else {
        return empty($form->input[$i]) && empty($form->output[$i]);
    }
}
/* Translate CR+LF (\r\n) to LF (\n) */
function crlf2lf(&$text)