Example #1
0
 /**
  * add_response_to_rawdata
  *
  * @param xxx $table (passed by reference)
  * @param xxx $attemptid
  * @param xxx $column
  * @param xxx $response
  */
 function add_response_to_rawdata(&$table, $attemptid, $column, $response)
 {
     $text = '';
     static $str = null;
     if (is_null($str)) {
         $str = (object) array('correct' => get_string('correct', 'mod_hotpot'), 'wrong' => get_string('wrong', 'mod_hotpot'), 'ignored' => get_string('ignored', 'mod_hotpot'), 'score' => get_string('score', 'mod_hotpot'), 'hintsclueschecks' => get_string('clues', 'mod_hotpot') . ',' . get_string('hints', 'mod_hotpot') . ',' . get_string('checks', 'mod_hotpot'));
     }
     // correct
     if ($value = $response->correct) {
         $value = $table->set_legend($column, $value);
         $text .= html_writer::tag('li', $value, array('class' => 'correct'));
     }
     // wrong
     if ($value = $response->wrong) {
         $values = array();
         foreach (explode(',', $value) as $v) {
             $values[] = $table->set_legend($column, $v);
         }
         $text .= html_writer::tag('li', implode(',', $values), array('class' => 'wrong'));
     }
     // ignored
     if ($value = $response->ignored) {
         $values = array();
         foreach (explode(',', $value) as $v) {
             $values[] = $table->set_legend($column, $v);
         }
         $text .= html_writer::tag('li', implode(',', $values), array('class' => 'ignored'));
     }
     // numeric
     if (is_numeric($response->score)) {
         $value = $response->score . '%';
         $text .= html_writer::tag('li', $value, array('class' => 'score'));
         $hints = empty($response->hints) ? 0 : $response->hints;
         $clues = empty($response->clues) ? 0 : $response->clues;
         $checks = empty($response->checks) ? 0 : $response->checks;
         $value = '(' . $hints . ',' . $clues . ',' . $checks . ')';
         $text .= html_writer::tag('li', $value, array('class' => 'hintsclueschecks'));
     }
     if ($text) {
         $text = html_writer::tag('ul', $text, array('class' => 'response'));
     }
     $table->rawdata[$attemptid]->{$column} = $text;
 }