|
|
|
@ -62,7 +62,7 @@ class ExerciseLink extends AbstractLink |
|
|
|
|
* Generate an array of all exercises available. |
|
|
|
|
* @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
|
|
|
*/ |
|
|
|
|
public function get_all_links() |
|
|
|
|
public function get_all_links($getOnlyHotPotatoes = false) |
|
|
|
|
{ |
|
|
|
|
$TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT); |
|
|
|
|
$TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
@ -86,25 +86,33 @@ class ExerciseLink extends AbstractLink |
|
|
|
|
$sql = 'SELECT id,title FROM '.$exerciseTable.' |
|
|
|
|
WHERE c_id = '.$this->course_id.' AND active=1 '.$session_condition; |
|
|
|
|
|
|
|
|
|
$sqlLp = "SELECT e.id, e.title FROM $exerciseTable e INNER JOIN $lpItemTable i |
|
|
|
|
$sqlLp = "SELECT e.id, e.title |
|
|
|
|
FROM $exerciseTable e |
|
|
|
|
INNER JOIN $lpItemTable i |
|
|
|
|
ON (e.c_id = i.c_id AND e.id = i.path) |
|
|
|
|
WHERE e.c_id = $this->course_id AND active = 0 AND item_type = 'quiz' |
|
|
|
|
WHERE |
|
|
|
|
e.c_id = $this->course_id AND |
|
|
|
|
active = 0 AND |
|
|
|
|
item_type = 'quiz' |
|
|
|
|
$session_condition"; |
|
|
|
|
|
|
|
|
|
$sql2 = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility, d.id |
|
|
|
|
FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip |
|
|
|
|
FROM $TBL_DOCUMENT d |
|
|
|
|
INNER JOIN $TBL_ITEM_PROPERTY ip |
|
|
|
|
ON (d.id = ip.ref AND d.c_id = ip.c_id) |
|
|
|
|
WHERE |
|
|
|
|
d.c_id = $this->course_id AND |
|
|
|
|
ip.c_id = $this->course_id AND |
|
|
|
|
d.id = ip.ref AND |
|
|
|
|
ip.tool = '".TOOL_DOCUMENT."' AND |
|
|
|
|
(d.path LIKE '%htm%')AND (d.path LIKE '%HotPotatoes_files%') AND |
|
|
|
|
(d.path LIKE '%htm%') AND |
|
|
|
|
(d.path LIKE '%HotPotatoes_files%') AND |
|
|
|
|
d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND |
|
|
|
|
ip.visibility='1' |
|
|
|
|
ip.visibility = '1' |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
require_once api_get_path(SYS_CODE_PATH).'exercise/hotpotatoes.lib.php'; |
|
|
|
|
$exerciseInLP = array(); |
|
|
|
|
|
|
|
|
|
if (!$this->is_hp) { |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$resultLp = Database::query($sqlLp); |
|
|
|
@ -121,13 +129,10 @@ class ExerciseLink extends AbstractLink |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$hotPotatoes = []; |
|
|
|
|
if (isset($result2)) { |
|
|
|
|
if (Database::num_rows($result2) > 0) { |
|
|
|
|
while ($row=Database::fetch_array($result2)) { |
|
|
|
|
/*$path = $data['path']; |
|
|
|
|
$fname = GetQuizName($path,$documentPath); |
|
|
|
|
$cats[] = array ($data['id'], $fname);*/ |
|
|
|
|
while ($row = Database::fetch_array($result2)) { |
|
|
|
|
$attribute['path'][] = $row['path']; |
|
|
|
|
$attribute['visibility'][] = $row['visibility']; |
|
|
|
|
$attribute['comment'][] = $row['comment']; |
|
|
|
@ -139,13 +144,19 @@ class ExerciseLink extends AbstractLink |
|
|
|
|
if ($title == '') { |
|
|
|
|
$title = basename($path); |
|
|
|
|
} |
|
|
|
|
$cats[] = array($attribute['id'], $title.'(HP)'); |
|
|
|
|
$element = array($attribute['id'], $title.'(HP)'); |
|
|
|
|
$cats[] = $element; |
|
|
|
|
$hotPotatoes[] = $element; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($getOnlyHotPotatoes) { |
|
|
|
|
return $hotPotatoes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($exerciseInLP)) { |
|
|
|
|
foreach ($exerciseInLP as $exercise) { |
|
|
|
|
$cats[] = array( |
|
|
|
@ -461,4 +472,12 @@ class ExerciseLink extends AbstractLink |
|
|
|
|
{ |
|
|
|
|
return 'exercise'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param bool $hp |
|
|
|
|
*/ |
|
|
|
|
public function setHp($hp) |
|
|
|
|
{ |
|
|
|
|
$this->hp = $hp; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|