|
|
|
|
@ -4405,9 +4405,13 @@ EOT; |
|
|
|
|
$remainingMessage = '' |
|
|
|
|
) { |
|
|
|
|
$origin = api_get_origin(); |
|
|
|
|
$courseCode = api_get_course_id(); |
|
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
|
|
|
|
|
|
// Getting attempt info |
|
|
|
|
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId); |
|
|
|
|
$studentInfo = api_get_user_info($exercise_stat_info['exe_user_id']); |
|
|
|
|
|
|
|
|
|
// Getting question list |
|
|
|
|
$question_list = []; |
|
|
|
|
@ -4521,11 +4525,10 @@ EOT; |
|
|
|
|
|
|
|
|
|
if (($show_results || $show_only_score) && $origin !== 'embeddable') { |
|
|
|
|
if (isset($exercise_stat_info['exe_user_id'])) { |
|
|
|
|
$user_info = api_get_user_info($exercise_stat_info['exe_user_id']); |
|
|
|
|
if ($user_info) { |
|
|
|
|
if ($studentInfo) { |
|
|
|
|
// Shows exercise header |
|
|
|
|
echo $objExercise->showExerciseResultHeader( |
|
|
|
|
$user_info, |
|
|
|
|
$studentInfo, |
|
|
|
|
$exercise_stat_info |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
@ -4737,6 +4740,8 @@ EOT; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalScoreText = null; |
|
|
|
|
$certificateBlock = ''; |
|
|
|
|
|
|
|
|
|
if (($show_results || $show_only_score) && $showTotalScore) { |
|
|
|
|
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { |
|
|
|
|
echo '<h1 style="text-align : center; margin : 20px 0;">'.get_lang('YourResults').'</h1><br />'; |
|
|
|
|
@ -4770,6 +4775,15 @@ EOT; |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$totalScoreText .= '</div>'; |
|
|
|
|
|
|
|
|
|
$certificateBlock = self::generateAndShowCertificateBlock( |
|
|
|
|
$total_score, |
|
|
|
|
$total_weight, |
|
|
|
|
$objExercise, |
|
|
|
|
$studentInfo['id'], |
|
|
|
|
$courseCode, |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { |
|
|
|
|
@ -4804,6 +4818,7 @@ EOT; |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
echo $totalScoreText; |
|
|
|
|
echo $certificateBlock; |
|
|
|
|
|
|
|
|
|
// Ofaj change BT#11784 |
|
|
|
|
if (api_get_configuration_value('quiz_show_description_on_results_page') && |
|
|
|
|
@ -5393,4 +5408,70 @@ EOT; |
|
|
|
|
|
|
|
|
|
return $countAll === $countOfAllowed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generate a certificate linked to current quiz and. |
|
|
|
|
* Return the HTML block with links to download and view the certificate. |
|
|
|
|
* |
|
|
|
|
* @param float $totalScore |
|
|
|
|
* @param float $totalWeight |
|
|
|
|
* @param Exercise $objExercise |
|
|
|
|
* @param int $studentId |
|
|
|
|
* @param string $courseCode |
|
|
|
|
* @param int $sessionId |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function generateAndShowCertificateBlock( |
|
|
|
|
$totalScore, |
|
|
|
|
$totalWeight, |
|
|
|
|
Exercise $objExercise, |
|
|
|
|
$studentId, |
|
|
|
|
$courseCode, |
|
|
|
|
$sessionId = 0 |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
if (!api_get_configuration_value('quiz_generate_certificate_ending') || |
|
|
|
|
!self::isSuccessExerciseResult($totalScore, $totalWeight, $objExercise->selectPassPercentage()) |
|
|
|
|
) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @var Category $category */ |
|
|
|
|
$category = Category::load(null, null, $courseCode, null, null, $sessionId, 'ORDER By id'); |
|
|
|
|
|
|
|
|
|
if (empty($category)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @var Category $category */ |
|
|
|
|
$category = $category[0]; |
|
|
|
|
$categoryId = $category->get_id(); |
|
|
|
|
$link = LinkFactory::load( |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$objExercise->selectId(), |
|
|
|
|
null, |
|
|
|
|
$courseCode, |
|
|
|
|
$categoryId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($link)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$resourceDeletedMessage = $category->show_message_resource_delete($courseCode); |
|
|
|
|
|
|
|
|
|
if (false !== $resourceDeletedMessage || api_is_allowed_to_edit() || api_is_excluded_user_type()) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$certificate = Category::generateUserCertificate($categoryId, $studentId); |
|
|
|
|
|
|
|
|
|
if (!is_array($certificate)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Category::getDownloadCertificateBlock($certificate); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|