diff --git a/main/document/slideshow.php b/main/document/slideshow.php index a05bc82261..3a3b8996f2 100755 --- a/main/document/slideshow.php +++ b/main/document/slideshow.php @@ -15,15 +15,15 @@ $pathurl = urlencode($path); $slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null; if (empty($slide_id)) { - $edit_slide_id = 1; + $edit_slide_id = 1; } else { - $edit_slide_id = $slide_id; + $edit_slide_id = $slide_id; } if ($path != '/') { - $folder = $path.'/'; + $folder = $path.'/'; } else { - $folder = '/'; + $folder = '/'; } $sys_course_path = api_get_path(SYS_COURSE_PATH); @@ -41,19 +41,19 @@ Display :: display_header($originaltoolname, 'Doc'); // Loading the slides from the session if (isset($_SESSION['image_files_only'])) { - $image_files_only = $_SESSION['image_files_only']; + $image_files_only = $_SESSION['image_files_only']; } // Calculating the current slide, next slide, previous slide and the number of slides $slide = null; if ($slide_id != 'all') { - $slide = $slide_id ? $slide_id : 0; - $previous_slide = $slide - 1; - $next_slide = $slide + 1; + $slide = $slide_id ? $slide_id : 0; + $previous_slide = $slide - 1; + $next_slide = $slide + 1; } $total_slides = count($image_files_only); ?> - + var delta_height = height - initial_height * resize_factor_width; + + if (delta_width > delta_height) { + width = Math.ceil(initial_width * resize_factor_height); + height= Math.ceil(initial_height * resize_factor_height); + } + else if(delta_width < delta_height) { + width = Math.ceil(initial_width * resize_factor_width); + height = Math.ceil(initial_height * resize_factor_width); + } + else { + width = Math.ceil(width); + height = Math.ceil(height); + } + + document.getElementById('image').style.height = height +"px"; + document.getElementById('image').style.width = width +"px"; + document.getElementById('td_image').style.background='none'; + document.getElementById('image').style.visibility='visible'; + }; + + if (initial_height>height || initial_width>width) { + document.getElementById('image').style.visibility='hidden'; + document.getElementById('td_image').style.background='url() center no-repeat'; + document.getElementById('image').onload = resizeImage; + window.onresize = resizeImage; + } + + "; - } + } else { + echo "".$image_files_only[$slide].""; + } - echo ''; + echo ''; echo '
'; echo Display::tag('h3', $row['title']); echo '

'.$row['comment'].'

