function get_item_display_classname($column, $item)
 {
     $sturec = array();
     $waitrec = array();
     if (isset($item->completionid)) {
         if ($item->completionid == STUSTATUS_NOTCOMPLETE) {
             return get_string('onenroledlist', 'local_elisprogram') . (coursecatalogpage::user_can_unenrol($item, $this->cuserid, $sturec, $waitrec) ? ' - ' . html_writer::tag('a', get_string('unenrolfromclass', 'local_elisprogram'), array('href' => 'index.php?s=crscat&section=curr&action=confirmunenrol' . (!empty($sturec) ? "&stuid={$sturec->id}" : '') . (!empty($waitrec) ? "&wlid={$waitrec->id}" : ''))) : '');
         } else {
             if ($item->completionid == STUSTATUS_PASSED) {
                 return get_string('onpassed', 'local_elisprogram');
             } else {
                 if ($item->completionid == STUSTATUS_FAILED) {
                     return get_string('onfailed', 'local_elisprogram');
                 }
             }
         }
     } else {
         if (!empty($item->prereqcount)) {
             return get_string('unsatisfiedprereqs', 'local_elisprogram');
         } else {
             if (empty($item->classcount)) {
                 return get_string('noclassavail', 'local_elisprogram');
             } else {
                 if (!empty($item->waiting)) {
                     return get_string('onwaitlist', 'local_elisprogram') . (coursecatalogpage::user_can_unenrol($item, $this->cuserid, $sturec, $waitrec) ? ' - ' . html_writer::tag('a', get_string('unenrolfromclass', 'local_elisprogram'), array('href' => 'index.php?s=crscat&section=curr&action=confirmunenrol' . (!empty($sturec) ? "&stuid={$sturec->id}" : '') . (!empty($waitrec) ? "&wlid={$waitrec->id}" : ''))) : '');
                 } else {
                     return get_string('noclassyet', 'local_elisprogram') . ' - <a href="' . "index.php?s=crscat&amp;section=curr&amp;crsid={$item->courseid}" . '&amp;action=add">' . get_string('chooseclass', 'local_elisprogram') . '</a>';
                 }
             }
         }
     }
 }
 /**
  * Test coursecatalogpage->display_savenew() for setting of class enrolment time (ELIS-8518)
  * @uses $DB
  * @uses $USER
  */
 public function test_display_savenew_classenrolmenttime()
 {
     global $DB, $USER;
     $this->load_csv_data_for_enrolment_test();
     $USER = $DB->get_record('user', array('id' => 100));
     // Set user to the test user.
     $_GET['clsid'] = 100;
     // Class GET parameter is expected by coursecatalogpage function.
     $now = time();
     // Set the startdate on the ELIS class to a day in the future.
     $pmclass = new pmclass(100);
     $pmclass->startdate = $now + 60 * 60 * 24;
     $pmclass->save();
     // Set the startdate on the associated Moodle course to a day in the past.
     $course = new stdClass();
     $course->id = 100;
     $course->startdate = $now - 60 * 60 * 24;
     $DB->update_record('course', $course);
     $coursecatalogpage = new coursecatalogpage();
     try {
         $coursecatalogpage->display_savenew();
     } catch (Exception $e) {
         // Ignore the redirect error message because we are not testing that here.
     }
     $enrolmenttime = $DB->get_field('local_elisprogram_cls_enrol', 'enrolmenttime', array('classid' => 100, 'userid' => 103));
     $difference = abs($now - $enrolmenttime);
     $this->assertLessThanOrEqual(1, $difference);
     // Allow for 1 second variance, just in case.
 }
 function get_navigation_available()
 {
     $page = new coursecatalogpage(array());
     return array(array('name' => get_string('availablecourses', 'block_curr_admin'), 'link' => $page->get_url()));
 }