/**
  * Renders the process stage screen
  *
  * @throws restore_ui_exception
  * @param core_backup_renderer $renderer renderer instance to use
  * @return string HTML code
  */
 public function display(core_backup_renderer $renderer)
 {
     global $PAGE;
     $html = '';
     $haserrors = false;
     $url = new moodle_url($PAGE->url, array('restore' => $this->get_uniqueid(), 'stage' => restore_ui::STAGE_PROCESS, 'substage' => $this->substage, 'sesskey' => sesskey()));
     $html .= html_writer::start_tag('form', array('action' => $url->out_omit_querystring(), 'class' => 'backup-restore', 'enctype' => 'application/x-www-form-urlencoded', 'method' => 'post'));
     foreach ($url->params() as $name => $value) {
         $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value));
     }
     switch ($this->substage) {
         case self::SUBSTAGE_PRECHECKS:
             $results = $this->ui->get_controller()->get_precheck_results();
             $info = $this->ui->get_controller()->get_info();
             $haserrors = !empty($results['errors']);
             $html .= $renderer->precheck_notices($results);
             if (!empty($info->role_mappings->mappings)) {
                 $context = context_course::instance($this->ui->get_controller()->get_courseid());
                 $assignableroles = get_assignable_roles($context, ROLENAME_ALIAS, false);
                 $html .= $renderer->role_mappings($info->role_mappings->mappings, $assignableroles);
             }
             break;
         default:
             throw new restore_ui_exception('backup_ui_must_execute_first');
     }
     $html .= $renderer->substage_buttons($haserrors);
     $html .= html_writer::end_tag('form');
     return $html;
 }