Minor - format code, flint fixes

pull/2970/head
Julio Montoya 7 years ago
parent 6588a37877
commit eccddab92f
  1. 2
      main/admin/user_list.php
  2. 4
      main/inc/ajax/message.ajax.php
  3. 54
      main/inc/lib/exercise.lib.php
  4. 4
      main/inc/lib/formvalidator/Element/UserAvatar.php
  5. 2
      plugin/grading_electronic/generate.php

@ -1060,7 +1060,7 @@ $data = $extraField->addElements($form, 0, [], true, false, $variablesToShow);
$htmlHeadXtra[] = '
<script>
$(document).ready(function() {
$(function () {
'.$data['jquery_ready_content'].'
})
</script>

@ -112,7 +112,7 @@ switch ($action) {
/** @var User $user */
foreach ($users as $user) {
$userName = $user->getCompleteNameWithUsername();
$userName = UserManager::formatUserFullName($user, true);
if ($showEmail) {
$userName .= " ({$user->getEmail()})";
@ -123,7 +123,7 @@ switch ($action) {
'id' => $user->getId(),
];
}
header('Content-type:application/json');
echo json_encode($return);
break;
default:

@ -2889,7 +2889,7 @@ HOTSPOT;
// But also keep the round values settings.
$format = api_get_configuration_value('exercise_score_format');
if (!empty($format)) {
$html = ScoreDisplay::instance()->display_score([ $score, $weight], $format);
$html = ScoreDisplay::instance()->display_score([$score, $weight], $format);
}
$html = Display::span($html, ['class' => 'score_exercise']);
@ -3191,17 +3191,16 @@ EOT;
}
$now = api_get_utc_datetime();
$time_conditions = '';
$timeConditions = '';
if ($check_publication_dates) {
//start and end are set
$time_conditions = " AND ((start_time <> '' AND start_time < '$now' AND end_time <> '' AND end_time > '$now' ) OR ";
// Start and end are set
$timeConditions = " AND ((start_time <> '' AND start_time < '$now' AND end_time <> '' AND end_time > '$now' ) OR ";
// only start is set
$time_conditions .= " (start_time <> '' AND start_time < '$now' AND end_time is NULL) OR ";
$timeConditions .= " (start_time <> '' AND start_time < '$now' AND end_time is NULL) OR ";
// only end is set
$time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
$timeConditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
// nothing is set
$time_conditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
$timeConditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
}
$needle_where = !empty($search) ? " AND title LIKE '?' " : '';
@ -3220,7 +3219,7 @@ EOT;
if ($search_all_sessions == true) {
$conditions = [
'where' => [
$active_sql.' c_id = ? '.$needle_where.$time_conditions => [
$active_sql.' c_id = ? '.$needle_where.$timeConditions => [
$course_id,
$needle,
],
@ -3231,7 +3230,7 @@ EOT;
if (empty($session_id)) {
$conditions = [
'where' => [
$active_sql.' (session_id = 0 OR session_id IS NULL) AND c_id = ? '.$needle_where.$time_conditions => [
$active_sql.' (session_id = 0 OR session_id IS NULL) AND c_id = ? '.$needle_where.$timeConditions => [
$course_id,
$needle,
],
@ -3241,7 +3240,7 @@ EOT;
} else {
$conditions = [
'where' => [
$active_sql.' (session_id = 0 OR session_id IS NULL OR session_id = ? ) AND c_id = ? '.$needle_where.$time_conditions => [
$active_sql.' (session_id = 0 OR session_id IS NULL OR session_id = ? ) AND c_id = ? '.$needle_where.$timeConditions => [
$session_id,
$course_id,
$needle,
@ -3257,32 +3256,6 @@ EOT;
return Database::select('*', $table, $conditions);
}
/**
* Get exercise information by id.
*
* @param int $exerciseId Exercise Id
* @param int $courseId The course ID (necessary as c_quiz.id is not unique)
*
* @return array Exercise info
*/
public static function get_exercise_by_id($exerciseId = 0, $courseId = 0)
{
$table = Database::get_course_table(TABLE_QUIZ_TEST);
if (empty($courseId)) {
$courseId = api_get_course_int_id();
} else {
$courseId = intval($courseId);
}
$conditions = [
'where' => [
'id = ?' => [$exerciseId],
' AND c_id = ? ' => $courseId,
],
];
return Database::select('*', $table, $conditions);
}
/**
* Getting all exercises (active only or all)
* from a course from a session
@ -3797,10 +3770,10 @@ EOT;
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$question_id = intval($question_id);
$exercise_id = intval($exercise_id);
$question_id = (int) $question_id;
$exercise_id = (int) $exercise_id;
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$session_id = (int) $session_id;
$courseId = api_get_course_int_id($course_code);
$sql = "SELECT MAX(marks) as max, MIN(marks) as min, AVG(marks) as average
@ -3988,7 +3961,6 @@ EOT;
$track_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$courseUserSession = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$question_id = (int) $question_id;

@ -73,10 +73,10 @@ class UserAvatar extends HTML_QuickForm_input
$html .= '
<div class="media">
<div class="media-left">
<img src="'.$userPicture.'" alt="'.$this->user->getCompleteName().'">
<img src="'.$userPicture.'" alt="'.UserManager::formatUserFullName($this->user).'">
</div>
<div class="media-body">
<h4 class="media-heading">'.$this->user->getCompleteName().'</h4>
<h4 class="media-heading">'.UserManager::formatUserFullName($this->user).'</h4>
'.$this->subTitle.'
</div>
</div>

@ -110,7 +110,7 @@ try {
$fileData = [];
$fileData[] = sprintf(
"1 %s %s%s",
'1 %s %s%s',
$fieldProvider ? $fieldProvider['value'] : null,
$values['course'],
$dateStart->format('m/d/Y')

Loading…
Cancel
Save