You are here

function theme_opigno_in_house_app_course_lessons in Opigno in house training app 7

Theme callback: display course quizes and results.

1 call to theme_opigno_in_house_app_course_lessons()
opigno_in_house_training_app_group_status in ./opigno_in_house_training_app.module

File

./opigno_in_house_training_app.module, line 446

Code

function theme_opigno_in_house_app_course_lessons($vars, $user) {
  $rows = array();
  if (!empty($vars)) {
    foreach ($vars as $course_id => $ihlessons) {
      foreach ($ihlessons as $ihlesson_id => $ihlesson) {
        $ihlesson = node_load($ihlesson);
        $time = strtotime($ihlesson->opigno_calendar_date['und'][0]['value']);
        $time2 = strtotime($ihlesson->opigno_calendar_date['und'][0]['value2']);
        $diff = abs($time2 - $time);
        $defaults = opigno_in_house_training_score_form_get_default_value($ihlesson_id, $user->uid);
        $defaults['status'] == '0' ? $status = t('Absent') : ($defaults['status'] == '1' ? $status = t('Attended') : ($status = '-'));
        $selected = "";
        if (strpos(current_path(), 'node/' . $ihlesson->nid) !== false) {
          $selected = "selected";
        }
        $rows[] = array(
          'class' => array(),
          'data' => array(
            l($ihlesson->title, 'node/' . $ihlesson->nid, array(
              'attributes' => array(
                'class' => array(
                  $selected,
                ),
              ),
            )),
            gmdate('H\\h i\\m', $diff),
            $status,
          ),
        );
      }
    }
  }
  $header = array(
    array(
      'data' => t('In house Lessons'),
      'class' => array(
        'opigno-ih-app-course-name',
      ),
    ),
    array(
      'data' => t('Duration'),
      'class' => array(
        'opigno-ih-app-course-duration',
      ),
    ),
    array(
      'data' => t('Status'),
      'class' => array(
        'opigno-ih-app-course-status',
      ),
    ),
  );
  if (!empty($rows)) {
    return theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'class' => array(),
      ),
    ));
  }
}