'; echo '
'; echo ''; - if (api_is_allowed_to_edit(null, true)) { + if (api_is_allowed_to_edit(null, true)) { echo ''; - } - - } else { - Display::display_warning_message(get_lang('FileNotFound')); - } + } + } else { + Display::display_warning_message(get_lang('FileNotFound')); + } } else { if ($slide_id != 'all') { Display::display_warning_message(get_lang('NoDataAvailable')); diff --git a/main/gradebook/lib/be/surveylink.class.php b/main/gradebook/lib/be/surveylink.class.php index f78f94ef8b..7b17660b65 100755 --- a/main/gradebook/lib/be/surveylink.class.php +++ b/main/gradebook/lib/be/surveylink.class.php @@ -8,300 +8,300 @@ */ class SurveyLink extends AbstractLink { - private $survey_table = null; - private $survey_data = []; - - /** - * Constructor - */ - public function __construct() - { - parent::__construct(); - $this->set_type(LINK_SURVEY); - } - - /** - * @return string - */ - public function get_name() - { - $this->get_survey_data(); - - return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); - } - - public function get_description() - { - $this->get_survey_data(); - return $this->survey_data['subtitle']; - } - - public function get_type_name() - { - return get_lang('Survey'); - } - - public function is_allowed_to_change_name() - { - return false; - } - - public function needs_name_and_description() - { - return false; - } - - public function needs_max() - { - return false; - } - - public function needs_results() - { - return false; - } - - /** - * Generates an array of all surveys available. - * @return array 2-dimensional array - every element contains 2 subelements (id, name) - */ - public function get_all_links() - { - if (empty($this->course_code)) { - die('Error in get_all_links() : course code not set'); - } - $tbl_survey = $this->get_survey_table(); - $session_id = api_get_session_id(); - $course_id = api_get_course_int_id(); - $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' - WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id); - $result = Database::query($sql); - while ($data = Database::fetch_array($result)) { - $links[] = array( - $data['survey_id'], - api_trunc_str( - $data['code'] . ': ' . self::html_to_text($data['title']), - 80 - ) - ); - } - - return isset($links) ? $links : null; - } - - /** - * 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; - } - - /** - * Has anyone done this survey yet? + private $survey_table = null; + private $survey_data = []; + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + $this->set_type(LINK_SURVEY); + } + + /** + * @return string + */ + public function get_name() + { + $this->get_survey_data(); + + return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); + } + + public function get_description() + { + $this->get_survey_data(); + return $this->survey_data['subtitle']; + } + + public function get_type_name() + { + return get_lang('Survey'); + } + + public function is_allowed_to_change_name() + { + return false; + } + + public function needs_name_and_description() + { + return false; + } + + public function needs_max() + { + return false; + } + + public function needs_results() + { + return false; + } + + /** + * Generates an array of all surveys available. + * @return array 2-dimensional array - every element contains 2 subelements (id, name) + */ + public function get_all_links() + { + if (empty($this->course_code)) { + die('Error in get_all_links() : course code not set'); + } + $tbl_survey = $this->get_survey_table(); + $session_id = api_get_session_id(); + $course_id = api_get_course_int_id(); + $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' + WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id); + $result = Database::query($sql); + while ($data = Database::fetch_array($result)) { + $links[] = array( + $data['survey_id'], + api_trunc_str( + $data['code'] . ': ' . self::html_to_text($data['title']), + 80 + ) + ); + } + + return isset($links) ? $links : null; + } + + /** + * 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; + } + + /** + * Has anyone done this survey yet? * Implementation of the AbstractLink class, mainly used dynamically in gradebook/lib/fe - */ - public function has_results() - { - $ref_id = intval($this->get_ref_id()); - $session_id = api_get_session_id(); - $tbl_survey = Database::get_course_table(TABLE_SURVEY); - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); - $sql = "SELECT - COUNT(i.answered) - FROM $tbl_survey AS s - JOIN $tbl_survey_invitation AS i ON s.code = i.survey_code - WHERE - s.c_id = {$this->course_id} AND - i.c_id = {$this->course_id} AND - s.survey_id = $ref_id AND - i.session_id = $session_id"; - - $sql_result = Database::query($sql); - $data = Database::fetch_array($sql_result); - - return ($data[0] != 0); - } - - /** - * Calculate score for a student (to show in the gradebook) + */ + public function has_results() + { + $ref_id = intval($this->get_ref_id()); + $session_id = api_get_session_id(); + $tbl_survey = Database::get_course_table(TABLE_SURVEY); + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); + $sql = "SELECT + COUNT(i.answered) + FROM $tbl_survey AS s + JOIN $tbl_survey_invitation AS i ON s.code = i.survey_code + WHERE + s.c_id = {$this->course_id} AND + i.c_id = {$this->course_id} AND + s.survey_id = $ref_id AND + i.session_id = $session_id"; + + $sql_result = Database::query($sql); + $data = Database::fetch_array($sql_result); + + return ($data[0] != 0); + } + + /** + * Calculate score for a student (to show in the gradebook) * @param int $stud_id * @param string $type Type of result we want (best|average|ranking) - * @return array|null - */ - public function calc_score($stud_id = null, $type = null) - { - // Note: Max score is assumed to be always 1 for surveys, - // only student's participation is to be taken into account. - $max_score = 1; - - $ref_id = intval($this->get_ref_id()); - $session_id = api_get_session_id(); - $tbl_survey = Database::get_course_table(TABLE_SURVEY); - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); - - $get_individual_score = !is_null($stud_id); - - $sql = "SELECT i.answered - FROM $tbl_survey AS s - JOIN $tbl_survey_invitation AS i - ON s.code = i.survey_code - WHERE - s.c_id = {$this->course_id} AND - i.c_id = {$this->course_id} AND - s.survey_id = $ref_id AND - i.session_id = $session_id - "; - - if ($get_individual_score) { - $sql .= ' AND i.user = '.intval($stud_id); - } - - $sql_result = Database::query($sql); - - if ($get_individual_score) { - // for 1 student - if ($data = Database::fetch_array($sql_result)) { - return array($data['answered'] ? $max_score : 0, $max_score); - } - return array(0, $max_score); - } else { - // for all the students -> get average - $rescount = 0; - $sum = 0; - $bestResult = 0; - while ($data = Database::fetch_array($sql_result)) { - $sum += $data['answered'] ? $max_score : 0; - $rescount++; - if ($data['answered'] > $bestResult) { - $bestResult = $data['answered']; - } - } - $sum = $sum / $max_score; - - if ($rescount == 0) { - return null; - } - - switch ($type) { - case 'best': - return array($bestResult, $rescount); - break; - case 'average': - return array($sum, $rescount); - break; - case 'ranking': - return null; - break; - default: - return array($sum, $rescount); - break; - } - } - } - - /** - * Lazy load function to get the database table of the surveys - */ - private function get_survey_table() - { - $this->survey_table = Database::get_course_table(TABLE_SURVEY); - return $this->survey_table; - } - - /** - * Check if this still links to a survey - */ - public function is_valid_link() - { - $session_id = api_get_session_id(); - $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' - WHERE - c_id = '.$this->course_id.' AND - survey_id = '.intval($this->get_ref_id()).' AND - session_id = '.intval($session_id); - $result = Database::query($sql); - $number = Database::fetch_row($result); - return ($number[0] != 0); - } - - public function get_test_id() - { - return 'DEBUG:ID'; - } - - public function get_link() - { - if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. - $tbl_name = $this->get_survey_table(); - $session_id = api_get_session_id(); - if ($tbl_name != '') { - $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' - WHERE - c_id = '.$this->course_id.' AND - survey_id = '.intval($this->get_ref_id()).' AND - session_id = '.intval($session_id).' '; - $result = Database::query($sql); - $row = Database::fetch_array($result, 'ASSOC'); - $survey_id = $row['survey_id']; - return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id; - } - } - return null; - } - - private function get_survey_data() - { - $tbl_name = $this->get_survey_table(); - $session_id = api_get_session_id(); - if ($tbl_name == '') { - return false; - } elseif (!isset($this->survey_data)) { - $sql = 'SELECT * FROM '.$tbl_name.' - WHERE - c_id = '.$this->course_id.' AND - survey_id = '.intval($this->get_ref_id()).' AND - session_id='.intval($session_id); - $query = Database::query($sql); - $this->survey_data = Database::fetch_array($query); - } - return $this->survey_data; - } - - public function get_icon_name() - { - return 'survey'; - } - - private static function html_to_text($string) - { - return strip_tags($string); - //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('

', '

', '
', '
', '
'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); - } + * @return array|null + */ + public function calc_score($stud_id = null, $type = null) + { + // Note: Max score is assumed to be always 1 for surveys, + // only student's participation is to be taken into account. + $max_score = 1; + + $ref_id = intval($this->get_ref_id()); + $session_id = api_get_session_id(); + $tbl_survey = Database::get_course_table(TABLE_SURVEY); + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); + + $get_individual_score = !is_null($stud_id); + + $sql = "SELECT i.answered + FROM $tbl_survey AS s + JOIN $tbl_survey_invitation AS i + ON s.code = i.survey_code + WHERE + s.c_id = {$this->course_id} AND + i.c_id = {$this->course_id} AND + s.survey_id = $ref_id AND + i.session_id = $session_id + "; + + if ($get_individual_score) { + $sql .= ' AND i.user = '.intval($stud_id); + } + + $sql_result = Database::query($sql); + + if ($get_individual_score) { + // for 1 student + if ($data = Database::fetch_array($sql_result)) { + return array($data['answered'] ? $max_score : 0, $max_score); + } + return array(0, $max_score); + } else { + // for all the students -> get average + $rescount = 0; + $sum = 0; + $bestResult = 0; + while ($data = Database::fetch_array($sql_result)) { + $sum += $data['answered'] ? $max_score : 0; + $rescount++; + if ($data['answered'] > $bestResult) { + $bestResult = $data['answered']; + } + } + $sum = $sum / $max_score; + + if ($rescount == 0) { + return null; + } + + switch ($type) { + case 'best': + return array($bestResult, $rescount); + break; + case 'average': + return array($sum, $rescount); + break; + case 'ranking': + return null; + break; + default: + return array($sum, $rescount); + break; + } + } + } + + /** + * Lazy load function to get the database table of the surveys + */ + private function get_survey_table() + { + $this->survey_table = Database::get_course_table(TABLE_SURVEY); + return $this->survey_table; + } + + /** + * Check if this still links to a survey + */ + public function is_valid_link() + { + $session_id = api_get_session_id(); + $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' + WHERE + c_id = '.$this->course_id.' AND + survey_id = '.intval($this->get_ref_id()).' AND + session_id = '.intval($session_id); + $result = Database::query($sql); + $number = Database::fetch_row($result); + return ($number[0] != 0); + } + + public function get_test_id() + { + return 'DEBUG:ID'; + } + + public function get_link() + { + if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. + $tbl_name = $this->get_survey_table(); + $session_id = api_get_session_id(); + if ($tbl_name != '') { + $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' + WHERE + c_id = '.$this->course_id.' AND + survey_id = '.intval($this->get_ref_id()).' AND + session_id = '.intval($session_id).' '; + $result = Database::query($sql); + $row = Database::fetch_array($result, 'ASSOC'); + $survey_id = $row['survey_id']; + return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id; + } + } + return null; + } + + private function get_survey_data() + { + $tbl_name = $this->get_survey_table(); + $session_id = api_get_session_id(); + if ($tbl_name == '') { + return false; + } elseif (!isset($this->survey_data)) { + $sql = 'SELECT * FROM '.$tbl_name.' + WHERE + c_id = '.$this->course_id.' AND + survey_id = '.intval($this->get_ref_id()).' AND + session_id='.intval($session_id); + $query = Database::query($sql); + $this->survey_data = Database::fetch_array($query); + } + return $this->survey_data; + } + + public function get_icon_name() + { + return 'survey'; + } + + private static function html_to_text($string) + { + return strip_tags($string); + //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('

', '

', '
', '
', '
'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); + } } diff --git a/main/inc/lib/exercise_show_functions.lib.php b/main/inc/lib/exercise_show_functions.lib.php index c5be3260e9..647571545b 100755 --- a/main/inc/lib/exercise_show_functions.lib.php +++ b/main/inc/lib/exercise_show_functions.lib.php @@ -17,25 +17,26 @@ */ class ExerciseShowFunctions { - /** - * Shows the answer to a fill-in-the-blanks question, as HTML + /** + * Shows the answer to a fill-in-the-blanks question, as HTML * @param int $feedbackType - * @param string $answer - * @param int $id Exercise ID - * @param int $questionId Question ID + * @param string $answer + * @param int $id Exercise ID + * @param int $questionId Question ID * @param int $resultsDisabled * @param string $originalStudentAnswer + * @param bool $showTotalScoreAndUserChoices * - * @return void - */ - public static function display_fill_in_blanks_answer( - $feedbackType, - $answer, - $id, - $questionId, - $resultsDisabled, - $originalStudentAnswer = '', - $showTotalScoreAndUserChoices + * @return void + */ + public static function display_fill_in_blanks_answer( + $feedbackType, + $answer, + $id, + $questionId, + $resultsDisabled, + $originalStudentAnswer = '', + $showTotalScoreAndUserChoices ) { $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); if (strpos($originalStudentAnswer, 'font color') !== false) { @@ -64,7 +65,7 @@ class ExerciseShowFunctions '; } } - } + } /** * @param $feedback_type @@ -146,7 +147,7 @@ class ExerciseShowFunctions * @param null $nano * @param int $results_disabled */ - public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $fileUrl = null, $results_disabled = 0) + public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $fileUrl = null, $results_disabled = 0) { if (isset($fileUrl)) { echo ' @@ -184,8 +185,8 @@ class ExerciseShowFunctions } } - /** - * Displays the answer to a hotspot question + /** + * Displays the answer to a hotspot question * @param int $feedback_type * @param int $answerId * @param string $answer @@ -194,7 +195,7 @@ class ExerciseShowFunctions * @param int $resultsDisabled * @param int $orderColor */ - public static function display_hotspot_answer( + public static function display_hotspot_answer( $feedback_type, $answerId, $answer, @@ -217,7 +218,7 @@ class ExerciseShowFunctions } } - $hotspot_colors = array( + $hotspot_colors = array( "", // $i starts from 1 on next loop (ugly fix) "#4271B5", "#FE8E16", @@ -234,37 +235,37 @@ class ExerciseShowFunctions "#F7BDE2" ); - ?> - - + ?> +
+ - - - - + + - - - - - + + + + + + - - - + + - - - - + + + - - - - - - + + + + + + + @@ -422,7 +423,7 @@ class ExerciseShowFunctions @@ -448,8 +449,8 @@ class ExerciseShowFunctions } if ($hide_expected_answer) { - $color = ''; - } + $color = ''; + } echo ''.nl2br($answerComment).''; } @@ -510,7 +511,7 @@ class ExerciseShowFunctions
+ - - + + - - + + '.nl2br($answerComment).''; } - ?> -  
 
