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. 44
      main/inc/lib/exercise.lib.php

@ -5857,8 +5857,12 @@ class Exercise
* @param string $ip Optional. The user IP * @param string $ip Optional. The user IP
* @return string * @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(); $array = array();
if (!empty($user_data)) { if (!empty($user_data)) {
@ -6435,13 +6439,14 @@ class Exercise
} }
/** /**
*
* @params array question list * @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(); $new_question_list = array();
if (!empty($question_list)) { if (!empty($question_list)) {
$media_questions = $this->getMediaList(); $media_questions = $this->getMediaList();
@ -6646,7 +6651,9 @@ class Exercise
if (empty($exercise_info['questions_to_check'])) { if (empty($exercise_info['questions_to_check'])) {
if ($action == 'add') { 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); Database::query($sql);
} }
} else { } else {
@ -6678,7 +6685,9 @@ class Exercise
} }
} }
$remind_list_string = Database::escape_string($remind_list_string); $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); 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 // The $questionList contains the media id we check if this questionId is a media question type
if (isset($mediaQuestions[$questionId]) &&
if (isset($mediaQuestions[$questionId]) && $mediaQuestions[$questionId] != 999) { $mediaQuestions[$questionId] != 999
) {
// The question belongs to a media // The question belongs to a media
$mediaQuestionList = $mediaQuestions[$questionId]; $mediaQuestionList = $mediaQuestions[$questionId];
$objQuestionTmp = Question::read($questionId); $objQuestionTmp = Question::read($questionId);
@ -7122,7 +7132,7 @@ class Exercise
if ($this->type == ALL_ON_ONE_PAGE) { if ($this->type == ALL_ON_ONE_PAGE) {
$exercise_actions = $this->show_button($questionId, $currentQuestion); $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 // Button save and continue
switch ($this->type) { switch ($this->type) {
case ONE_PER_PAGE: 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; break;
case ALL_ON_ONE_PAGE: case ALL_ON_ONE_PAGE:
$button = [ $button = [
@ -7271,7 +7286,9 @@ class Exercise
} }
// Checkbox review answers // 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( $remind_question_div = Display::tag(
'label', 'label',
Display::input( Display::input(

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

@ -1499,17 +1499,19 @@ HOTSPOT;
/** /**
* Gets count of exam results * 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( $count = self::get_exam_results_data(
null, null,
null, null,
null, null,
null, null,
$exercise_id, $exerciseId,
$extra_where_conditions, $conditions,
true true
); );
return $count; return $count;
@ -2176,7 +2178,8 @@ HOTSPOT;
get_lang('DeleteAttempt'), get_lang('DeleteAttempt'),
$results[$i]['username'], $results[$i]['username'],
$dt $dt
).'\')) return false;">'.Display:: return_icon( ).'\')) return false;">'.
Display:: return_icon(
'delete.png', 'delete.png',
get_lang('Delete') get_lang('Delete')
).'</a>'; ).'</a>';
@ -2223,7 +2226,6 @@ HOTSPOT;
} }
} }
} else { } else {
//$hpresults = StatsUtils::getManyResultsXCol($hpsql, 6);
$hpresults = []; $hpresults = [];
$res = Database::query($hpsql); $res = Database::query($hpsql);
if ($res !== false) { if ($res !== false) {
@ -2436,8 +2438,19 @@ HOTSPOT;
return false; 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(); $model = self::getCourseScoreModel();
if (empty($model)) { if (empty($model)) {
return false; return false;
@ -2506,7 +2519,6 @@ HOTSPOT;
EOT; EOT;
return $js; return $js;
} }
/** /**
@ -3147,8 +3159,7 @@ EOT;
$courseId, $courseId,
$session_id, $session_id,
$user_count $user_count
) ) {
{
$user_results = Event::get_best_exercise_results_by_user( $user_results = Event::get_best_exercise_results_by_user(
$exercise_id, $exercise_id,
$courseId, $courseId,
@ -3204,6 +3215,7 @@ EOT;
* @param int $exercise_id * @param int $exercise_id
* @param string $course_code * @param string $course_code
* @param int $session_id * @param int $session_id
* @return array
* *
**/ **/
public static function get_student_stats_by_question( public static function get_student_stats_by_question(
@ -3255,8 +3267,7 @@ EOT;
public static function getNumberStudentsFillBlanksAnwserCount( public static function getNumberStudentsFillBlanksAnwserCount(
$question_id, $question_id,
$exercise_id $exercise_id
) ) {
{
$listStudentsId = []; $listStudentsId = [];
$listAllStudentInfo = CourseManager::get_student_list_from_course_code( $listAllStudentInfo = CourseManager::get_student_list_from_course_code(
api_get_course_id(), api_get_course_id(),
@ -3397,8 +3408,7 @@ EOT;
$exercise_id, $exercise_id,
$course_code, $course_code,
$session_id $session_id
) ) {
{
$track_exercises = Database::get_main_table( $track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES TABLE_STATISTIC_TRACK_E_EXERCISES
); );
@ -3765,7 +3775,8 @@ EOT;
$res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>"; $res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>";
$currentCatId = $tabCategory["id"]; $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>"; $res .= "</select>";
return $res; return $res;
@ -3898,7 +3909,6 @@ EOT;
if (isset($exercise_stat_info['exe_user_id'])) { if (isset($exercise_stat_info['exe_user_id'])) {
$user_info = api_get_user_info($exercise_stat_info['exe_user_id']); $user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
if ($user_info) { if ($user_info) {
// Shows exercise header // Shows exercise header
echo $objExercise->show_exercise_result_header( echo $objExercise->show_exercise_result_header(
$user_info, $user_info,

Loading…
Cancel
Save