Skip to content

Commit bc808c8

Browse files
committed
Remove unused code get_not_created_links, try find exercise with iid.
See BT#14242
1 parent 5124ae4 commit bc808c8

File tree

1 file changed

+17
-36
lines changed

1 file changed

+17
-36
lines changed

main/gradebook/lib/be/exerciselink.class.php

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,6 @@ public function __construct($hp = 0)
2929
}
3030
}
3131

32-
/**
33-
* Generate an array of exercises that a teacher hasn't created a link for.
34-
*
35-
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
36-
*/
37-
public function get_not_created_links()
38-
{
39-
return false;
40-
41-
if (empty($this->course_code)) {
42-
die('Error in get_not_created_links() : course code not set');
43-
}
44-
$tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
45-
46-
$sql = 'SELECT id, title FROM '.$this->get_exercise_table().' exe
47-
WHERE id NOT IN (
48-
SELECT ref_id FROM '.$tbl_grade_links.'
49-
WHERE
50-
type = '.LINK_EXERCISE." AND
51-
course_code = '".$this->get_course_code()."'
52-
) AND
53-
exe.c_id = ".$this->course_id;
54-
55-
$result = Database::query($sql);
56-
$cats = [];
57-
while ($data = Database::fetch_array($result)) {
58-
$cats[] = [$data['id'], $data['title']];
59-
}
60-
61-
return $cats;
62-
}
63-
6432
/**
6533
* Generate an array of all exercises available.
6634
*
@@ -77,7 +45,7 @@ public function get_all_links($getOnlyHotPotatoes = false)
7745

7846
$documentPath = api_get_path(SYS_COURSE_PATH).$this->course_code."/document";
7947
if (empty($this->course_code)) {
80-
die('Error in get_not_created_links() : course code not set');
48+
return [];
8149
}
8250
$sessionId = api_get_session_id();
8351
if (empty($sessionId)) {
@@ -188,7 +156,7 @@ public function has_results()
188156
WHERE
189157
session_id = $sessionId AND
190158
c_id = $course_id AND
191-
exe_exo_id = ".$this->get_ref_id();
159+
exe_exo_id = ".$this->get_ref_id();
192160
$result = Database::query($sql);
193161
$number = Database::fetch_row($result);
194162

@@ -487,14 +455,27 @@ private function get_exercise_data()
487455
ex.path LIKE '%htm%' AND
488456
ex.path LIKE '%HotPotatoes_files%' AND
489457
ip.visibility = 1";
458+
$result = Database::query($sql);
459+
$this->exercise_data = Database::fetch_array($result);
490460
} else {
491461
$sql = 'SELECT * FROM '.$tbl_exercise.'
492462
WHERE
493463
c_id = '.$this->course_id.' AND
494464
id = '.$exerciseId;
465+
$result = Database::query($sql);
466+
$rows = Database::num_rows($result);
467+
if (!empty($rows)) {
468+
$this->exercise_data = Database::fetch_array($result);
469+
} else {
470+
// Try wit iid
471+
$sql = 'SELECT * FROM '.$tbl_exercise.'
472+
WHERE
473+
c_id = '.$this->course_id.' AND
474+
iid = '.$exerciseId;
475+
$result = Database::query($sql);
476+
$this->exercise_data = Database::fetch_array($result);
477+
}
495478
}
496-
$result = Database::query($sql);
497-
$this->exercise_data = Database::fetch_array($result);
498479
}
499480

500481
return $this->exercise_data;

0 commit comments

Comments
 (0)