Minor - format code.

pull/2487/head
jmontoyaa 7 years ago
parent 193a286273
commit ab00cdbf0c
  1. 45
      main/exercise/exercise.class.php
  2. 28
      main/exercise/question.class.php
  3. 60
      main/inc/lib/exercise.lib.php

@ -5857,8 +5857,12 @@ class Exercise
* @param string $ip Optional. The user IP
* @return string
*/
public function show_exercise_result_header($user_data, $start_date = null, $duration = null, $ip = null)
{
public function show_exercise_result_header(
$user_data,
$start_date = null,
$duration = null,
$ip = null
) {
$array = array();
if (!empty($user_data)) {
@ -6435,13 +6439,14 @@ class Exercise
}
/**
*
* @params array question list
* @params bool expand or not question list (true show all questions, false show media question id instead of the question ids)
*
* @params bool expand or not question list (true show all questions,
* false show media question id instead of the question ids)
**/
public function transformQuestionListWithMedias($question_list, $expand_media_questions = false)
{
public function transformQuestionListWithMedias(
$question_list,
$expand_media_questions = false
) {
$new_question_list = array();
if (!empty($question_list)) {
$media_questions = $this->getMediaList();
@ -6646,7 +6651,9 @@ class Exercise
if (empty($exercise_info['questions_to_check'])) {
if ($action == 'add') {
$sql = "UPDATE $track_exercises SET questions_to_check = '$question_id' WHERE exe_id = $exe_id ";
$sql = "UPDATE $track_exercises
SET questions_to_check = '$question_id'
WHERE exe_id = $exe_id ";
Database::query($sql);
}
} else {
@ -6678,7 +6685,9 @@ class Exercise
}
}
$remind_list_string = Database::escape_string($remind_list_string);
$sql = "UPDATE $track_exercises SET questions_to_check = '$remind_list_string' WHERE exe_id = $exe_id ";
$sql = "UPDATE $track_exercises
SET questions_to_check = '$remind_list_string'
WHERE exe_id = $exe_id ";
Database::query($sql);
}
}
@ -7050,8 +7059,9 @@ class Exercise
}
// The $questionList contains the media id we check if this questionId is a media question type
if (isset($mediaQuestions[$questionId]) && $mediaQuestions[$questionId] != 999) {
if (isset($mediaQuestions[$questionId]) &&
$mediaQuestions[$questionId] != 999
) {
// The question belongs to a media
$mediaQuestionList = $mediaQuestions[$questionId];
$objQuestionTmp = Question::read($questionId);
@ -7122,7 +7132,7 @@ class Exercise
if ($this->type == ALL_ON_ONE_PAGE) {
$exercise_actions = $this->show_button($questionId, $currentQuestion);
echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
echo Display::div($exercise_actions, ['class' => 'exercise_actions']);
}
}
@ -7230,7 +7240,12 @@ class Exercise
// Button save and continue
switch ($this->type) {
case ONE_PER_PAGE:
$exercise_actions .= $this->show_button($questionId, $current_question, null, $remindList);
$exercise_actions .= $this->show_button(
$questionId,
$current_question,
null,
$remindList
);
break;
case ALL_ON_ONE_PAGE:
$button = [
@ -7271,7 +7286,9 @@ class Exercise
}
// Checkbox review answers
if ($this->review_answers && !in_array($question_obj->type, Question::question_type_no_review())) {
if ($this->review_answers &&
!in_array($question_obj->type, Question::question_type_no_review())
) {
$remind_question_div = Display::tag(
'label',
Display::input(

@ -1140,12 +1140,10 @@ abstract class Question
if ($se_doc !== false) {
if (($se_doc_data = $di->get_document_data($se_doc)) !== false) {
$se_doc_data = unserialize($se_doc_data);
if (
isset($se_doc_data[SE_DATA]['type']) &&
if (isset($se_doc_data[SE_DATA]['type']) &&
$se_doc_data[SE_DATA]['type'] == SE_DOCTYPE_EXERCISE_QUESTION
) {
if (
isset($se_doc_data[SE_DATA]['exercise_ids']) &&
if (isset($se_doc_data[SE_DATA]['exercise_ids']) &&
is_array($se_doc_data[SE_DATA]['exercise_ids'])
) {
foreach ($se_doc_data[SE_DATA]['exercise_ids'] as $old_value) {
@ -1632,7 +1630,11 @@ abstract class Question
switch ($this->type) {
case UNIQUE_ANSWER:
$buttonGroup = array();
$buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
$buttonGroup[] = $form->addButtonSave(
$text,
'submitQuestion',
true
);
$buttonGroup[] = $form->addButton(
'convertAnswer',
get_lang('ConvertToMultipleAnswer'),
@ -1647,7 +1649,11 @@ abstract class Question
break;
case MULTIPLE_ANSWER:
$buttonGroup = array();
$buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
$buttonGroup[] = $form->addButtonSave(
$text,
'submitQuestion',
true
);
$buttonGroup[] = $form->addButton(
'convertAnswer',
get_lang('ConvertToUniqueAnswer'),
@ -2050,7 +2056,8 @@ abstract class Question
$question_id = Database::insert($tbl_quiz_question, $params);
if ($question_id) {
$sql = "UPDATE $tbl_quiz_question SET id = iid WHERE iid = $question_id";
$sql = "UPDATE $tbl_quiz_question
SET id = iid WHERE iid = $question_id";
Database::query($sql);
// Get the max question_order
@ -2101,7 +2108,12 @@ abstract class Question
$where_condition = array()
) {
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$default_where = array('c_id = ? AND parent_id = 0 AND type = ?' => array($course_id, MEDIA_QUESTION));
$default_where = array(
'c_id = ? AND parent_id = 0 AND type = ?' => array(
$course_id,
MEDIA_QUESTION
)
);
$result = Database::select(
'*',
$table_question,

@ -366,7 +366,7 @@ class ExerciseLib
$attributes['style'] = 'display: none;';
$answer = '<div class="thumbnail">'.$answer.'</div>';
}
$answer_input .= '<label class="radio '.$hidingClass.'">';
$answer_input .= Display::input(
'radio',
@ -1499,17 +1499,19 @@ HOTSPOT;
/**
* Gets count of exam results
* @todo this function should be moved in a library + no global calls
* @param int $exerciseId
* @param array $conditions
* @return array
*/
public static function get_count_exam_results($exercise_id, $extra_where_conditions)
public static function get_count_exam_results($exerciseId, $conditions)
{
$count = self::get_exam_results_data(
null,
null,
null,
null,
$exercise_id,
$extra_where_conditions,
$exerciseId,
$conditions,
true
);
return $count;
@ -2173,13 +2175,14 @@ HOTSPOT;
$delete_link = '<a href="exercise_report.php?'.api_get_cidreq().'&filter_by_user='.intval($_GET['filter_by_user']).'&filter='.$filter.'&exerciseId='.$exercise_id.'&delete=delete&did='.$id.'"
onclick="javascript:if(!confirm(\'' . sprintf(
get_lang('DeleteAttempt'),
$results[$i]['username'],
$dt
).'\')) return false;">'.Display:: return_icon(
'delete.png',
get_lang('Delete')
).'</a>';
get_lang('DeleteAttempt'),
$results[$i]['username'],
$dt
).'\')) return false;">'.
Display:: return_icon(
'delete.png',
get_lang('Delete')
).'</a>';
$delete_link = utf8_encode($delete_link);
if (api_is_drh() && !api_is_platform_admin()) {
@ -2223,7 +2226,6 @@ HOTSPOT;
}
}
} else {
//$hpresults = StatsUtils::getManyResultsXCol($hpsql, 6);
$hpresults = [];
$res = Database::query($hpsql);
if ($res !== false) {
@ -2436,8 +2438,19 @@ HOTSPOT;
return false;
}
public static function addScoreModelInput(FormValidator & $form, $name, $weight, $selected)
{
/**
* @param FormValidator $form
* @param string $name
* @param $weight
* @param $selected
* @return bool
*/
public static function addScoreModelInput(
FormValidator & $form,
$name,
$weight,
$selected
) {
$model = self::getCourseScoreModel();
if (empty($model)) {
return false;
@ -2505,8 +2518,7 @@ HOTSPOT;
});
EOT;
return $js;
return $js;
}
/**
@ -3147,8 +3159,7 @@ EOT;
$courseId,
$session_id,
$user_count
)
{
) {
$user_results = Event::get_best_exercise_results_by_user(
$exercise_id,
$courseId,
@ -3204,6 +3215,7 @@ EOT;
* @param int $exercise_id
* @param string $course_code
* @param int $session_id
* @return array
*
**/
public static function get_student_stats_by_question(
@ -3255,8 +3267,7 @@ EOT;
public static function getNumberStudentsFillBlanksAnwserCount(
$question_id,
$exercise_id
)
{
) {
$listStudentsId = [];
$listAllStudentInfo = CourseManager::get_student_list_from_course_code(
api_get_course_id(),
@ -3397,8 +3408,7 @@ EOT;
$exercise_id,
$course_code,
$session_id
)
{
) {
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
@ -3765,7 +3775,8 @@ EOT;
$res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>";
$currentCatId = $tabCategory["id"];
}
$res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".$tabGroups[$i]["name"]."</option>";
$res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".
$tabGroups[$i]["name"]."</option>";
}
$res .= "</select>";
return $res;
@ -3898,7 +3909,6 @@ EOT;
if (isset($exercise_stat_info['exe_user_id'])) {
$user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
if ($user_info) {
// Shows exercise header
echo $objExercise->show_exercise_result_header(
$user_info,

Loading…
Cancel
Save