Skip to content

Commit da3ce3e

Browse files
author
Francis Gonzales
committed
Minor code format
1 parent 1b0f416 commit da3ce3e

File tree

1 file changed

+47
-55
lines changed

1 file changed

+47
-55
lines changed

main/inc/lib/thematic.lib.php

Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -541,70 +541,62 @@ public function get_thematic_plan_div($data) {
541541
return $final_return;
542542
}
543543

544-
/**
544+
/**
545545
* get thematic advance list
546-
* @param int Thematic advance id (optional), get data by thematic advance list
547-
* @param string Course code (optional)
548-
* @return array data
546+
* @param int $thematic_advance_id Thematic advance id (optional), get data by thematic advance list
547+
* @param string $course_code Course code (optional)
548+
* @param bool $force_session_id Force to have a session id
549+
* @return array $data
549550
*/
550-
public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false) { // set current course
551-
$course_info = api_get_course_info($course_code);
552-
553-
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
554-
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
551+
public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false) { // set current course
552+
$course_info = api_get_course_info($course_code);
553+
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
554+
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
555555

556-
$data = array();
557-
558-
$condition = '';
559-
if (isset($thematic_advance_id)) {
560-
$thematic_advance_id = intval($thematic_advance_id);
561-
$condition = " AND a.id = $thematic_advance_id ";
562-
}
563-
564-
$course_id = $course_info['real_id'];
556+
$data = array();
565557

558+
$condition = '';
559+
if (isset($thematic_advance_id)) {
560+
$thematic_advance_id = intval($thematic_advance_id);
561+
$condition = " AND a.id = $thematic_advance_id ";
562+
}
566563

567-
/*if ($force_session_id) {
568-
$sql = "SELECT a.* FROM $tbl_thematic_advance a INNER JOIN $tbl_thematic t ON t.id = a.thematic_id WHERE 1 $condition AND t.session_id = ".api_get_session_id()." ORDER BY start_date ";
569-
} else {
570-
$sql = "SELECT * FROM $tbl_thematic_advance a WHERE 1 $condition ORDER BY start_date ";
571-
}*/
564+
$course_id = $course_info['real_id'];
572565

573-
$sql = "SELECT * FROM $tbl_thematic_advance a WHERE c_id = $course_id $condition ORDER BY start_date ";
566+
$sql = "SELECT * FROM $tbl_thematic_advance a WHERE c_id = $course_id $condition ORDER BY start_date ";
574567

575-
$elements = array();
576-
if ($force_session_id) {
577-
$list = api_get_item_property_by_tool('thematic_advance', $course_info['code'], api_get_session_id());
578-
foreach($list as $value) {
579-
$elements[$value['ref']]= $value;
580-
}
581-
}
568+
$elements = array();
569+
if ($force_session_id) {
570+
$list = api_get_item_property_by_tool('thematic_advance', $course_info['code'], api_get_session_id());
571+
foreach($list as $value) {
572+
$elements[$value['ref']]= $value;
573+
}
574+
}
582575

583-
$res = Database::query($sql);
584-
if (Database::num_rows($res) > 0) {
585-
if (!empty($thematic_advance_id)) {
586-
$data = Database::fetch_array($res);
587-
} else {
588-
// group all data group by thematic id
589-
$tmp = array();
590-
while ($row = Database::fetch_array($res, 'ASSOC')) {
591-
592-
$tmp[] = $row['thematic_id'];
593-
if (in_array($row['thematic_id'], $tmp)) {
594-
if ($force_session_id) {
595-
if (in_array($row['id'], array_keys($elements))) {
596-
$row['session_id'] = $elements[$row['id']]['id_session'];
597-
$data[$row['thematic_id']][$row['id']] = $row;
598-
}
599-
} else {
600-
$data[$row['thematic_id']][$row['id']] = $row;
601-
}
602-
}
576+
$res = Database::query($sql);
577+
if (Database::num_rows($res) > 0) {
578+
if (!empty($thematic_advance_id)) {
579+
$data = Database::fetch_array($res);
580+
} else {
581+
// group all data group by thematic id
582+
$tmp = array();
583+
while ($row = Database::fetch_array($res, 'ASSOC')) {
584+
$tmp[] = $row['thematic_id'];
585+
if (in_array($row['thematic_id'], $tmp)) {
586+
if ($force_session_id) {
587+
if (in_array($row['id'], array_keys($elements))) {
588+
$row['session_id'] = $elements[$row['id']]['id_session'];
589+
$data[$row['thematic_id']][$row['id']] = $row;
590+
}
591+
} else {
592+
$data[$row['thematic_id']][$row['id']] = $row;
593+
}
594+
}
603595

604-
}
605-
}
606-
}
607-
return $data;
596+
}
597+
}
598+
}
599+
return $data;
608600
}
609601

610602
/**

0 commit comments

Comments
 (0)