/** * Generates an array of surveys that a teacher hasn't created a link for. * @return array 2-dimensional array - every element contains 2 subelements (id, name) */ public function get_not_created_links() { if (empty($this->course_code)) { die('Error in get_not_created_links() : course code not set'); } $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $sql = 'SELECT survey_id, title, code FROM ' . $this->get_survey_table() . ' AS srv WHERE survey_id NOT IN (SELECT ref_id FROM ' . $tbl_grade_links . ' WHERE type = ' . LINK_SURVEY . " AND course_code = '" . $this->get_course_code() . "'" . ') AND srv.session_id=' . api_get_session_id() . ''; $result = Database::query($sql); $links = array(); while ($data = Database::fetch_array($result)) { $links[] = array($data['survey_id'], api_trunc_str($data['code'] . ': ' . self::html_to_text($data['title']), 80)); } return $links; }
/** * Return the interactions as an array for the given lp_iv_id. * This method can be used as static. * @param integer Learnpath Item View ID * @return array * @todo Transcode labels instead of switching to HTML (which requires to know the encoding of the LP) */ function get_iv_interactions_array($lp_iv_id = 0) { $charset = api_get_setting('platform_charset'); $list = array(); $table = Database::get_course_table(TABLE_LP_IV_INTERACTION); $sql = "SELECT * FROM {$table} WHERE lp_iv_id = {$lp_iv_id} ORDER BY order_id ASC"; $res = Database::query($sql, __FILE__, __LINE__); $num = Database::num_rows($res); if ($num > 0) { $list[] = array("order_id" => api_htmlentities(get_lang('Order'), ENT_QUOTES, $charset), "id" => api_htmlentities(get_lang('InteractionID'), ENT_QUOTES, $charset), "type" => api_htmlentities(get_lang('Type'), ENT_QUOTES, $charset), "time" => api_htmlentities(get_lang('TimeFinished'), ENT_QUOTES, $charset), "correct_responses" => api_htmlentities(get_lang('CorrectAnswers'), ENT_QUOTES, $charset), "student_response" => api_htmlentities(get_lang('StudentResponse'), ENT_QUOTES, $charset), "result" => api_htmlentities(get_lang('Result'), ENT_QUOTES, $charset), "latency" => api_htmlentities(get_lang('LatencyTimeSpent'), ENT_QUOTES, $charset)); while ($row = Database::fetch_array($res)) { $list[] = array("order_id" => $row['order_id'] + 1, "id" => urldecode($row['interaction_id']), "type" => $row['interaction_type'], "time" => $row['completion_time'], "correct_responses" => '', "student_response" => api_trunc_str($row['student_response'], 50), "result" => $row['result'], "latency" => $row['latency']); } } return $list; }
/** * @deprecated use api_trunc_str() instead. */ function shorten($input, $length = 15, $encoding = null) { $length = intval($length); if (!$length) { $length = 15; } return api_trunc_str($input, $length, '...', false, $encoding); }