Minor - format code

pull/2606/head
Julio Montoya 7 years ago
parent 673dd3d346
commit e3d67828a2
  1. 101
      main/exercise/exercise_show.php

@ -19,7 +19,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$debug = false; $debug = false;
$origin = api_get_origin(); $origin = api_get_origin();
$currentUserId = api_get_user_id(); $currentUserId = api_get_user_id();
$printHeaders = $origin == 'learnpath'; $printHeaders = $origin === 'learnpath';
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; //exe id $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; //exe id
if (empty($id)) { if (empty($id)) {
@ -107,7 +107,7 @@ if (!empty($sessionId) && !$is_allowedToEdit) {
} }
$allowCoachFeedbackExercises = api_get_setting('allow_coach_feedback_exercises') === 'true'; $allowCoachFeedbackExercises = api_get_setting('allow_coach_feedback_exercises') === 'true';
$maxEditors = intval(api_get_setting('exercise_max_ckeditors_in_page')); $maxEditors = (int) api_get_setting('exercise_max_ckeditors_in_page');
$isCoachAllowedToEdit = api_is_allowed_to_edit(false, true); $isCoachAllowedToEdit = api_is_allowed_to_edit(false, true);
$isFeedbackAllowed = false; $isFeedbackAllowed = false;
@ -140,11 +140,11 @@ if (api_is_in_gradebook()) {
} }
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => "exercise.php?".api_get_cidreq(), 'url' => 'exercise.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'), 'name' => get_lang('Exercises'),
]; ];
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => "overview.php?exerciseId=".$exercise_id.'&'.api_get_cidreq(), 'url' => 'overview.php?exerciseId='.$exercise_id.'&'.api_get_cidreq(),
'name' => $objExercise->selectTitle(true), 'name' => $objExercise->selectTitle(true),
]; ];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Result')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Result')];
@ -168,11 +168,7 @@ if ($action != 'export') {
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
Display::display_header(''); Display::display_header('');
} else { } else {
$htmlHeadXtra[] = " $htmlHeadXtra[] = "<style>body { background: none; } </style>";
<style>
body { background: none;}
</style>
";
Display::display_reduced_header(); Display::display_reduced_header();
} }
@ -184,8 +180,8 @@ if ($action != 'export') {
]); ?> ]); ?>
<script> <script>
<?php echo $scoreJsCode; ?> <?php echo $scoreJsCode; ?>
var maxEditors = <?php echo $maxEditors; ?>;
var maxEditors = <?php echo intval($maxEditors); ?>;
function showfck(sid, marksid) { function showfck(sid, marksid) {
$('#' + sid).toggleClass('hidden'); $('#' + sid).toggleClass('hidden');
$('#' + marksid).toggleClass('hidden'); $('#' + marksid).toggleClass('hidden');
@ -198,7 +194,6 @@ if ($action != 'export') {
function getFCK(vals, marksid) { function getFCK(vals, marksid) {
var f = document.getElementById('myform'); var f = document.getElementById('myform');
var m_id = marksid.split(','); var m_id = marksid.split(',');
for (var i = 0; i < m_id.length; i++) { for (var i = 0; i < m_id.length; i++) {
var oHidn = document.createElement("input"); var oHidn = document.createElement("input");
@ -235,44 +230,42 @@ if (!empty($track_exercise_info)) {
// if the results_disabled of the Quiz is 1 when block the script // if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled']; $result_disabled = $track_exercise_info['results_disabled'];
if (true) { if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) { $show_results = false;
$show_results = false; } elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) { $show_results = false;
$show_results = false; $show_only_total_score = true;
$show_only_total_score = true; if ($origin != 'learnpath') {
if ($origin != 'learnpath') { if ($currentUserId == $student_id) {
if ($currentUserId == $student_id) { echo Display::return_message(
echo Display::return_message( get_lang('ThankYouForPassingTheTest'),
get_lang('ThankYouForPassingTheTest'), 'warning',
'warning', false
false );
);
}
}
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
$attempts = Event::getExerciseResultsByUser(
$currentUserId,
$objExercise->id,
api_get_course_int_id(),
api_get_session_id(),
$track_exercise_info['orig_lp_id'],
$track_exercise_info['orig_lp_item_id'],
'desc'
);
$numberAttempts = count($attempts);
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
$show_results = true;
$show_only_total_score = true;
// Attempt reach max so show score/feedback now
$showTotalScoreAndUserChoicesInLastAttempt = true;
} else {
$show_results = true;
$show_only_total_score = true;
// Last attempt not reach don't show score/feedback
$showTotalScoreAndUserChoicesInLastAttempt = false;
} }
} }
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
$attempts = Event::getExerciseResultsByUser(
$currentUserId,
$objExercise->id,
api_get_course_int_id(),
api_get_session_id(),
$track_exercise_info['orig_lp_id'],
$track_exercise_info['orig_lp_item_id'],
'desc'
);
$numberAttempts = count($attempts);
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
$show_results = true;
$show_only_total_score = true;
// Attempt reach max so show score/feedback now
$showTotalScoreAndUserChoicesInLastAttempt = true;
} else {
$show_results = true;
$show_only_total_score = true;
// Last attempt not reach don't show score/feedback
$showTotalScoreAndUserChoicesInLastAttempt = false;
}
} }
} else { } else {
echo Display::return_message(get_lang('CantViewResults'), 'warning'); echo Display::return_message(get_lang('CantViewResults'), 'warning');
@ -328,7 +321,6 @@ $sql = "SELECT attempts.question_id, answer
$result = Database::query($sql); $result = Database::query($sql);
$question_list_from_database = []; $question_list_from_database = [];
$exerciseResult = []; $exerciseResult = [];
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$question_list_from_database[] = $row['question_id']; $question_list_from_database[] = $row['question_id'];
$exerciseResult[$row['question_id']] = $row['answer']; $exerciseResult[$row['question_id']] = $row['answer'];
@ -352,7 +344,7 @@ if (!empty($track_exercise_info['data_tracking'])) {
// Display the text when finished message if we are on a LP #4227 // Display the text when finished message if we are on a LP #4227
$end_of_message = $objExercise->selectTextWhenFinished(); $end_of_message = $objExercise->selectTextWhenFinished();
if (!empty($end_of_message) && ($origin == 'learnpath')) { if (!empty($end_of_message) && ($origin === 'learnpath')) {
echo Display::return_message($end_of_message, 'normal', false); echo Display::return_message($end_of_message, 'normal', false);
echo "<div class='clear'>&nbsp;</div>"; echo "<div class='clear'>&nbsp;</div>";
} }
@ -436,8 +428,8 @@ foreach ($questionList as $questionId) {
break; break;
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY: case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
$choiceTmp = []; $choiceTmp = [];
$choiceTmp["choice"] = $choice; $choiceTmp['choice'] = $choice;
$choiceTmp["choiceDegreeCertainty"] = $choiceDegreeCertainty; $choiceTmp['choiceDegreeCertainty'] = $choiceDegreeCertainty;
$questionResult = $objExercise->manage_answer( $questionResult = $objExercise->manage_answer(
$id, $id,
@ -456,7 +448,7 @@ foreach ($questionList as $questionId) {
case HOT_SPOT: case HOT_SPOT:
if ($show_results || $showTotalScoreAndUserChoicesInLastAttempt) { if ($show_results || $showTotalScoreAndUserChoicesInLastAttempt) {
echo '<table width="500" border="0"><tr> echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" > <td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">'; <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
} }
$question_result = $objExercise->manage_answer( $question_result = $objExercise->manage_answer(
@ -723,8 +715,8 @@ foreach ($questionList as $questionId) {
$marksname = ''; $marksname = '';
if ($isFeedbackAllowed && $action != 'export') { if ($isFeedbackAllowed && $action != 'export') {
$name = "fckdiv".$questionId; $name = 'fckdiv'.$questionId;
$marksname = "marksName".$questionId; $marksname = 'marksName'.$questionId;
if (in_array($answerType, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) { if (in_array($answerType, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) {
$url_name = get_lang('EditCommentsAndMarks'); $url_name = get_lang('EditCommentsAndMarks');
} else { } else {
@ -790,7 +782,6 @@ foreach ($questionList as $questionId) {
echo ExerciseLib::getOralFeedbackForm($id, $questionId, $student_id); echo ExerciseLib::getOralFeedbackForm($id, $questionId, $student_id);
echo '</div>'; echo '</div>';
} }
echo '</div>'; echo '</div>';
} else { } else {
$comnt = Event::get_comments($id, $questionId); $comnt = Event::get_comments($id, $questionId);

Loading…
Cancel
Save