- - + $icon .= $studentChoice?'_on':'_off'; + $icon .= '.gif'; + $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; + $iconAnswer .= $answerCorrect?'_on':'_off'; + $iconAnswer .= '.gif'; + + ?> +
+ + - - - - + + + + '.nl2br($answerComment).''; - } else { + //echo ''.nl2br($answerComment).''; + } else { $color = 'black'; //echo ''.nl2br($answerComment).''; - } - if ($hide_expected_answer) { - $color = ''; - } + } + if ($hide_expected_answer) { + $color = ''; + } echo ''.nl2br($answerComment).''; - } - ?> -  
 
- +
options[$studentChoice])) { echo $question->options[$studentChoice]; @@ -521,7 +522,7 @@ class ExerciseShowFunctions options[$answerCorrect])) { echo $question->options[$answerCorrect]; @@ -550,10 +551,10 @@ class ExerciseShowFunctions if ($studentChoice == $answerCorrect) { $color = "green"; } - //echo ''.nl2br($answerComment).''; + //echo ''.nl2br($answerComment).''; if ($hide_expected_answer) { $color = ''; - } + } echo ''.nl2br($answerComment).''; } ?> @@ -572,12 +573,11 @@ class ExerciseShowFunctions public static function displayAnnotationAnswer( $feedback_type, - $exe_id, - $questionId, - $questionScore = null, - $results_disabled = 0 - ) - { + $exe_id, + $questionId, + $questionScore = null, + $results_disabled = 0 + ) { $comments = Event::get_comments($exe_id, $questionId); if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { diff --git a/main/inc/lib/thematic.lib.php b/main/inc/lib/thematic.lib.php index c9c2e41fd9..18d7e567bd 100755 --- a/main/inc/lib/thematic.lib.php +++ b/main/inc/lib/thematic.lib.php @@ -61,6 +61,7 @@ class Thematic * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) + * @return array * @see SortableTable#get_table_data($from) */ public function get_thematic_data($from, $number_of_items, $column, $direction) @@ -177,8 +178,8 @@ class Thematic /** * Move a thematic * - * @param string $direction (up, down) - * @param int $thematic_id + * @param string $direction (up, down) + * @param int $thematic_id */ public function move_thematic($direction, $thematic_id) { @@ -241,11 +242,11 @@ class Thematic /** * get thematic list - * @param int Thematic id (optional), get list by id + * @param int Thematic id (optional), get list by id * @param integer $thematic_id * @param string $course_code * @param integer $session_id - * @return array Thematic data + * @return array Thematic data */ public static function get_thematic_list( $thematic_id = null, @@ -365,8 +366,8 @@ class Thematic /** * Delete logically (set active field to 0) a thematic - * @param int|array One or many thematic ids - * @return int Affected rows + * @param int|array One or many thematic ids + * @return int Affected rows */ public function thematic_destroy($thematic_id) { @@ -394,8 +395,8 @@ class Thematic ); } } - } else { - $thematic_id = intval($thematic_id); + } else { + $thematic_id = intval($thematic_id); $sql = "UPDATE $tbl_thematic SET active = 0 WHERE c_id = $course_id AND id = $thematic_id"; $result = Database::query($sql); @@ -432,8 +433,8 @@ class Thematic $new_thematic_id = $thematic_copy->thematic_save(); if (!empty($new_thematic_id)) { $thematic_advanced = self::get_thematic_advance_by_thematic_id($thematic_id); - if(!empty($thematic_advanced)) { - foreach($thematic_advanced as $item) { + if (!empty($thematic_advanced)) { + foreach ($thematic_advanced as $item) { $thematic = new Thematic(); $thematic->set_thematic_advance_attributes( 0, @@ -481,13 +482,13 @@ class Thematic return $obj->total_number_of_items; } - /** * Get the thematic advances to display on the current page (fill the sortable-table) * @param int offset of first user to recover * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) + * @return array * @see SortableTable#get_table_data($from) */ public static function get_thematic_advance_data($from, $number_of_items, $column, $direction) @@ -501,11 +502,8 @@ class Thematic $direction = 'ASC'; } $data = array(); - $course_id = api_get_course_int_id(); - if (api_is_allowed_to_edit(null, true)) { - $sql = "SELECT id AS col0, start_date AS col1, duration AS col2, content AS col3 FROM $tbl_thematic_advance WHERE c_id = $course_id AND thematic_id = $thematic_id @@ -592,7 +590,6 @@ class Thematic foreach ($data as $thematic_id => $thematic_advance_data) { foreach ($thematic_advance_data as $key => $thematic_advance) { - $session_star = ''; if (api_is_allowed_to_edit(null, true)) { if ($thematic_advance['session_id'] !=0) { @@ -654,11 +651,6 @@ class Thematic } } $final_return[$thematic_id] = $return; - /* - if ($no_data) { - $return .= '
'.get_lang('StillDoNotHaveAThematicPlan').'
'; - } - */ } return $final_return; @@ -671,7 +663,10 @@ class Thematic * @param bool $force_session_id Force to have a session id * @return array $data */ - public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false + public function get_thematic_advance_list( + $thematic_advance_id = null, + $course_code = null, + $force_session_id = false ) { $course_info = api_get_course_info($course_code); $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); @@ -734,7 +729,6 @@ class Thematic public function thematic_advance_save() { $_course = api_get_course_info(); - // definition database table $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); @@ -846,7 +840,6 @@ class Thematic // definition database table $tbl_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); $tbl_thematic = Database::get_course_table(TABLE_THEMATIC); - $course_id = api_get_course_int_id(); $data = array(); @@ -967,7 +960,6 @@ class Thematic if (Database::num_rows($rs) > 0) { $row_thematic_plan = Database::fetch_array($rs); $thematic_plan_id = $row_thematic_plan['id']; - $update = false; if (in_array($thematic_plan_id, $elements_to_show)) { $update = true; @@ -1128,7 +1120,11 @@ class Thematic { $_course = api_get_course_info(); $thematic_data = $this->get_thematic_list(null, api_get_course_id()); - $thematic_advance_data = $this->get_thematic_advance_list(null, api_get_course_id(), true); + $thematic_advance_data = $this->get_thematic_advance_list( + null, + api_get_course_id(), + true + ); $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); $affected_rows = 0; diff --git a/main/lp/aicc.class.php b/main/lp/aicc.class.php index 354abbfeac..43e88ce220 100755 --- a/main/lp/aicc.class.php +++ b/main/lp/aicc.class.php @@ -5,8 +5,8 @@ * Class aicc * Defines the AICC class, which is meant to contain the aicc items (nuclear elements) * @package chamilo.learnpath - * @author Yannick Warnier - * @license GNU/GPL + * @author Yannick Warnier + * @license GNU/GPL * @package chamilo.learnpath */ class aicc extends learnpath @@ -58,7 +58,9 @@ class aicc extends learnpath */ public function open($id) { - if ($this->debug > 0) { error_log('In aicc::open()', 0); } + if ($this->debug > 0) { + error_log('In aicc::open()', 0); + } // Redefine parent method. } @@ -132,7 +134,7 @@ class aicc extends learnpath //echo '
des:'.print_r($des_params, true).'
'; if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$des_file.' has been parsed', 0); } // Distribute des params into the aicc object. - foreach ($des_params as $des){ + foreach ($des_params as $des) { // One AU in AICC is equivalent to one SCO in SCORM (scormItem class). $oDes = new aiccResource('config', $des); $this->deslist[$oDes->identifier] = $oDes; @@ -215,8 +217,8 @@ class aicc extends learnpath /** * Import the aicc object (as a result from the parse_config_files function) into the database structure - * @param string $course_code - * @return bool Returns -1 on error + * @param string $course_code + * @return bool Returns -1 on error */ public function import_aicc($course_code) { @@ -376,9 +378,7 @@ class aicc extends learnpath } */ $zipFile = new PclZip($zip_file_path); - // Check the zip content (real size and file extension). - $zipContentArray = $zipFile->listContent(); $package_type = ''; // The type of the package. Should be 'aicc' after the next few lines. @@ -562,12 +562,13 @@ class aicc extends learnpath } else { return ''; } + return $course_sys_dir.$new_dir.$config_dir; } /** * Sets the proximity setting in the database - * @param string $proxy Proximity setting + * @param string $proxy Proximity setting */ function set_proximity($proxy = '') { @@ -586,7 +587,7 @@ class aicc extends learnpath /** * Sets the theme setting in the database - * @param string Theme setting + * @param string Theme setting */ function set_theme($theme = '') { @@ -605,7 +606,7 @@ class aicc extends learnpath /** * Sets the image LP in the database - * @param string $preview_image Theme setting + * @param string $preview_image Theme setting */ function set_preview_image($preview_image = '') { @@ -624,7 +625,7 @@ class aicc extends learnpath /** * Sets the Author LP in the database - * @param string $author + * @param string $author */ function set_author($author = '') { @@ -643,7 +644,7 @@ class aicc extends learnpath /** * Sets the content maker setting in the database - * @param string $maker + * @param string $maker */ function set_maker($maker = '') { @@ -662,7 +663,7 @@ class aicc extends learnpath /** * Exports the current AICC object's files as a zip. Excerpts taken from learnpath_functions.inc.php::exportpath() - * @param integer Learnpath ID (optional, taken from object context if not defined) + * @param integer Learnpath ID (optional, taken from object context if not defined) */ function export_zip($lp_id = null) { @@ -758,7 +759,8 @@ class aicc extends learnpath * Gets the default organisation's title * @return string The organization's title */ - function get_title(){ + function get_title() + { if ($this->debug > 0) { error_log('In aicc::get_title() method', 0); } $title = ''; if (isset($this->config['organizations']['default'])) { @@ -778,7 +780,8 @@ class aicc extends learnpath * updating the existing table... This will prove very useful in case initial data * from config files were not imported well enough. */ - function reimport_aicc() { + function reimport_aicc() + { if ($this->debug > 0) { error_log('In aicc::reimport_aicc() method', 0); } //query current items list //get the identifiers @@ -794,7 +797,8 @@ class aicc extends learnpath * @param string File path * @return array Structured array */ - function parse_ini_file_quotes_safe($f) { + function parse_ini_file_quotes_safe($f) + { $null = ''; $r = $null; $sec = $null; @@ -845,7 +849,8 @@ class aicc extends learnpath * @param array List of names of sections that should be considered as containing only hard string data (no variables), provided in lower case * @return array Structured array */ - function parse_ini_string_quotes_safe($s, $pure_strings = array()) { + function parse_ini_string_quotes_safe($s, $pure_strings = array()) + { $null = ''; $r = $null; $sec = $null; @@ -908,7 +913,8 @@ class aicc extends learnpath * @param boolean Might one field name happen more than once on the same line? (then split by comma in the values) * @return array Simple structured array */ - function parse_csv_file($f, $delim = ',', $enclosure = '"', $multiples = false) { + function parse_csv_file($f, $delim = ',', $enclosure = '"', $multiples = false) + { $data = @file_get_contents($f); $data = api_convert_encoding($data, api_get_system_encoding(), $this->config_encoding); $enclosed = false; @@ -982,6 +988,7 @@ class aicc extends learnpath } } } + return $ret_ret_array; } } diff --git a/plugin/dashboard/block_teacher/block_teacher.class.php b/plugin/dashboard/block_teacher/block_teacher.class.php index 4db0673d45..82b3370e56 100755 --- a/plugin/dashboard/block_teacher/block_teacher.class.php +++ b/plugin/dashboard/block_teacher/block_teacher.class.php @@ -1,4 +1,6 @@ user_id = $user_id; - $this->path = 'block_teacher'; - if ($this->is_block_visible_for_user($user_id)) { - $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); - } + $this->user_id = $user_id; + $this->path = 'block_teacher'; + if ($this->is_block_visible_for_user($user_id)) { + $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); + } } /** - * This method check if a user is allowed to see the block inside dashboard interface - * @param int User id - * @return bool Is block visible for user - */ + * This method check if a user is allowed to see the block inside dashboard interface + * @param int User id + * @return bool Is block visible for user + */ public function is_block_visible_for_user($user_id) { - $user_info = api_get_user_info($user_id); - $user_status = $user_info['status']; - $is_block_visible_for_user = false; - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { - $is_block_visible_for_user = true; - } - return $is_block_visible_for_user; + $user_info = api_get_user_info($user_id); + $user_status = $user_info['status']; + $is_block_visible_for_user = false; + if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { + $is_block_visible_for_user = true; + } + return $is_block_visible_for_user; } /** - * This method return content html containing information about teachers and its position for showing it inside dashboard interface - * it's important to use the name 'get_block' for beeing used from dashboard controller + * This method return content html containing information about + * teachers and its position for showing it inside dashboard interface + * it's important to use the name 'get_block' for beeing used from + * dashboard controller * @return array column and content html */ public function get_block() { + global $charset; + $column = 1; + $data = array(); + $teacher_content_html = $this->get_teachers_content_html_for_drh(); - global $charset; - $column = 1; - $data = array(); - $teacher_content_html = $this->get_teachers_content_html_for_drh(); - - $html = ' + $html = '
'.get_lang('TeachersInformationsList').' @@ -77,133 +75,131 @@ class BlockTeacher extends Block '.$teacher_content_html.'
- '; - - $data['column'] = $column; - $data['content_html'] = $html; + '; - return $data; + $data['column'] = $column; + $data['content_html'] = $html; + return $data; } /** - * This method return a content html, it's used inside get_block method for showing it inside dashboard interface - * @return string content html - */ + * This method return a content html, it's used inside get_block method + * for showing it inside dashboard interface + * @return string content html + */ public function get_teachers_content_html_for_platform_admin() { - $teachers = $this->teachers; - //$content = '
'; - $content = '

'.get_lang('YourTeachers').'

'; + $teachers = $this->teachers; + $content = '

'.get_lang('YourTeachers').'

'; $teachers_table = null; - if (count($teachers) > 0) { - $teachers_table .= ''; - $teachers_table .= ' - - - - - - '; - - $i = 1; - foreach ($teachers as $teacher) { - - $teacher_id = $teacher['user_id']; - $firstname = $teacher['firstname']; - $lastname = $teacher['lastname']; - $username = $teacher['username']; - - $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($teacher_id)); - $last_connection = Tracking::get_last_connection_date($teacher_id); - - if ($i%2 == 0) $class_tr = 'row_odd'; - else $class_tr = 'row_even'; - - $teachers_table .= ' - - - - - - '; - $i++; - } - $teachers_table .= '
'.get_lang('User').''.get_lang('TimeSpentOnThePlatform').''.get_lang('LastConnexion').'
'.api_get_person_name($firstname,$lastname).' ('.$username.')'.$time_on_platform.''.$last_connection.'
'; - } else { - $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); - } - - $content .= $teachers_table; - - if (count($teachers) > 0) { - $content .= ''; - } - - //$content .= '
'; - - return $content; - } - - public function get_teachers_content_html_for_drh() + if (count($teachers) > 0) { + $teachers_table .= ''; + $teachers_table .= ' + + + + + + '; + $i = 1; + foreach ($teachers as $teacher) { + $teacher_id = $teacher['user_id']; + $firstname = $teacher['firstname']; + $lastname = $teacher['lastname']; + $username = $teacher['username']; + + $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($teacher_id)); + $last_connection = Tracking::get_last_connection_date($teacher_id); + + if ($i % 2 == 0) { + $class_tr = 'row_odd'; + } else { + $class_tr = 'row_even'; + } + $teachers_table .= ' + + + + + + '; + $i++; + } + $teachers_table .= '
'.get_lang('User').''.get_lang('TimeSpentOnThePlatform').''.get_lang('LastConnexion').'
'.api_get_person_name($firstname, $lastname).' ('.$username.')'.$time_on_platform.''.$last_connection.'
'; + } else { + $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); + } + + $content .= $teachers_table; + + if (count($teachers) > 0) { + $content .= ''; + } + + //$content .= ''; + + return $content; + } + + public function get_teachers_content_html_for_drh() { - $teachers = $this->teachers; - //$content = '
'; - $content = '

'.get_lang('YourTeachers').'

'; + $teachers = $this->teachers; + $content = '

'.get_lang('YourTeachers').'

'; $teachers_table = null; - if (count($teachers) > 0) { - $a_last_week = get_last_week(); - $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); - - $teachers_table .= ''; - $teachers_table .= ' - - - - - '; - - $i = 1; - foreach ($teachers as $teacher) { - - $teacher_id = $teacher['user_id']; - $firstname = $teacher['firstname']; - $lastname = $teacher['lastname']; - $username = $teacher['username']; - $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($teacher_id,true)); - - if ($i%2 == 0) $class_tr = 'row_odd'; - else $class_tr = 'row_even'; - $teachers_table .= ' - - - '; - - $i++; - } - $teachers_table .= '
'.get_lang('User').''.get_lang('TimeSpentLastWeek').'
'.$last_week.'
'.api_get_person_name($firstname,$lastname).' ('.$username.')'.$time_on_platform.'
'; - } else { - $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); - } - - $content .= $teachers_table; - - if (count($teachers) > 0) { - $content .= ''; - } - //$content .= '
'; - - return $content; - } + if (count($teachers) > 0) { + $a_last_week = get_last_week(); + $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); + + $teachers_table .= ''; + $teachers_table .= ' + + + + + '; + + $i = 1; + foreach ($teachers as $teacher) { + $teacher_id = $teacher['user_id']; + $firstname = $teacher['firstname']; + $lastname = $teacher['lastname']; + $username = $teacher['username']; + $time_on_platform = api_time_to_hms( + Tracking::get_time_spent_on_the_platform($teacher_id, true) + ); + + if ($i % 2 == 0) { + $class_tr = 'row_odd'; + } else { + $class_tr = 'row_even'; + } + $teachers_table .= ' + + + '; + + $i++; + } + $teachers_table .= '
'.get_lang('User').''.get_lang('TimeSpentLastWeek').'
'.$last_week.'
'.api_get_person_name($firstname, $lastname).' ('.$username.')'.$time_on_platform.'
'; + } else { + $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); + } + $content .= $teachers_table; + if (count($teachers) > 0) { + $content .= ''; + } + return $content; + } /** - * Get number of teachers - * @return int - */ - function get_number_of_teachers() + * Get number of teachers + * @return int + */ + public function get_number_of_teachers() { - return count($this->teachers); - } + return count($this->teachers); + } }