You are here

function theme_quiz_questions_browser_body in Quiz 8.4

1 theme call to theme_quiz_questions_browser_body()
_quiz_question_browser_form in ./quiz.admin.inc
Creates the browser part of the quiz_questions_form

File

./quiz.theme.inc, line 36
Preprocessors and helper functions to make theming easier.

Code

function theme_quiz_questions_browser_body(&$vars) {
  $form = $vars['form'];
  $html = '<tbody id="quiz-browser-body" class="browser-table">';
  $full_options = array();
  foreach ($form['titles']['#options'] as $key => $value) {
    $full_options[$key] = $form['titles'][$key];
    $full_options[$key]['#title'] = '';
  }

  // We make the question rows
  foreach ($form['titles']['#options'] as $key => $value) {

    // Find nid and vid
    $matches = array();
    preg_match('/([0-9]+)-([0-9]+)/', $key, $matches);
    $quest_nid = $matches[1];
    $quest_vid = $matches[2];
    $html .= '<tr class="quiz-question-browser-row" id="browser-' . $key . '">';
    $html .= '<td width="35">' . drupal_render($full_options[$key]) . '</td>';
    $html .= '<td>';
    $html .= l($value, "node/{$quest_nid}", array(
      'html' => TRUE,
      'query' => array(
        'destination' => current_path(),
      ),
      'attributes' => array(
        'target' => 'blank',
      ),
    ));
    $html .= '</td>';
    $html .= '<td>' . $form['types'][$key]['#value'] . '</td>';
    $html .= '<td>' . $form['changed'][$key]['#value'] . '</td>';
    $html .= '<td>' . $form['names'][$key]['#value'] . '</td>';
    $html .= '</tr>';
  }
  if (count($form['titles']['#options']) == 0) {
    print t('No questions were found');
  }
  $html .= '</tbody>';
  return $html;
}