function triger_test($language, $files, $input, $output, $cpulimit, $memlimit, $expect)
 {
     global $DB;
     $judgeclass = 'judge_' . onlinejudge_judge_name($language);
     if (!$judgeclass::is_available()) {
         // skip unavailable judge
         return;
     }
     $options->input = $input;
     $options->output = $output;
     $options->cpulimit = $cpulimit;
     $options->memlimit = $memlimit;
     $options->var1 = ideoneuser;
     $options->var2 = ideonepass;
     $taskid = onlinejudge_submit_task(1, 1, $language, $files, 'simpletest', $options);
     $task = onlinejudge_judge($taskid);
     $this->assertEqual($task->status, $expect);
 }
/**
 * Judge specified task
 *
 * @param $taskorid object of task or task id
 * @return updated task
 */
function onlinejudge_judge($taskorid)
{
    global $CFG, $DB;
    if (is_object($taskorid)) {
        $task = $taskorid;
    } else {
        $task = $DB->get_record('onlinejudge_tasks', array('id' => $taskorid));
    }
    $task->judgetime = time();
    $judgeclass = 'judge_' . onlinejudge_judge_name($task->language);
    $judgeclasses = onlinejudge_get_judge_classes();
    if (!in_array($judgeclass, $judgeclasses)) {
        $task->status = ONLINEJUDGE_STATUS_INTERNAL_ERROR;
        $task->infostudent = get_string('invalidjudgeclass', 'local_onlinejudge', $judgeclass);
        $DB->update_record('onlinejudge_tasks', $task);
        throw new onlinejudge_exception('invalidjudgeclass', $judgeclass);
    }
    $judge = new $judgeclass($task);
    try {
        $task = $judge->judge();
    } catch (Exception $e) {
        $task->status = ONLINEJUDGE_STATUS_INTERNAL_ERROR;
        $task->infostudent = $e->getMessage();
        $DB->update_record('onlinejudge_tasks', $task);
        events_trigger('onlinejudge_task_judged', $task);
        throw $e;
    }
    $DB->update_record('onlinejudge_tasks', $task);
    events_trigger('onlinejudge_task_judged', $task);
    return $task;
}