| @@ 151-176 (lines=26) @@ | ||
| 148 | * @param int $ref_id representative id inside one tool item |
|
| 149 | * @return array |
|
| 150 | */ |
|
| 151 | function get_specific_field_values_list_by_prefix( |
|
| 152 | $prefix, |
|
| 153 | $course_code, |
|
| 154 | $tool_id, |
|
| 155 | $ref_id |
|
| 156 | ) { |
|
| 157 | $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
|
| 158 | $table_sfv = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 159 | $sql = 'SELECT sfv.value FROM %s sf LEFT JOIN %s sfv ON sf.id = sfv.field_id'. |
|
| 160 | ' WHERE sf.code = \'%s\' AND sfv.c_id = \'%s\' AND tool_id = \'%s\' AND sfv.ref_id = %s'; |
|
| 161 | $sql = sprintf( |
|
| 162 | $sql, |
|
| 163 | $table_sf, |
|
| 164 | $table_sfv, |
|
| 165 | $prefix, |
|
| 166 | $course_code, |
|
| 167 | $tool_id, |
|
| 168 | $ref_id |
|
| 169 | ); |
|
| 170 | $sql_result = Database::query($sql); |
|
| 171 | while ($result = Database::fetch_array($sql_result)) { |
|
| 172 | $return_array[] = $result; |
|
| 173 | } |
|
| 174 | ||
| 175 | return $return_array; |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * Add a specific field value |
|
| @@ 3327-3349 (lines=23) @@ | ||
| 3324 | * @param int Session id |
|
| 3325 | * @return array Courses list |
|
| 3326 | */ |
|
| 3327 | public static function get_courses_list_from_session($session_id) |
|
| 3328 | { |
|
| 3329 | $session_id = intval($session_id); |
|
| 3330 | ||
| 3331 | // table definition |
|
| 3332 | $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
| 3333 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
| 3334 | ||
| 3335 | $sql = "SELECT DISTINCT code, c_id |
|
| 3336 | FROM $tbl_session_course sc |
|
| 3337 | INNER JOIN $courseTable c |
|
| 3338 | ON sc.c_id = c.id |
|
| 3339 | WHERE session_id= $session_id"; |
|
| 3340 | ||
| 3341 | $result = Database::query($sql); |
|
| 3342 | ||
| 3343 | $courses = array(); |
|
| 3344 | while ($row = Database::fetch_array($result)) { |
|
| 3345 | $courses[$row['code']] = $row; |
|
| 3346 | } |
|
| 3347 | ||
| 3348 | return $courses; |
|
| 3349 | } |
|
| 3350 | ||
| 3351 | /** |
|
| 3352 | * Count the number of documents that an user has uploaded to a course |
|
| @@ 5495-5518 (lines=24) @@ | ||
| 5492 | * @param string $lastname Lastname to search |
|
| 5493 | * @return array The user list |
|
| 5494 | */ |
|
| 5495 | public static function getUserByName($firstname, $lastname) |
|
| 5496 | { |
|
| 5497 | $firstname = Database::escape_string($firstname); |
|
| 5498 | $lastname = Database::escape_string($lastname); |
|
| 5499 | ||
| 5500 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
| 5501 | ||
| 5502 | $sql = <<<SQL |
|
| 5503 | SELECT id, username, lastname, firstname |
|
| 5504 | FROM $userTable |
|
| 5505 | WHERE |
|
| 5506 | firstname LIKE '$firstname%' AND |
|
| 5507 | lastname LIKE '$lastname%' |
|
| 5508 | SQL; |
|
| 5509 | ||
| 5510 | $result = Database::query($sql); |
|
| 5511 | ||
| 5512 | $users = []; |
|
| 5513 | while ($resultData = Database::fetch_object($result)) { |
|
| 5514 | $users[] = $resultData; |
|
| 5515 | } |
|
| 5516 | ||
| 5517 | return $users; |
|
| 5518 | } |
|
| 5519 | ||
| 5520 | /** |
|
| 5521 | * @param int $optionSelected |
|