/** * Renders the result of the submissions allocation process * * @param workshopplus_allocation_result $result as returned by the allocator's init() method * @return string HTML to be echoed */ protected function render_workshopplus_allocation_result(workshopplus_allocation_result $result) { global $CFG; $status = $result->get_status(); if (is_null($status) or $status == workshopplus_allocation_result::STATUS_VOID) { debugging('Attempt to render workshopplus_allocation_result with empty status', DEBUG_DEVELOPER); return ''; } switch ($status) { case workshopplus_allocation_result::STATUS_FAILED: if ($message = $result->get_message()) { $message = new workshopplus_message($message, workshopplus_message::TYPE_ERROR); } else { $message = new workshopplus_message(get_string('allocationerror', 'workshopplus'), workshopplus_message::TYPE_ERROR); } break; case workshopplus_allocation_result::STATUS_CONFIGURED: if ($message = $result->get_message()) { $message = new workshopplus_message($message, workshopplus_message::TYPE_INFO); } else { $message = new workshopplus_message(get_string('allocationconfigured', 'workshopplus'), workshopplus_message::TYPE_INFO); } break; case workshopplus_allocation_result::STATUS_EXECUTED: if ($message = $result->get_message()) { $message = new workshopplus_message($message, workshopplus_message::TYPE_OK); } else { $message = new workshopplus_message(get_string('allocationdone', 'workshopplus'), workshopplus_message::TYPE_OK); } break; default: throw new coding_exception('Unknown allocation result status', $status); } // start with the message $o = $this->render($message); // display the details about the process if available $logs = $result->get_logs(); if (is_array($logs) and !empty($logs)) { $o .= html_writer::start_tag('ul', array('class' => 'allocation-init-results')); foreach ($logs as $log) { if ($log->type == 'debug' and !$CFG->debugdeveloper) { // display allocation debugging messages for developers only continue; } $class = $log->type; if ($log->indent) { $class .= ' indent'; } $o .= html_writer::tag('li', $log->message, array('class' => $class)) . PHP_EOL; } $o .= html_writer::end_tag('ul'); } return $o; }