Minor - Code style

remotes/angel/1.11.x
Yannick Warnier 8 years ago
parent a6f61fc538
commit e1f6520d97
  1. 20
      main/exercise/fill_blanks.class.php
  2. 20
      main/gradebook/lib/fe/catform.class.php
  3. 20
      main/gradebook/lib/fe/resulttable.class.php
  4. 18
      main/inc/lib/course_request.lib.php
  5. 20
      main/inc/lib/link.lib.php
  6. 18
      main/inc/lib/message.lib.php
  7. 10
      main/inc/lib/tracking.lib.php

@ -36,7 +36,7 @@ class FillBlanks extends Question
if (!empty($this->id)) {
$objectAnswer = new Answer($this->id);
$answer = $objectAnswer->selectAnswer(1);
$listAnswersInfo = FillBlanks::getAnswerInfo($answer);
$listAnswersInfo = self::getAnswerInfo($answer);
if ($listAnswersInfo['switchable']) {
$defaults['multiple_answer'] = 1;
} else {
@ -357,7 +357,7 @@ class FillBlanks extends Question
//$answer = api_html_entity_decode($answer, ENT_QUOTES, $charset);
//$answer = htmlentities(api_utf8_encode($answer));
// remove the :: eventually written by the user
// remove the "::" eventually written by the user
$answer = str_replace('::', '', $answer);
// remove starting and ending space and  
@ -844,24 +844,24 @@ class FillBlanks extends Question
$tabUserResult = array();
// foreach attempts for all students starting with his older attempt
while ($data = Database::fetch_array($res)) {
$tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
$tabAnswer = self::getAnswerInfo($data['answer'], true);
// for each bracket to find in this question
foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
// student has answered this bracket, cool
switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
switch (self::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
case self::FILL_THE_BLANK_MENU:
// get the indice of the choosen answer in the menu
// we know that the right answer is the first entry of the menu, ie 0
// (remember, menu entries are shuffled when taking the test)
$tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum(
$tabUserResult[$data['user_id']][$bracketNumber] = self::getFillTheBlankMenuAnswerNum(
$tabAnswer['tabwords'][$bracketNumber],
$tabAnswer['studentanswer'][$bracketNumber]
);
break;
default:
if (FillBlanks::isGoodStudentAnswer(
if (self::isGoodStudentAnswer(
$tabAnswer['studentanswer'][$bracketNumber],
$tabAnswer['tabwords'][$bracketNumber]
)
@ -1184,11 +1184,11 @@ class FillBlanks extends Question
if (!$right) {
$style = "color: red; text-decoration: line-through;";
}
$type = FillBlanks::getFillTheBlankAnswerType($correct);
$type = self::getFillTheBlankAnswerType($correct);
switch ($type) {
case self::FILL_THE_BLANK_MENU:
$correctAnswerHtml = '';
$listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false);
$listPossibleAnswers = self::getFillTheBlankMenuAnswers($correct, false);
$correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>";
$correctAnswerHtml .= " <span style='font-weight:normal'>(";
for ($i=1; $i < count($listPossibleAnswers); $i++) {
@ -1258,13 +1258,13 @@ class FillBlanks extends Question
*/
public static function isCorrect($answerText)
{
$answerInfo = FillBlanks::getAnswerInfo($answerText, true);
$answerInfo = self::getAnswerInfo($answerText, true);
$correctAnswerList = $answerInfo['tabwords'];
$studentAnswer = $answerInfo['studentanswer'];
$isCorrect = true;
foreach ($correctAnswerList as $i => $correctAnswer) {
$isGoodStudentAnswer = FillBlanks::isGoodStudentAnswer($studentAnswer[$i], $correctAnswer);
$isGoodStudentAnswer = self::isGoodStudentAnswer($studentAnswer[$i], $correctAnswer);
$isCorrect = $isCorrect && $isGoodStudentAnswer;
}

@ -31,18 +31,18 @@ class CatForm extends FormValidator
$method = 'post',
$action = null
) {
parent :: __construct($form_name, $method, $action);
parent::__construct($form_name, $method, $action);
$this->form_type = $form_type;
if (isset($category_object)) {
$this->category_object = $category_object;
}
if ($this->form_type == self :: TYPE_EDIT) {
if ($this->form_type == self::TYPE_EDIT) {
$this->build_editing_form();
} elseif ($this->form_type == self :: TYPE_ADD) {
} elseif ($this->form_type == self::TYPE_ADD) {
$this->build_add_form();
} elseif ($this->form_type == self :: TYPE_MOVE) {
} elseif ($this->form_type == self::TYPE_MOVE) {
$this->build_move_form();
} elseif ($this->form_type == self :: TYPE_SELECT_COURSE) {
} elseif ($this->form_type == self::TYPE_SELECT_COURSE) {
$this->build_select_course_form();
}
$this->setDefaults();
@ -88,7 +88,7 @@ class CatForm extends FormValidator
//check if we are a root category
//if so, you can only choose between courses
if ($this->category_object->get_parent_id() == '0') {
$coursecat = Category :: get_not_created_course_categories(
$coursecat = Category::get_not_created_course_categories(
api_get_user_id()
);
if (count($coursecat) == 0) {
@ -310,7 +310,7 @@ class CatForm extends FormValidator
// Freeze or not
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$test_cats = Category :: load(
$test_cats = Category::load(
null,
null,
$course_code,
@ -359,7 +359,7 @@ class CatForm extends FormValidator
$isRequirementCheckbox->setChecked(true);
}
if ($this->form_type == self :: TYPE_ADD) {
if ($this->form_type == self::TYPE_ADD) {
$this->addButtonCreate(get_lang('AddCategory'));
} else {
$this->addElement('hidden', 'editcat', intval($_GET['editcat']));
@ -386,7 +386,7 @@ class CatForm extends FormValidator
array(get_lang('PickACourse'), 'test'),
null
);
$coursecat = Category :: get_all_courses(api_get_user_id());
$coursecat = Category::get_all_courses(api_get_user_id());
//only return courses that are not yet created by the teacher
foreach ($coursecat as $row) {
@ -403,7 +403,7 @@ class CatForm extends FormValidator
function display()
{
parent :: display();
parent::display();
}
function setDefaults($defaults = array(), $filter = null)

@ -36,7 +36,7 @@ class ResultTable extends SortableTable
if (isset($addparams)) {
$this->set_additional_parameters($addparams);
}
$scoredisplay = ScoreDisplay :: instance();
$scoredisplay = ScoreDisplay::instance();
$column= 0;
if ($this->iscourse == '1') {
$this->set_header($column++, '', false);
@ -74,7 +74,7 @@ class ResultTable extends SortableTable
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) {
$is_western_name_order = api_is_western_name_order();
$scoredisplay = ScoreDisplay :: instance();
$scoredisplay = ScoreDisplay::instance();
// determine sorting type
$col_adjust = $this->iscourse == '1' ? 1 : 0;
@ -83,32 +83,32 @@ class ResultTable extends SortableTable
// first name or last name
case (0 + $col_adjust):
if ($is_western_name_order) {
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
$sorting = ResultsDataGenerator::RDG_SORT_FIRSTNAME;
} else {
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
$sorting = ResultsDataGenerator::RDG_SORT_LASTNAME;
}
break;
// first name or last name
case (1 + $col_adjust):
if ($is_western_name_order) {
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
$sorting = ResultsDataGenerator::RDG_SORT_LASTNAME;
} else {
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
$sorting = ResultsDataGenerator::RDG_SORT_FIRSTNAME;
}
break;
//Score
case (2 + $col_adjust):
$sorting = ResultsDataGenerator :: RDG_SORT_SCORE;
$sorting = ResultsDataGenerator::RDG_SORT_SCORE;
break;
case (3 + $col_adjust):
$sorting = ResultsDataGenerator :: RDG_SORT_MASK;
$sorting = ResultsDataGenerator::RDG_SORT_MASK;
break;
}
if ($this->direction == 'DESC') {
$sorting |= ResultsDataGenerator :: RDG_SORT_DESC;
$sorting |= ResultsDataGenerator::RDG_SORT_DESC;
} else {
$sorting |= ResultsDataGenerator :: RDG_SORT_ASC;
$sorting |= ResultsDataGenerator::RDG_SORT_ASC;
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);

@ -29,7 +29,7 @@ class CourseRequestManager
if ($code_exists = CourseManager::course_code_exists($wanted_course_code)) {
return $code_exists;
}
$table_course_request = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$table_course_request = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
$wanted_course_code = Database::escape_string($wanted_course_code);
$sql = sprintf(
'SELECT COUNT(id) AS number FROM %s WHERE visual_code = "%s"',
@ -359,7 +359,7 @@ class CourseRequestManager
public static function delete_course_request($id)
{
$id = (int)$id;
$sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
$sql = "DELETE FROM ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
WHERE id = ".$id;
$result = Database::query($sql);
return $result !== false;
@ -372,7 +372,7 @@ class CourseRequestManager
*/
public static function count_course_requests($status = null)
{
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$course_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
if (is_null($status)) {
$sql = "SELECT COUNT(id) AS number FROM ".$course_table;
} else {
@ -397,7 +397,7 @@ class CourseRequestManager
{
$id = (int)$id;
$sql = "SELECT *
FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
FROM ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
WHERE id = ".$id;
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -415,7 +415,7 @@ class CourseRequestManager
{
$id = (int)$id;
$sql = "SELECT code
FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
FROM ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
WHERE id = ".$id;
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -471,7 +471,7 @@ class CourseRequestManager
$course_info = CourseManager::create_course($params);
if (!empty($course_info)) {
// Mark the request as accepted.
$sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
$sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
SET status = ".COURSE_REQUEST_ACCEPTED."
WHERE id = ".$id;
Database::query($sql);
@ -549,7 +549,7 @@ class CourseRequestManager
$code = $course_request_info['code'];
$sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
$sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
SET status = ".COURSE_REQUEST_REJECTED."
WHERE id = ".$id;
if (Database::query($sql) === false) {
@ -685,7 +685,7 @@ class CourseRequestManager
}
// Marking the fact that additional information about the request has been asked.
$sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
$sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
SET info = 1 WHERE id = ".$id;
$result = Database::query($sql) !== false;
@ -700,7 +700,7 @@ class CourseRequestManager
public static function additional_info_asked($id)
{
$id = (int)$id;
$sql = "SELECT id FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
$sql = "SELECT id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
WHERE (id = ".$id." AND info > 0)";
$result = Database::num_rows(Database::query($sql));
return !empty($result);

@ -1438,7 +1438,7 @@ class Link extends Model
return 0; // 0 = fail
}
$cat = ($catname = trim($linkdata['category'])) ? Link::get_cat($catname) : 0;
$cat = ($catname = trim($linkdata['category'])) ? self::get_cat($catname) : 0;
$regs = array(); // Will be passed to ereg()
$d = '';
@ -1466,7 +1466,7 @@ class Link extends Model
$d = substr($d, 2) . ' - ';
}
return Link::put_link(
return self::put_link(
$url,
$cat,
$title,
@ -1597,7 +1597,7 @@ class Link extends Model
Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>';
}
$categories = Link::getLinkCategories($course_id, $session_id);
$categories = self::getLinkCategories($course_id, $session_id);
$count = count($categories);
if (!empty($count)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">';
@ -1617,7 +1617,7 @@ class Link extends Model
if ($count !== 0) {
echo Display::panel(
Link::showLinksPerCategory(
self::showLinksPerCategory(
0,
api_get_course_int_id(),
api_get_session_id()
@ -1643,11 +1643,11 @@ class Link extends Model
$visibilityClass = null;
if ($myrow['visibility'] == '1') {
$strVisibility = '<a href="link.php?' . api_get_cidreq() . '&sec_token='.$token.'&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' .
Display :: return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>';
Display::return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>';
} elseif ($myrow['visibility'] == '0') {
$visibilityClass = 'text-muted';
$strVisibility = ' <a href="link.php?' . api_get_cidreq() . '&sec_token='.$token.'&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' .
Display :: return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>';
Display::return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>';
}
$header = '';
@ -1665,7 +1665,7 @@ class Link extends Model
if (api_is_allowed_to_edit(null, true)) {
if ($session_id == $myrow['session_id']) {
$header .= $strVisibility;
$header .= Link::showCategoryAdminTools($myrow, $counter, count($categories));
$header .= self::showCategoryAdminTools($myrow, $counter, count($categories));
} else {
$header .= get_lang('EditionNotAvailableFromSession');
}
@ -1673,7 +1673,7 @@ class Link extends Model
$childrenContent = '';
if ($showChildren) {
$childrenContent = Link::showLinksPerCategory(
$childrenContent = self::showLinksPerCategory(
$myrow['id'],
api_get_course_int_id(),
api_get_session_id()
@ -1697,7 +1697,7 @@ class Link extends Model
{
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$linkInfo = Link::get_link_info($linkId);
$linkInfo = self::get_link_info($linkId);
$categoryId = isset($linkInfo['category_id']) ? $linkInfo['category_id'] : '';
$lpId = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null;
@ -1740,7 +1740,7 @@ class Link extends Model
$form->addText('title', get_lang('LinkName'));
$form->addTextarea('description', get_lang('Description'));
$resultcategories = Link::getLinkCategories($course_id, $session_id);
$resultcategories = self::getLinkCategories($course_id, $session_id);
$options = ['0' => '--'];
if (!empty($resultcategories)) {
foreach ($resultcategories as $myrow) {

@ -415,7 +415,7 @@ class MessageManager
$sendCopyToDrhUsers = false,
$directMessage = false
) {
$result = MessageManager::send_message(
$result = self::send_message(
$receiver_user_id,
$subject,
$message,
@ -439,7 +439,7 @@ class MessageManager
$userInfo['complete_name']
) . ' <br />' . $message;
MessageManager::send_message_simple(
self::send_message_simple(
$drhInfo['user_id'],
$subject,
$message,
@ -1617,7 +1617,7 @@ class MessageManager
$number_of_selected_messages = count($_POST['id']);
if (is_array($_POST['id'])) {
foreach ($_POST['id'] as $index => $message_id) {
MessageManager::update_message_status(api_get_user_id(), $message_id, MESSAGE_STATUS_UNREAD);
self::update_message_status(api_get_user_id(), $message_id, MESSAGE_STATUS_UNREAD);
}
}
$html .= Display::return_message(api_xml_http_response_encode($success_unread), 'normal', false);
@ -1626,7 +1626,7 @@ class MessageManager
$number_of_selected_messages = count($_POST['id']);
if (is_array($_POST['id'])) {
foreach ($_POST['id'] as $index => $message_id) {
MessageManager::update_message_status(api_get_user_id(), $message_id, MESSAGE_STATUS_NEW);
self::update_message_status(api_get_user_id(), $message_id, MESSAGE_STATUS_NEW);
}
}
$html .= Display::return_message(api_xml_http_response_encode($success_read), 'normal', false);
@ -1634,12 +1634,12 @@ class MessageManager
case 'delete' :
$number_of_selected_messages = count($_POST['id']);
foreach ($_POST['id'] as $index => $message_id) {
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
self::delete_message_by_user_receiver(api_get_user_id(), $message_id);
}
$html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
break;
case 'deleteone' :
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
self::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
$html .= Display::return_message(api_xml_http_response_encode($success), 'confirmation', false);
break;
}
@ -1699,13 +1699,13 @@ class MessageManager
$number_of_selected_messages = count($_POST['id']);
if ($number_of_selected_messages != 0) {
foreach ($_POST['id'] as $index => $message_id) {
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
self::delete_message_by_user_receiver(api_get_user_id(), $message_id);
}
}
$html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
break;
case 'deleteone':
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
self::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
$html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
$html .= '<br/>';
break;
@ -1880,7 +1880,7 @@ class MessageManager
$admins = UserManager::get_all_administrators();
foreach ($admins as $admin_info) {
MessageManager::send_message(
self::send_message(
$admin_info['user_id'],
$emailsubject,
$emailbody,

@ -4411,21 +4411,21 @@ class Tracking
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$total_time_login = Tracking::get_time_spent_on_the_course(
$total_time_login = self::get_time_spent_on_the_course(
$user_id,
$courseId
);
$time = api_time_to_hms($total_time_login);
$progress = Tracking::get_avg_student_progress(
$progress = self::get_avg_student_progress(
$user_id,
$course_code
);
$percentage_score = Tracking::get_avg_student_score(
$percentage_score = self::get_avg_student_score(
$user_id,
$course_code,
array()
);
$last_connection = Tracking::get_last_connection_date_on_the_course(
$last_connection = self::get_last_connection_date_on_the_course(
$user_id,
$courseInfo
);
@ -6129,7 +6129,7 @@ class TrackingCourseLog
$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
while ($row = Database::fetch_array($res)) {
$ref = $row['ref'];
$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
$table_name = self::get_tool_name_table($row['col0']);
$table_tool = Database::get_course_table($table_name['table_name']);
$id = $table_name['id_tool'];

Loading…
Cancel
Save