diff --git a/main/exercise/exercise_result.class.php b/main/exercise/exercise_result.class.php index 118a8b4ea7..43acde5f4d 100755 --- a/main/exercise/exercise_result.class.php +++ b/main/exercise/exercise_result.class.php @@ -433,37 +433,44 @@ class ExerciseResult if ($with_column_user) { if (api_is_western_name_order()) { - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); $column++; } else { - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); $column++; } if ($officialCodeInList === 'true') { - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('OfficialCode')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('OfficialCode')); $column++; } - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email')); $column++; } - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Groups')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Groups')); $column++; if ($export_user_fields) { //show user fields section with a big th colspan that spans over all fields - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); + $extra_user_fields = UserManager::get_extra_fields( + 0, + 1000, + 5, + 'ASC', + false, + 1 + ); //show the fields names for user fields foreach ($extra_user_fields as $field) { - $worksheet->SetCellValueByColumnAndRow( - $line, + $worksheet->setCellValueByColumnAndRow( $column, + $line, api_html_entity_decode( strip_tags($field[3]), ENT_QUOTES, @@ -474,23 +481,23 @@ class ExerciseResult } } - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')'); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ToolLearnpath')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ToolLearnpath')); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('UserIsCurrentlySubscribed')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('UserIsCurrentlySubscribed')); $line++; foreach ($this->results as $row) { @@ -498,55 +505,130 @@ class ExerciseResult if ($with_column_user) { if (api_is_western_name_order()) { - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['first_name']), + ENT_QUOTES, + $charset + ) + ); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['last_name']), + ENT_QUOTES, + $charset + ) + ); $column++; } else { - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['last_name']), + ENT_QUOTES, + $charset + ) + ); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['first_name']), + ENT_QUOTES, + $charset + ) + ); $column++; } if ($officialCodeInList === 'true') { - $worksheet->SetCellValueByColumnAndRow($line, $column,api_html_entity_decode(strip_tags($row['official_code']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['official_code']), + ENT_QUOTES, + $charset + ) + ); $column++; } - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['email']), + ENT_QUOTES, + $charset + ) + ); $column++; } - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags( + implode( + ", ", + GroupManager:: get_user_group_name($row['user_id']) + ) + ), + ENT_QUOTES, + $charset + ) + ); $column++; if ($export_user_fields) { //show user fields data, if any, for this user - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); - foreach($user_fields_values as $value) { - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); + $user_fields_values = UserManager::get_extra_user_data( + $row['user_id'], + false, + false, + false, + true + ); + foreach ($user_fields_values as $value) { + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($value), + ENT_QUOTES, + $charset + ) + ); $column++; } } - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['duration']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['result']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['max']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['status']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['lp_name']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['lp_name']); $column++; - $worksheet->SetCellValueByColumnAndRow($line, $column, $row['is_user_subscribed']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['is_user_subscribed']); $line++; } diff --git a/main/exercise/hotpotatoes_exercise_result.class.php b/main/exercise/hotpotatoes_exercise_result.class.php index 22c32aa253..21627e3eeb 100755 --- a/main/exercise/hotpotatoes_exercise_result.class.php +++ b/main/exercise/hotpotatoes_exercise_result.class.php @@ -250,18 +250,17 @@ class HotpotatoesExerciseResult } if ($with_column_user) { - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email')); $column++; - if (api_is_western_name_order()) { - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); $column++; } else { - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); $column++; } } @@ -272,42 +271,58 @@ class HotpotatoesExerciseResult //show the fields names for user fields foreach ($extra_user_fields as $field) { - $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($field[3]), + ENT_QUOTES, + $charset + ) + ); $column++; } } - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')'); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total')); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status')); $line++; foreach ($this->results as $row) { $column = 0; if ($with_column_user) { - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + api_html_entity_decode( + strip_tags($row['email']), + ENT_QUOTES, + $charset + ) + ); $column++; if (api_is_western_name_order()) { - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); $column++; } else { - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); $column++; } } @@ -316,24 +331,24 @@ class HotpotatoesExerciseResult //show user fields data, if any, for this user $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); foreach($user_fields_values as $value) { - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); $column++; } } - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']); $column++; - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); + $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']); $line++; } diff --git a/main/gradebook/gradebook.php b/main/gradebook/gradebook.php index d1d355078c..58c6ea17b3 100755 --- a/main/gradebook/gradebook.php +++ b/main/gradebook/gradebook.php @@ -71,9 +71,9 @@ if (isset ($_GET['createallcategories'])) { //move a category if (isset($_GET['movecat'])) { - $move_cat = Security::remove_XSS($_GET['movecat']); + $move_cat = (int) $_GET['movecat']; GradebookUtils::block_students(); - $cats= Category :: load($move_cat); + $cats = Category :: load($move_cat); if (!isset ($_GET['targetcat'])) { $move_form= new CatForm(CatForm :: TYPE_MOVE, $cats[0], @@ -267,7 +267,7 @@ if ($course_to_crsind && !isset($_GET['confirm'])) { method="post" action="'.api_get_self() .'?confirm=' .(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat']) - : '&moveeval=' . Security::remove_XSS($_GET['moveeval']) ).'&selectcat=' . $selectcat.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'"> + : '&moveeval=' . intval($_GET['moveeval']) ).'&selectcat=' . $selectcat.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'"> '; diff --git a/main/gradebook/index.php b/main/gradebook/index.php index ebef10fbc8..78d531c763 100755 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -164,7 +164,7 @@ if (isset($_GET['createallcategories'])) { $cat->set_weight(0); $cat->set_visible(0); $cat->add(); - unset ($cat); + unset($cat); } } header('Location: '.$_SESSION['gradebook_dest'].'?addallcat=&selectcat=0'); @@ -181,18 +181,17 @@ if (isset($_GET['visiblelog'])) { if (isset($_GET['movecat'])) { GradebookUtils::block_students(); $cats= Category :: load($_GET['movecat']); - if (!isset ($_GET['targetcat'])) { + if (!isset($_GET['targetcat'])) { $move_form= new CatForm( CatForm :: TYPE_MOVE, $cats[0], 'move_cat_form', null, - api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat']) - . '&selectcat=' . $selectCat + api_get_self() . '?movecat=' . intval($_GET['movecat']). '&selectcat=' . $selectCat ); if ($move_form->validate()) { header('Location: ' . api_get_self() . '?selectcat=' . $selectCat - . '&movecat=' . Security::remove_XSS($_GET['movecat']) + . '&movecat=' . intval($_GET['movecat']) . '&targetcat=' . $move_form->exportValue('move_cat')); exit; } @@ -421,7 +420,7 @@ if (!empty($course_to_crsind) && !isset($_GET['confirm'])) { die ('Error: movecat or moveeval not defined'); } $button = '
'; @@ -878,8 +877,8 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null,true)) /** @var Category $cat */ foreach ($cats as $cat) { $allcat = $cat->get_subcategories($stud_id, $course_code, $session_id); - $alleval = $cat->get_evaluations($stud_id); - $alllink = $cat->get_links($stud_id, true); + $alleval = $cat->get_evaluations($stud_id, false, $course_code, $session_id); + $alllink = $cat->get_links($stud_id, true, $course_code, $session_id); if ($cat->get_parent_id() != 0) { $i++; diff --git a/main/gradebook/lib/be/abstractlink.class.php b/main/gradebook/lib/be/abstractlink.class.php index ecfbc4d1b7..d5ff12b5cb 100755 --- a/main/gradebook/lib/be/abstractlink.class.php +++ b/main/gradebook/lib/be/abstractlink.class.php @@ -56,7 +56,7 @@ abstract class AbstractLink implements GradebookItem */ public function get_ref_id() { - return $this->ref_id; + return (int) $this->ref_id; } /** @@ -239,32 +239,32 @@ abstract class AbstractLink implements GradebookItem $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $sql = 'SELECT * FROM '.$tbl_grade_links; $paramcount = 0; - if (isset ($id)) { + if (isset($id)) { $sql.= ' WHERE id = '.intval($id); $paramcount ++; } - if (isset ($type)) { + if (isset($type)) { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= ' type = '.intval($type); $paramcount ++; } - if (isset ($ref_id)) { + if (isset($ref_id)) { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= ' ref_id = '.intval($ref_id); $paramcount ++; } - if (isset ($user_id)) { + if (isset($user_id)) { if ($paramcount != 0) { $sql .= ' AND'; - }else { + } else { $sql .= ' WHERE'; } $sql .= ' user_id = '.intval($user_id); $paramcount ++; } - if (isset ($course_code)) { + if (isset($course_code)) { if ($paramcount != 0) { $sql .= ' AND'; } else { @@ -273,16 +273,16 @@ abstract class AbstractLink implements GradebookItem $sql .= " course_code = '".Database::escape_string($course_code)."'"; $paramcount ++; } - if (isset ($category_id)) { + if (isset($category_id)) { if ($paramcount != 0) { $sql .= ' AND'; - }else { + } else { $sql .= ' WHERE'; } $sql .= ' category_id = '.intval($category_id); $paramcount ++; } - if (isset ($visible)) { + if (isset($visible)) { if ($paramcount != 0) { $sql .= ' AND'; } else { @@ -290,6 +290,7 @@ abstract class AbstractLink implements GradebookItem } $sql .= ' visible = '.intval($visible); } + $result = Database::query($sql); $links = AbstractLink::create_objects_from_sql_result($result); diff --git a/main/gradebook/lib/be/evaluation.class.php b/main/gradebook/lib/be/evaluation.class.php index 60e53007b7..ee2e172d0a 100755 --- a/main/gradebook/lib/be/evaluation.class.php +++ b/main/gradebook/lib/be/evaluation.class.php @@ -230,48 +230,46 @@ class Evaluation implements GradebookItem $paramcount ++; } - if (isset ($user_id)) { + if (isset($user_id)) { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= ' user_id = '.intval($user_id); $paramcount ++; } - if (isset ($course_code) && $course_code <> '-1') { + if (isset($course_code) && $course_code <> '-1') { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= " course_code = '".Database::escape_string($course_code)."'"; $paramcount ++; } - if (isset ($category_id)) { + if (isset($category_id)) { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= ' category_id = '.intval($category_id); $paramcount ++; } - if (isset ($visible)) { + if (isset($visible)) { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= ' visible = '.intval($visible); $paramcount ++; } - if (isset ($locked)) { + if (isset($locked)) { if ($paramcount != 0) $sql .= ' AND'; else $sql .= ' WHERE'; $sql .= ' locked = '.intval($locked); } $result = Database::query($sql); - $alleval = Evaluation::create_evaluation_objects_from_sql_result($result); + $allEval = Evaluation::create_evaluation_objects_from_sql_result($result); - return $alleval; + return $allEval; } - - /** * @param array $result * @return array @@ -306,7 +304,7 @@ class Evaluation implements GradebookItem /** * Insert this evaluation into the database */ - public function add() + public function add() { if (isset($this->name) && isset($this->user_id) && diff --git a/main/gradebook/lib/be/studentpublicationlink.class.php b/main/gradebook/lib/be/studentpublicationlink.class.php index fb81fbc34a..4739737d1c 100755 --- a/main/gradebook/lib/be/studentpublicationlink.class.php +++ b/main/gradebook/lib/be/studentpublicationlink.class.php @@ -8,101 +8,109 @@ */ class StudentPublicationLink extends AbstractLink { - private $studpub_table = null; - private $itemprop_table = null; - - /** - * Constructor - */ - public function __construct() - { - parent::__construct(); - $this->set_type(LINK_STUDENTPUBLICATION); - } - - /** - * - * Returns the URL of a document - * This function is loaded when using a gradebook as a tab (gradebook = -1) - * see issue #2705 - * - */ - public function get_view_url($stud_id) - { - // find a file uploaded by the given student, - // with the same title as the evaluation name - - $eval = $this->get_evaluation(); - $stud_id = intval($stud_id); - - $sql = 'SELECT pub.url - FROM '.$this->get_itemprop_table().' prop, '.$this->get_studpub_table().' pub' - ." WHERE - prop.c_id = ".$this->course_id." AND - pub.c_id = ".$this->course_id." AND - prop.tool = 'work'" - .' AND prop.insert_user_id = '.$stud_id - .' AND prop.ref = pub.id' - ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; - - $result = Database::query($sql); - if ($fileurl = Database::fetch_row($result)) { - return null; - } else { - return null; - } - } - - public function get_type_name() - { - return get_lang('Works'); - } - - public function is_allowed_to_change_name() - { - return false; - } - - /** - * Generate an array of exercises 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() - { - return false; - 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 id, url from '.$this->get_studpub_table() - .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' - .' (SELECT ref_id FROM '.$tbl_grade_links - .' WHERE type = '.LINK_STUDENTPUBLICATION - ." AND course_code = '".Database::escape_string($this->get_course_code())."'" - .') AND pub.session_id='.api_get_session_id().''; - - $result = Database::query($sql); - - $cats=array(); - while ($data=Database::fetch_array($result)) { - $cats[] = array ($data['id'], $data['url']); - } - return $cats; - } - - /** - * Generate an array of all exercises 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_not_created_links() : course code not set'); - } - $em = Database::getManager(); + private $studpub_table = null; + private $itemprop_table = null; + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + $this->set_type(LINK_STUDENTPUBLICATION); + } + + /** + * + * Returns the URL of a document + * This function is loaded when using a gradebook as a tab (gradebook = -1) + * see issue #2705 + * + */ + public function get_view_url($stud_id) + { + return null; + // find a file uploaded by the given student, + // with the same title as the evaluation name + + $eval = $this->get_evaluation(); + $stud_id = intval($stud_id); + $itemProperty = $this->get_itemprop_table(); + $workTable = $this->get_studpub_table(); + $courseId = $this->course_id; + + $sql = "SELECT pub.url + FROM $itemProperty prop INNER JOIN $workTable pub + ON (prop.c_id = pub.c_id AND prop.ref = pub.id) + WHERE + prop.c_id = ".$courseId." AND + pub.c_id = ".$courseId." AND + prop.tool = 'work' AND + prop.insert_user_id = $stud_id AND + pub.title = '".Database::escape_string($eval->get_name())."' AND + pub.session_id=".api_get_session_id(); + + $result = Database::query($sql); + if ($fileurl = Database::fetch_row($result)) { + return null; + } else { + return null; + } + } + + /** + * @return string + */ + public function get_type_name() + { + return get_lang('Works'); + } + + public function is_allowed_to_change_name() + { + return false; + } + + /** + * Generate an array of exercises 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() + { + return false; + 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 id, url from '.$this->get_studpub_table() + .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' + .' (SELECT ref_id FROM '.$tbl_grade_links + .' WHERE type = '.LINK_STUDENTPUBLICATION + ." AND course_code = '".Database::escape_string($this->get_course_code())."'" + .') AND pub.session_id='.api_get_session_id().''; + + $result = Database::query($sql); + + $cats=array(); + while ($data = Database::fetch_array($result)) { + $cats[] = array($data['id'], $data['url']); + } + return $cats; + } + + /** + * Generate an array of all exercises 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_not_created_links() : course code not set'); + } + $em = Database::getManager(); $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); - /* + /* if (empty($session_id)) { $session_condition = api_get_session_condition(0, true); } else { @@ -111,8 +119,8 @@ class StudentPublicationLink extends AbstractLink $sql = "SELECT id, url, title FROM $tbl_grade_links WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/ - //Only show works from the session - //AND has_properties != '' + //Only show works from the session + //AND has_properties != '' $links = $em ->getRepository('ChamiloCourseBundle:CStudentPublication') ->findBy([ @@ -123,42 +131,55 @@ class StudentPublicationLink extends AbstractLink ]); foreach ($links as $data) { - $work_name = $data->getTitle(); - if (empty($work_name)) { - $work_name = basename($data->getUrl()); - } - $cats[] = array ($data->getId(), $work_name); - } - $cats=isset($cats) ? $cats : array(); - return $cats; - } - - /** - * Has anyone done this exercise yet ? - */ - public function has_results() - { - $em = Database::getManager(); + $work_name = $data->getTitle(); + if (empty($work_name)) { + $work_name = basename($data->getUrl()); + } + $cats[] = array ($data->getId(), $work_name); + } + $cats=isset($cats) ? $cats : array(); + return $cats; + } + + /** + * Has anyone done this exercise yet ? + */ + public function has_results() + { + $data = $this->get_exercise_data(); + + if (empty($data)) { + return ''; + } + $id = $data['id']; + + $em = Database::getManager(); $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); $results = $em ->getRepository('ChamiloCourseBundle:CStudentPublication') ->findBy([ 'cId' => $this->course_id, - 'parentId' => intval($this->get_ref_id()), + 'parentId' => $id, 'session' => $session ]); return count($results) != 0; - } - - /** - * @param null $stud_id - * @return array|null - */ - public function calc_score($stud_id = null, $type = null) - { - $stud_id = intval($stud_id); + } + + /** + * @param null $stud_id + * @return array|null + */ + public function calc_score($stud_id = null, $type = null) + { + $stud_id = (int) $stud_id; $em = Database::getManager(); + $data = $this->get_exercise_data(); + + if (empty($data)) { + return ''; + } + $id = $data['id']; $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); @@ -166,53 +187,72 @@ class StudentPublicationLink extends AbstractLink ->getRepository('ChamiloCourseBundle:CStudentPublication') ->findOneBy([ 'cId' => $this->course_id, - 'id' => intval($this->get_ref_id()), + 'id' => $id, 'session' => $session - ]); + ]) + ; $parentId = !$assignment ? 0 : $assignment->getId(); - $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a - WHERE - a.cId = :course AND - a.active = :active AND - a.parentId = :parent AND - a.session = :session AND - a.qualificatorId <> 0 - '; - - $params = [ - 'course' => $this->course_id, - 'parent' => $parentId, - 'session' => $session, - 'active' => true - ]; - - if (!empty($stud_id)) { - $dql .= ' AND a.userId = :student '; + if (empty($session)) { + $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a + WHERE + a.cId = :course AND + a.active = :active AND + a.parentId = :parent AND + a.session is null AND + a.qualificatorId <> 0 + '; + + $params = [ + 'course' => $this->course_id, + 'parent' => $parentId, + 'active' => true + ]; + + } else { + $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a + WHERE + a.cId = :course AND + a.active = :active AND + a.parentId = :parent AND + a.session = :session AND + a.qualificatorId <> 0 + '; + + $params = [ + 'course' => $this->course_id, + 'parent' => $parentId, + 'session' => $session, + 'active' => true, + ]; + } + + if (!empty($stud_id)) { + $dql .= ' AND a.userId = :student '; $params['student'] = $stud_id; - } - - $order = api_get_setting('student_publication_to_take_in_gradebook'); - - switch ($order) { - case 'last': - // latest attempt - $dql .= ' ORDER BY a.sentDate DESC'; - break; - case 'first': - default: - // first attempt - $dql .= ' ORDER BY a.id'; - break; - } + } + + $order = api_get_setting('student_publication_to_take_in_gradebook'); + + switch ($order) { + case 'last': + // latest attempt + $dql .= ' ORDER BY a.sentDate DESC'; + break; + case 'first': + default: + // first attempt + $dql .= ' ORDER BY a.id'; + break; + } $scores = $em->createQuery($dql)->execute($params); - // for 1 student - if (!empty($stud_id)) { - if (!count($scores)) { - return ''; + // for 1 student + if (!empty($stud_id)) { + if (!count($scores)) { + return ''; } $data = $scores[0]; @@ -221,7 +261,7 @@ class StudentPublicationLink extends AbstractLink $data->getQualification(), $assignment->getQualification() ]; - } + } $students = array(); // user list, needed to make sure we only // take first attempts into account @@ -265,116 +305,148 @@ class StudentPublicationLink extends AbstractLink return array($sum, $rescount); break; } - } - - /** - * Lazy load function to get the database table of the student publications - */ - private function get_studpub_table() - { - return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); - } - - /** - * Lazy load function to get the database table of the item properties - */ - private function get_itemprop_table() - { - return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); - } - - public function needs_name_and_description() - { - return false; - } - - public function get_name() - { - $this->get_exercise_data(); - return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); - } - - public function get_description() - { - $this->get_exercise_data(); - return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; - } - - public function get_test_id() - { - return 'DEBUG:ID'; - } - - public function get_link() - { - $session_id = api_get_session_id(); - $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; - - return $url; - } - - private function get_exercise_data() - { - $tbl_name = $this->get_studpub_table(); - $course_info = api_get_course_info($this->get_course_code()); - if ($tbl_name=='') { - return false; - } elseif (!isset($this->exercise_data)) { - $sql = 'SELECT * FROM '.$this->get_studpub_table()." - WHERE - c_id ='".$course_info['real_id']."' AND - id = '".intval($this->get_ref_id())."' "; - $query = Database::query($sql); - $this->exercise_data = Database::fetch_array($query); - } - return $this->exercise_data; - } - - public function needs_max() - { - return false; - } - - public function needs_results() - { - return false; - } - - public function is_valid_link() - { - $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' - WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).''; - $result = Database::query($sql); - $number = Database::fetch_row($result); - return ($number[0] != 0); - } - - public function get_icon_name() - { - return 'studentpublication'; - } - - public function save_linked_data() - { - $weight = (float)$this->get_weight(); - $ref_id = $this->get_ref_id(); - - if (!empty($ref_id)) { - //Cleans works - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' - WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; - Database::query($sql); - } - } - - public function delete_linked_data() - { - $ref_id = $this->get_ref_id(); - if (!empty($ref_id)) { - //Cleans works - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 - WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; - Database::query($sql); - } - } + } + + /** + * Lazy load function to get the database table of the student publications + */ + private function get_studpub_table() + { + return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); + } + + /** + * Lazy load function to get the database table of the item properties + */ + private function get_itemprop_table() + { + return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); + } + + public function needs_name_and_description() + { + return false; + } + + public function get_name() + { + $this->get_exercise_data(); + $name = isset($this->exercise_data['title']) && !empty($this->exercise_data['title']) ? $this->exercise_data['title'] : get_lang('Untitled'); + return $name; + } + + public function get_description() + { + $this->get_exercise_data(); + return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; + } + + public function get_test_id() + { + return 'DEBUG:ID'; + } + + public function get_link() + { + $session_id = api_get_session_id(); + $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; + + return $url; + } + + /** + * @return array + */ + private function get_exercise_data() + { + $course_info = api_get_course_info($this->get_course_code()); + if (!isset($this->exercise_data)) { + $sql = 'SELECT * FROM '.$this->get_studpub_table()." + WHERE + c_id ='".$course_info['real_id']."' AND + id = '".$this->get_ref_id()."' "; + $query = Database::query($sql); + $this->exercise_data = Database::fetch_array($query); + + // Try with iid + if (empty($this->exercise_data)) { + $sql = 'SELECT * FROM '.$this->get_studpub_table()." + WHERE + c_id ='".$course_info['real_id']."' AND + iid = '".$this->get_ref_id()."' "; + $query = Database::query($sql); + $this->exercise_data = Database::fetch_array($query); + } + } + + return $this->exercise_data; + } + + public function needs_max() + { + return false; + } + + public function needs_results() + { + return false; + } + + public function is_valid_link() + { + $data = $this->get_exercise_data(); + + if (empty($data)) { + return ''; + } + $id = $data['id']; + $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' + WHERE + c_id = "'.$this->course_id.'" AND + id = '.$id.''; + $result = Database::query($sql); + $number = Database::fetch_row($result); + return ($number[0] != 0); + } + + public function get_icon_name() + { + return 'studentpublication'; + } + + public function save_linked_data() + { + $data = $this->get_exercise_data(); + + if (empty($data)) { + return ''; + } + $id = $data['id']; + + $weight = (float) $this->get_weight(); + if (!empty($id)) { + //Cleans works + $sql = 'UPDATE '.$this->get_studpub_table().' + SET weight= '.$weight.' + WHERE c_id = '.$this->course_id.' AND id ='.$id; + Database::query($sql); + } + } + + public function delete_linked_data() + { + $data = $this->get_exercise_data(); + + if (empty($data)) { + return ''; + } + + if (!empty($id)) { + //Cleans works + $sql = 'UPDATE '.$this->get_studpub_table().' + SET weight=0 + WHERE c_id = '.$this->course_id.' AND id ='.$id; + Database::query($sql); + } + } } diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index 28e52cb5bd..82e245d3d7 100755 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -171,39 +171,35 @@ class GradebookTable extends SortableTable switch ($this->column) { // Type case (0 + $col_adjust): - $sorting = GradebookDataGenerator :: GDG_SORT_TYPE; + $sorting = GradebookDataGenerator::GDG_SORT_TYPE; break; case (1 + $col_adjust): - $sorting = GradebookDataGenerator :: GDG_SORT_NAME; + $sorting = GradebookDataGenerator::GDG_SORT_NAME; break; case (2 + $col_adjust): - $sorting = GradebookDataGenerator :: GDG_SORT_DESCRIPTION; + $sorting = GradebookDataGenerator::GDG_SORT_DESCRIPTION; break; case (3 + $col_adjust): - $sorting = GradebookDataGenerator :: GDG_SORT_WEIGHT; + $sorting = GradebookDataGenerator::GDG_SORT_WEIGHT; break; case (4 + $col_adjust): - $sorting = GradebookDataGenerator :: GDG_SORT_DATE; + $sorting = GradebookDataGenerator::GDG_SORT_DATE; break; case (5 + $col_adjust): - $sorting = GradebookDataGenerator :: GDG_SORT_ID; + $sorting = GradebookDataGenerator::GDG_SORT_ID; break; } if ($this->direction == 'DESC') { - $sorting |= GradebookDataGenerator :: GDG_SORT_DESC; + $sorting |= GradebookDataGenerator::GDG_SORT_DESC; } else { - $sorting |= GradebookDataGenerator :: GDG_SORT_ASC; + $sorting |= GradebookDataGenerator::GDG_SORT_ASC; } // Status of user in course. $user_id = $this->userId; $course_code = api_get_course_id(); $session_id = api_get_session_id(); - $status_user = api_get_status_of_user_in_course( - api_get_user_id(), - api_get_course_int_id() - ); if (empty($session_id)) { $statusToFilter = STUDENT; @@ -244,6 +240,7 @@ class GradebookTable extends SortableTable $session_id, 'ORDER BY id' ); + $total_categories_weight = 0; $scoredisplay = ScoreDisplay :: instance(); @@ -718,7 +715,7 @@ class GradebookTable extends SortableTable ); if (!empty($content_html)) { - $new_content = explode('',$content_html['content']); + $new_content = explode('', $content_html['content']); } if (empty($new_content[0])) { @@ -950,13 +947,13 @@ class GradebookTable extends SortableTable $prms_uri='?selectcat=' . $item->get_id() . '&view='.$view; if (isset($_GET['isStudentView'])) { - if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { + if ( isset($is_student) || (isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { $prms_uri=$prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); } } $cat = new Category(); - $show_message=$cat->show_message_resource_delete($item->get_course_code()); + $show_message = $cat->show_message_resource_delete($item->get_course_code()); return ' ' . $item->get_name() . '' diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index af4ced4563..6eb54e9cb4 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -638,7 +638,11 @@ class FlatViewDataGenerator // Fixing total when using one or multiple gradebooks. if (empty($parentCategoryIdFilter)) { if ($this->category->get_parent_id() == 0) { - $item_value = $score[0] / $divide * $item->get_weight(); + if (isset($score[0])) { + $item_value = $score[0] / $divide * $item->get_weight(); + } else { + $item_value = 0; + } } else { $item_value = $item_value * $item->get_weight(); } diff --git a/main/gradebook/lib/gradebook_data_generator.class.php b/main/gradebook/lib/gradebook_data_generator.class.php index fd83583b5c..f7425d84ca 100755 --- a/main/gradebook/lib/gradebook_data_generator.class.php +++ b/main/gradebook/lib/gradebook_data_generator.class.php @@ -31,9 +31,9 @@ class GradebookDataGenerator */ public function __construct($cats = array(), $evals = array(), $links = array()) { - $allcats = (isset($cats) ? $cats : array()); - $allevals = (isset($evals) ? $evals : array()); - $alllinks = (isset($links) ? $links : array()); + $allcats = isset($cats) ? $cats : array(); + $allevals = isset($evals) ? $evals : array(); + $alllinks = isset($links) ? $links : array(); // if we are in the root category and if there are sub categories // display only links depending of the root category and not link that belongs @@ -42,12 +42,12 @@ class GradebookDataGenerator if (count($allcats) > 0) { // get sub categories id $tabCategories = array(); - for ($i=0; $i < count($allcats); $i++) { + for ($i = 0; $i < count($allcats); $i++) { $tabCategories[] = $allcats[$i]->get_id(); } // dont display links that belongs to a sub category $tabLinkToDisplay = array(); - for ($i=0; $i < count($alllinks); $i++) { + for ($i = 0; $i < count($alllinks); $i++) { if (!in_array($alllinks[$i]->get_category_id(), $tabCategories)) { $tabLinkToDisplay[] = $alllinks[$i]; } @@ -90,54 +90,27 @@ class GradebookDataGenerator //$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); // do some checks on count, redefine if invalid value if (!isset($count)) { - $count = count ($this->items) - $start; + $count = count($this->items) - $start; } if ($count < 0) { $count = 0; } $allitems = $this->items; - /* - // sort array - if ($sorting & self :: GDG_SORT_TYPE) { - usort($allitems, array('GradebookDataGenerator', 'sort_by_type')); - } elseif ($sorting & self :: GDG_SORT_ID) { - usort($allitems, array('GradebookDataGenerator', 'sort_by_id')); - } elseif ($sorting & self :: GDG_SORT_NAME) { - usort($allitems, array('GradebookDataGenerator', 'sort_by_name')); - } elseif ($sorting & self :: GDG_SORT_DESCRIPTION) { - usort($allitems, array('GradebookDataGenerator', 'sort_by_description')); - } elseif ($sorting & self :: GDG_SORT_WEIGHT) { - usort($allitems, array('GradebookDataGenerator', 'sort_by_weight')); - } elseif ($sorting & self :: GDG_SORT_DATE) { - //usort($allitems, array('GradebookDataGenerator', 'sort_by_date')); - } - if ($sorting & self :: GDG_SORT_DESC) { - $allitems = array_reverse($allitems); - }*/ - usort($allitems, array('GradebookDataGenerator', 'sort_by_name')); $userId = $this->userId; // Get selected items - $visibleitems = array_slice($allitems, $start, $count); - $course_code = api_get_course_id(); - $sessionId = api_get_session_id(); - $status_user = api_get_status_of_user_in_course( - api_get_user_id(), - api_get_course_int_id() - ); - + $visibleItems = array_slice($allitems, $start, $count); $userCount = count($studentList); // Generate the data to display $data = array(); - - /** @var GradebookItem $item */ $totalWeight = 0; - foreach ($visibleitems as $item) { + /** @var GradebookItem $item */ + foreach ($visibleItems as $item) { $row = array(); $row[] = $item; $row[] = $item->get_name(); diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 7baee076ed..e33cb90a14 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -453,7 +453,7 @@ function menuArray() } } else { if (api_get_user_id() && !api_is_anonymous()) { - $list = split("\n", $openMenuTabsLoggedIn); + $list = explode("\n", $openMenuTabsLoggedIn); foreach ($list as $link) { $matches = array(); $match = preg_match('$href="([^"]*)" target="([^"]*)">([^<]*)$', $link, $matches); @@ -467,7 +467,7 @@ function menuArray() } } } else { - $list = split("\n", $open); + $list = explode("\n", $open); foreach ($list as $link) { $matches = array(); $match = preg_match('$href="([^"]*)" target="([^"]*)">([^<]*)$', $link, $matches); @@ -488,7 +488,6 @@ function menuArray() //$pre_lis = ''; $activeSection = ''; foreach ($mainNavigation['navigation'] as $section => $navigation_info) { - $key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:''); if (isset($GLOBALS['this_section'])) { diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 9f48d101b6..7e0f80c29c 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -83,10 +83,12 @@ class Template api_get_path(SYS_PLUGIN_PATH) // plugin folder ); - $cache_folder = api_get_path(SYS_ARCHIVE_PATH).'twig'; + $urlId = api_get_current_access_url_id(); + + $cache_folder = api_get_path(SYS_ARCHIVE_PATH).'twig/'.$urlId.'/'; if (!is_dir($cache_folder)) { - mkdir($cache_folder, api_get_permissions_for_new_directories()); + mkdir($cache_folder, api_get_permissions_for_new_directories(), true); } $loader = new Twig_Loader_Filesystem($template_paths); diff --git a/main/mySpace/current_courses.php b/main/mySpace/current_courses.php index 62c3d02349..15c5545b86 100755 --- a/main/mySpace/current_courses.php +++ b/main/mySpace/current_courses.php @@ -220,14 +220,18 @@ if (isset($_GET['export'])) { $column = 0; //skip the first column (row titles) foreach ($headers as $header) { - $worksheet->SetCellValueByColumnAndRow($line, $column, $header); + $worksheet->setCellValueByColumnAndRow($column, $line, $header); $column++; } $line++; foreach ($array as $row) { $column = 0; foreach ($row as $item) { - $worksheet->SetCellValueByColumnAndRow($line, $column, html_entity_decode(strip_tags($item))); + $worksheet->setCellValueByColumnAndRow( + $column, + $line, + html_entity_decode(strip_tags($item)) + ); $column++; } $line++; diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index ed3b3a798a..6e4db5df60 100755 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -2559,7 +2559,7 @@ class SurveyUtil $sql = "SELECT q.question_id, q.type, q.survey_question, count(o.question_option_id) as number_of_options FROM $table_survey_question q LEFT JOIN $table_survey_question_option o ON q.question_id = o.question_id - WHERE q.survey_id = '".Database::escape_string($_GET['survey_id'])."' AND + WHERE q.survey_id = '".$surveyId."' AND q.c_id = $course_id AND o.c_id = $course_id GROUP BY q.question_id @@ -2614,7 +2614,7 @@ class SurveyUtil LEFT JOIN $table_survey_question_option sqo ON sq.question_id = sqo.question_id WHERE - sq.survey_id = '".intval($_GET['survey_id'])."' AND + sq.survey_id = '".$surveyId."' AND sq.c_id = $course_id AND sqo.c_id = $course_id ORDER BY sq.sort ASC, sqo.sort ASC"; @@ -2641,7 +2641,7 @@ class SurveyUtil $display_percentage_header = 0; } else if ($row['type'] == 'percentage') { $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; - } else if ($row['type'] <> 'comment' AND $row['type'] <> 'pagebreak' AND $row['type'] <> 'percentage') { + } else if ($row['type'] <> 'comment' && $row['type'] <> 'pagebreak' && $row['type'] <> 'percentage') { echo '