Minor - Format code - refs #8237

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent dfaa4f873d
commit 3709d59641
  1. 379
      main/exercice/exercise_show.php

@ -16,7 +16,7 @@ use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$debug = false;
if (empty($origin) ) {
if (empty($origin)) {
$origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
}
@ -33,18 +33,40 @@ $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERC
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
// General parameters passed via POST/GET
if ($debug) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
if (empty($formSent)) { $formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null; }
if (empty($exerciseResult)) { $exerciseResult = isset($_SESSION['exerciseResult']) ? $_SESSION['exerciseResult'] : null; }
if (empty($questionId)) { $questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;}
if (empty($choice)) { $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;}
if (empty($questionNum)) { $questionNum = isset($_REQUEST['num']) ? $_REQUEST['num'] : null;}
if (empty($nbrQuestions)) { $nbrQuestions = isset($_REQUEST['nbrQuestions']) ? $_REQUEST['nbrQuestions'] : null;}
if (empty($questionList)) { $questionList = isset($_SESSION['questionList']) ? $_SESSION['questionList'] : null;}
if (empty($objExercise)) { $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;}
if (empty($exeId)) { $exeId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;}
if (empty($action)) { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;}
if ($debug) {
error_log('Entered exercise_result.php: ' . print_r($_POST, 1));
}
if (empty($formSent)) {
$formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null;
}
if (empty($exerciseResult)) {
$exerciseResult = isset($_SESSION['exerciseResult']) ? $_SESSION['exerciseResult'] : null;
}
if (empty($questionId)) {
$questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;
}
if (empty($choice)) {
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
}
if (empty($questionNum)) {
$questionNum = isset($_REQUEST['num']) ? $_REQUEST['num'] : null;
}
if (empty($nbrQuestions)) {
$nbrQuestions = isset($_REQUEST['nbrQuestions']) ? $_REQUEST['nbrQuestions'] : null;
}
if (empty($questionList)) {
$questionList = isset($_SESSION['questionList']) ? $_SESSION['questionList'] : null;
}
if (empty($objExercise)) {
$objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
}
if (empty($exeId)) {
$exeId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
}
if (empty($action)) {
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
}
$id = intval($_REQUEST['id']); //exe id
@ -105,18 +127,18 @@ if (!$is_allowedToEdit) {
}
if (isset($_SESSION['gradebook'])) {
$gradebook= Security::remove_XSS($_SESSION['gradebook']);
$gradebook = Security::remove_XSS($_SESSION['gradebook']);
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook'));
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
}
$fromlink = '';
$interbreadcrumb[]= array("url" => "exercise.php?".api_get_cidreq(),"name" => get_lang('Exercises'));
$interbreadcrumb[]= array("url" => "overview.php?exerciseId=".$exercise_id.'&'.api_get_cidreq(),"name" => $objExercise->name);
$interbreadcrumb[]= array("url" => "#","name" => get_lang('Result'));
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
$interbreadcrumb[] = array("url" => "overview.php?exerciseId=" . $exercise_id . '&' . api_get_cidreq(), "name" => $objExercise->name);
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result'));
$this_section = SECTION_COURSES;
@ -134,34 +156,34 @@ if ($origin != 'learnpath') {
Display::display_reduced_header();
}
?>
<script>
var maxEditors = <?php echo intval($maxEditors); ?>;
<script>
var maxEditors = <?php echo intval($maxEditors); ?>;
function showfck(sid,marksid) {
document.getElementById(sid).style.display='block';
document.getElementById(marksid).style.display='block';
var comment = 'feedback_'+sid;
document.getElementById(comment).style.display='none';
}
function showfck(sid, marksid) {
document.getElementById(sid).style.display = 'block';
document.getElementById(marksid).style.display = 'block';
var comment = 'feedback_' + sid;
document.getElementById(comment).style.display = 'none';
}
function getFCK(vals,marksid) {
var f=document.getElementById('myform');
function getFCK(vals, marksid) {
var f = document.getElementById('myform');
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");
oHidn.type = "hidden";
var selname = oHidn.name = "marks_"+m_id[i];
var selid = document.forms['marksform_'+m_id[i]].marks.selectedIndex;
oHidn.value = document.forms['marksform_'+m_id[i]].marks.options[selid].text;
var selname = oHidn.name = "marks_" + m_id[i];
var selid = document.forms['marksform_' + m_id[i]].marks.selectedIndex;
oHidn.value = document.forms['marksform_' + m_id[i]].marks.options[selid].text;
f.appendChild(oHidn);
}
var ids = vals.split(',');
for(var k=0;k<ids.length;k++){
for (var k = 0; k < ids.length; k++) {
var oHidden = document.createElement("input");
oHidden.type = "hidden";
oHidden.name = "comments_"+ids[k];
oHidden.name = "comments_" + ids[k];
if (CKEDITOR.instances[oHidden.name]) {
oHidden.value = CKEDITOR.instances[oHidden.name].getData();
} else {
@ -169,8 +191,8 @@ function getFCK(vals,marksid) {
}
f.appendChild(oHidden);
}
}
</script>
}
</script>
<?php
$show_results = true;
$show_only_total_score = false;
@ -190,7 +212,7 @@ if (!empty($track_exercise_info)) {
<tr>
<td colspan="2">';
Display::display_warning_message(
get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercise.php">'.(get_lang('BackToExercisesList')).'</a>',
get_lang('ThankYouForPassingTheTest') . '<br /><br /><a href="exercise.php">' . (get_lang('BackToExercisesList')) . '</a>',
false
);
echo '</td>
@ -236,7 +258,7 @@ if (!empty($track_exercise_info)) {
$show_results = false;
}
if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
if ($origin == 'learnpath' && !isset($_GET['fb_type'])) {
$show_results = false;
}
@ -254,29 +276,29 @@ if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
$i = $totalScore = $totalWeighting = 0;
if ($debug > 0) {
error_log("ExerciseResult: ".print_r($exerciseResult, 1));
error_log("QuestionList: ".print_r($questionList, 1));
error_log("ExerciseResult: " . print_r($exerciseResult, 1));
error_log("QuestionList: " . print_r($questionList, 1));
}
$arrques = array();
$arrans = array();
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." ";
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=" . intval($student_id) . " ";
$sql = "SELECT attempts.question_id, answer
FROM $TBL_TRACK_ATTEMPT as attempts
INNER JOIN ".$TBL_TRACK_EXERCISES." AS stats_exercises
INNER JOIN " . $TBL_TRACK_EXERCISES . " AS stats_exercises
ON stats_exercises.exe_id=attempts.exe_id
INNER JOIN $TBL_EXERCISE_QUESTION AS quizz_rel_questions
ON
quizz_rel_questions.exercice_id=stats_exercises.exe_exo_id AND
quizz_rel_questions.question_id = attempts.question_id AND
quizz_rel_questions.c_id=".api_get_course_int_id()."
INNER JOIN ".$TBL_QUESTIONS." AS questions
quizz_rel_questions.c_id=" . api_get_course_int_id() . "
INNER JOIN " . $TBL_QUESTIONS . " AS questions
ON
questions.id=quizz_rel_questions.question_id AND
questions.c_id = ".api_get_course_int_id()."
questions.c_id = " . api_get_course_int_id() . "
WHERE
attempts.exe_id = ".intval($id)." $user_restriction
attempts.exe_id = " . intval($id) . " $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
$result = Database::query($sql);
@ -316,7 +338,7 @@ if (!empty($end_of_message) && ($origin == 'learnpath')) {
$total_weighting = 0;
foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId);
$total_weighting +=$objQuestionTmp->selectWeighting();
$total_weighting += $objQuestionTmp->selectWeighting();
}
$counter = 1;
@ -330,7 +352,6 @@ if (!empty($maxEditors) && count($questionList) > $maxEditors) {
}
foreach ($questionList as $questionId) {
$choice = $exerciseResult[$questionId];
// destruction of the Question object
unset($objQuestionTmp);
@ -343,9 +364,10 @@ foreach ($questionList as $questionId) {
// Start buffer
ob_start();
// Use switch
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
switch ($answerType) {
case MULTIPLE_ANSWER:
//no break
case MULTIPLE_ANSWER_TRUE_FALSE:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -361,7 +383,10 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
break;
case MULTIPLE_ANSWER_COMBINATION:
//no break
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
$choice = array();
$question_result = $objExercise->manage_answer(
$id,
@ -378,7 +403,10 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
break;
case UNIQUE_ANSWER:
//no break;
case UNIQUE_ANSWER_NO_OPTION:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -395,7 +423,8 @@ foreach ($questionList as $questionId) {
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
echo '</table>';
} elseif ($answerType == FILL_IN_BLANKS) {
break;
case FILL_IN_BLANKS:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -411,7 +440,8 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) {
break;
case GLOBAL_MULTIPLE_ANSWER:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -427,7 +457,8 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == FREE_ANSWER) {
break;
case FREE_ANSWER:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -443,7 +474,8 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == ORAL_EXPRESSION) {
break;
case ORAL_EXPRESSION:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -459,7 +491,12 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
break;
case MATCHING:
//no break
case DRAGGABLE:
//no break
case MATCHING_DRAGGABLE:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -475,7 +512,8 @@ foreach ($questionList as $questionId) {
);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
break;
case HOT_SPOT:
if ($show_results || $showTotalScoreAndUserChoices) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
@ -521,8 +559,8 @@ foreach ($questionList as $questionId) {
<br>
";
}
} else if($answerType == HOT_SPOT_DELINEATION) {
break;
case HOT_SPOT_DELINEATION:
$question_result = $objExercise->manage_answer(
$id,
$questionId,
@ -556,20 +594,20 @@ foreach ($questionList as $questionId) {
if ($show_results) {
if ($overlap_color) {
$overlap_color='green';
$overlap_color = 'green';
} else {
$overlap_color='red';
$overlap_color = 'red';
}
if ($missing_color) {
$missing_color='green';
$missing_color = 'green';
} else {
$missing_color='red';
$missing_color = 'red';
}
if ($excess_color) {
$excess_color='green';
$excess_color = 'green';
} else {
$excess_color='red';
$excess_color = 'red';
}
if (!is_numeric($final_overlap)) {
@ -583,77 +621,77 @@ foreach ($questionList as $questionId) {
$final_excess = 0;
}
if ($final_excess>100) {
if ($final_excess > 100) {
$final_excess = 100;
}
$table_resume='<table class="data_table">
$table_resume = '<table class="data_table">
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
<td><b>'.get_lang('YourAnswer').'</b></td>
<td ><b>' . get_lang('Requirements') . '</b></td>
<td><b>' . get_lang('YourAnswer') . '</b></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Overlap').'</b></td>
<td>'.get_lang('Min').' '.$threadhold1.'</td>
<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
<td><b>' . get_lang('Overlap') . '</b></td>
<td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
<td><div style="color:' . $overlap_color . '">' . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
</tr>
<tr>
<td><b>'.get_lang('Excess').'</b></td>
<td>'.get_lang('Max').' '.$threadhold2.'</td>
<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
<td><b>' . get_lang('Excess') . '</b></td>
<td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
<td><div style="color:' . $excess_color . '">' . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
<td><b>' . get_lang('Missing') . '</b></td>
<td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
<td><div style="color:' . $missing_color . '">' . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
</tr></table>';
if ($answerType!= HOT_SPOT_DELINEATION) {
$item_list = explode('@@',$destination);
if ($answerType != HOT_SPOT_DELINEATION) {
$item_list = explode('@@', $destination);
$try = $item_list[0];
$lp = $item_list[1];
$destinationid = $item_list[2];
$url = $item_list[3];
$table_resume='';
$table_resume = '';
} else {
if ($next==0) {
if ($next == 0) {
$try = $try_hotspot;
$lp = $lp_hotspot;
$destinationid= $select_question_hotspot;
$url=$url_hotspot;
$destinationid = $select_question_hotspot;
$url = $url_hotspot;
} else {
//show if no error
$comment=$answerComment = $objAnswerTmp->selectComment($nbrAnswers);
$comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
$answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
}
}
echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit > 0) {
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
$message = '<br />' . get_lang('ResultIs') . ' <b>' . $result_comment . '</b><br />';
$message .= '<p style="color:#DC0A0A;"><b>' . get_lang('OARHit') . '</b></p>';
} else {
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message = '<p>' . get_lang('YourDelineation') . '</p>';
$message .= $table_resume;
$message .= '<br />' . get_lang('ResultIs') . ' <b>' . $result_comment . '</b><br />';
}
$message.='<p>'.$comment.'</p>';
$message .= '<p>' . $comment . '</p>';
echo $message;
} else {
echo '<p>'.$comment.'</p>';
echo '<p>' . $comment . '</p>';
}
//showing the score
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." WHERE exe_id = ".intval($id)." and question_id= ".intval($questionId)."";
$queryfree = "select marks from " . $TBL_TRACK_ATTEMPT . " WHERE exe_id = " . intval($id) . " and question_id= " . intval($questionId) . "";
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;
$questionScore = Database::result($resfree, 0, "marks");
$totalScore += $questionScore;
$relPath = api_get_path(REL_PATH);
echo '</table></td></tr>';
@ -677,13 +715,12 @@ foreach ($questionList as $questionId) {
</table>
";
}
break;
}
if ($show_results) {
if ($answerType != HOT_SPOT) {
if ($show_results && $answerType != HOT_SPOT) {
echo '</table>';
}
}
$comnt = null;
@ -703,39 +740,39 @@ foreach ($questionList as $questionId) {
$marksname = '';
if ($isFeedbackAllowed) {
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
$name = "fckdiv" . $questionId;
$marksname = "marksName" . $questionId;
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
$url_name = get_lang('EditCommentsAndMarks');
} else {
if ($action=='edit') {
if ($action == 'edit') {
$url_name = get_lang('EditIndividualComment');
} else {
$url_name = get_lang('AddComments');
}
}
echo '<br />';
echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick'=>"showfck('".$name."', '".$marksname."');"));
echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick' => "showfck('" . $name . "', '" . $marksname . "');"));
echo '<br />';
echo '<div id="feedback_'.$name.'" style="width:100%">';
echo '<div id="feedback_' . $name . '" style="width:100%">';
$comnt = trim(Event::get_comments($id, $questionId));
if (empty($comnt)) {
echo '<br />';
} else {
echo '<div id="question_feedback">'.$comnt.'</div>';
echo '<div id="question_feedback">' . $comnt . '</div>';
}
echo '</div>';
echo '<div id="'.$name.'" style="display:none">';
echo '<div id="' . $name . '" style="display:none">';
$arrid[] = $questionId;
$feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
$feedback_form->addElement('html','<br>');
$feedback_form = new FormValidator('frmcomments' . $questionId, 'post', '');
$feedback_form->addElement('html', '<br>');
$renderer =& $feedback_form->defaultRenderer();
$renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
$renderer->setCustomElementTemplate('<div align="left">{element}</div>');
$comnt = Event::get_comments($id, $questionId);
$default = array('comments_'.$questionId => $comnt);
$default = array('comments_' . $questionId => $comnt);
if ($useAdvancedEditor) {
$feedback_form->addElement(
@ -752,7 +789,7 @@ foreach ($questionList as $questionId) {
} else {
$feedback_form->addElement('textarea', 'comments_' . $questionId);
}
$feedback_form->addElement('html','<br>');
$feedback_form->addElement('html', '<br>');
$feedback_form->setDefaults($default);
$feedback_form->display();
echo '</div>';
@ -761,33 +798,33 @@ foreach ($questionList as $questionId) {
$comnt = Event::get_comments($id, $questionId);
echo '<br />';
if (!empty($comnt)) {
echo '<b>'.get_lang('Feedback').'</b>';
echo '<div id="question_feedback">'.$comnt.'</div>';
echo '<b>' . get_lang('Feedback') . '</b>';
echo '<div id="question_feedback">' . $comnt . '</div>';
}
}
if ($is_allowedToEdit && $isFeedbackAllowed) {
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
$marksname = "marksName".$questionId;
echo '<div id="'.$marksname.'" style="display:none">';
echo '<form name="marksform_'.$questionId.'" method="post" action="">';
$marksname = "marksName" . $questionId;
echo '<div id="' . $marksname . '" style="display:none">';
echo '<form name="marksform_' . $questionId . '" method="post" action="">';
$arrmarks[] = $questionId;
echo get_lang("AssignMarks");
echo "&nbsp;<select name='marks' id='marks'>";
for ($i=0;$i<=$questionWeighting;$i++) {
echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>';
for ($i = 0; $i <= $questionWeighting; $i++) {
echo '<option ' . (($i == $questionScore) ? "selected='selected'" : '') . '>' . $i . '</option>';
}
echo '</select>';
echo '</form><br /></div>';
if ($questionScore == -1 ) {
if ($questionScore == -1) {
$questionScore = 0;
echo Display::return_message(get_lang('notCorrectedYet'));
}
} else {
$arrmarks[] = $questionId;
echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action="">
<select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>';
echo '<div id="' . $marksname . '" style="display:none"><form name="marksform_' . $questionId . '" method="post" action="">
<select name="marks" id="marks" style="display:none;"><option>' . $questionScore . '</option></select></form><br/ ></div>';
}
} else {
if ($questionScore == -1) {
@ -816,7 +853,7 @@ foreach ($questionList as $questionId) {
}
if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
foreach($objQuestionTmp->category_list as $category_id) {
foreach ($objQuestionTmp->category_list as $category_id) {
$category_list[$category_id]['score'] += $my_total_score;
$category_list[$category_id]['total'] += $my_total_weight;
$category_was_added_for_this_test = true;
@ -843,7 +880,12 @@ foreach ($questionList as $questionId) {
$score = array();
if ($show_results) {
$score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false);
$score['result'] = get_lang('Score') . " : " . ExerciseLib::show_score(
$my_total_score,
$my_total_weight,
false,
false
);
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['type'] = $answerType;
$score['score'] = $my_total_score;
@ -871,7 +913,7 @@ foreach ($questionList as $questionId) {
$total_score_text = null;
//Total score
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
$total_score_text .= '<div class="question_row">';
$my_total_score_temp = $totalScore;
@ -903,27 +945,49 @@ echo $total_score_text;
if ($isFeedbackAllowed) {
if (is_array($arrid) && is_array($arrmarks)) {
$strids = implode(",",$arrid);
$marksid = implode(",",$arrmarks);
$strids = implode(",", $arrid);
$marksid = implode(",", $arrmarks);
}
}
if ($isFeedbackAllowed) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">';
echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">';
echo '<input type = "hidden" name="student_id" value="'.$student_id.'">';
echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
$formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
$formUrl .= http_build_query([
'exerciseId' => $exercise_id,
'filter' => 2,
'comments' => 'update',
'exeid' => $id,
'origin' => $origin,
'details' => 'true',
'course' => Security::remove_XSS($_GET['cidReq'])
]);
$formUrl .= $fromlink;
echo '<form name="myform" id="myform" action="' . $formUrl . '" method="post">';
echo '<input type = "hidden" name="lp_item_id" value="' . $learnpath_id . '">';
echo '<input type = "hidden" name="lp_item_view_id" value="' . $lp_item_view_id . '">';
echo '<input type = "hidden" name="student_id" value="' . $student_id . '">';
echo '<input type = "hidden" name="total_score" value="' . $totalScore . '"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="' . $exercise_id . '"> ';
} else {
echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
$formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
$formUrl .= http_build_query([
'exerciseId' => $exercise_id,
'filter' => 1,
'comments' => 'update',
'exeid' => $id
]);
echo ' <form name="myform" id="myform" action="' . $formUrl . '" method="post">';
}
if ($origin !='learnpath' && $origin!='student_progress') {
echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>';
if ($origin != 'learnpath' && $origin != 'student_progress') {
echo '<label><input type= "checkbox" name="send_notification"> ' . get_lang('SendEmail') . '</label>';
?>
<br />
<button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');">
<br/>
<button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>"
onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');">
<?php echo get_lang('CorrectTest'); ?>
</button>
</form>
@ -932,16 +996,18 @@ if ($isFeedbackAllowed) {
}
//Came from lpstats in a lp
if ($origin =='student_progress') { ?>
<button type="button" class="back" onclick="window.history.go(-1);" value="<?php echo get_lang('Back'); ?>" >
<?php echo get_lang('Back');?></button>
<?php
} else if($origin=='myprogress') {
?>
<button type="button" class="save" onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id()?>'" value="<?php echo get_lang('Finish'); ?>" >
<?php echo get_lang('Finish');?>
if ($origin == 'student_progress') { ?>
<button type="button" class="back" onclick="window.history.go(-1);" value="<?php echo get_lang('Back'); ?>">
<?php echo get_lang('Back'); ?></button>
<?php
} else if ($origin == 'myprogress') {
?>
<button type="button" class="save"
onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id() ?>'"
value="<?php echo get_lang('Finish'); ?>">
<?php echo get_lang('Finish'); ?>
</button>
<?php
<?php
}
if ($origin != 'learnpath') {
@ -950,14 +1016,21 @@ if ($origin != 'learnpath') {
} else {
if (!isset($_GET['fb_type'])) {
$lp_mode = $_SESSION['lp_mode'];
$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
echo '<script type="text/javascript">'.$href.'</script>';
$url = '../newscorm/lp_controller.php?' . api_get_cidreq() . '&';
$url .= http_build_url([
'action' => 'view',
'lp_id' => $learnpath_id,
'lp_item_id' => $learnpath_item_id,
'exeId' => $exeId,
'fb_type' => $feedback_type
]);
$href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '" ';
echo '<script type="text/javascript">' . $href . '</script>';
// Record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
echo '</body></html>';
} else {
Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
Display::display_normal_message(get_lang('ExerciseFinished') . ' ' . get_lang('ToContinueUseMenu'));
echo '<br />';
}
}

Loading…
Cancel
Save