/**
  * Returns the HTML for a "big select list" for selecting courses
  *
  * Allows courses to be selected for either subject or tutor reviews to be generated
  * for that course.  Those which already have reviews can have missing reviews
  * generated, or a new snapshot of statistics taken.
  *
  * @param progressreview_potential_course_selector $potential_selector
  * @param progressreview_distributed_course_selector $distributed_selector
  * @param int $sessionid
  * @param int $type PROGRESSREVIEW_SUBJECT or PROGRESSREVIEW_TUTOR
  * @return string HTML for the form
  */
 public function course_selector_form($potential_selector, $distributed_selector, $sessionid, $type = PROGRESSREVIEW_SUBJECT)
 {
     $buttonsuffix = $type == PROGRESSREVIEW_SUBJECT ? '_subject' : '_tutor';
     $output = '';
     $table = new html_table('course_selector');
     $row = new html_table_row();
     $row->cells[] = $distributed_selector->display(true);
     $strcreatereviews = get_string('createreviews', 'local_progressreview');
     $attrs = array('class' => 'course_selector_button', 'name' => 'generate' . $buttonsuffix, 'type' => 'submit', 'value' => $this->output->larrow() . ' ' . $strcreatereviews);
     $cell = html_writer::empty_tag('input', $attrs);
     $row->cells[] = $cell;
     $row->cells[] = $potential_selector->display(true);
     $table->data[] = $row;
     $attrs = array('action' => $this->page->url->out(), 'method' => 'post');
     $output = html_writer::start_tag('form', $attrs);
     $attrs = array('type' => 'hidden', 'name' => 'id', 'value' => $sessionid);
     $output .= html_writer::empty_tag('input', $attrs);
     $output .= html_writer::table($table);
     $attrs = array('type' => 'submit', 'name' => 'regenerate' . $buttonsuffix, 'value' => get_string('regenerate', 'local_progressreview'));
     $output .= html_writer::empty_tag('input', $attrs);
     if ($type == PROGRESSREVIEW_SUBJECT) {
         $attrs = array('type' => 'submit', 'name' => 'snapshot', 'value' => get_string('snapshot', 'local_progressreview'));
         $output .= html_writer::empty_tag('input', $attrs);
     }
     $output .= html_writer::end_tag('form');
     return $output;
 }
         }
     }
 }
 if ($subjects) {
     foreach ($subjects as $subject) {
         progressreview_controller::generate_reviews_for_course($subject->id, $session->id, PROGRESSREVIEW_SUBJECT);
     }
     redirect($PAGE->url->out(), get_string('reviewsgenerated', 'local_progressreview'));
     exit;
 }
 $subject_selector = $output->course_selector_form($potential_subject_selector, $distributed_subject_selector, $session->id);
 $content = $OUTPUT->heading(get_string('subjectreviews', 'local_progressreview'), 2);
 $content .= $subject_selector;
 // Tutor group selector
 $potential_tutor_selector = new progressreview_potential_course_selector('potential_tutors');
 $distributed_tutor_selector = new progressreview_distributed_course_selector('distributed_tutors', $session->id, PROGRESSREVIEW_TUTOR);
 $excludes = $distributed_tutor_selector->find_users();
 foreach ($excludes as $exclude) {
     $potential_tutor_selector->exclude(array_keys($exclude));
 }
 $tutors = array();
 if ($generate_tutor) {
     $tutors = $potential_tutor_selector->get_selected_users();
 } else {
     if ($regenerate_tutor) {
         $tutors = $distributed_tutor_selector->get_selected_users();
     }
 }
 if ($tutors) {
     add_to_log(SITEID, 'local_progressreview', 'update reviews', $PAGE->url->out(), count($tutors));
     foreach ($tutors as $tutor) {