Files
Chamilo/plugin/whispeakauth/WhispeakMyStudentsLpTrackingHook.php
T
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

68 lines
1.8 KiB
PHP

<?php
/* For licensing terms, see /license.txt */
/**
* Class WhispeakMyStudentsLpTrackingHook.
*/
class WhispeakMyStudentsLpTrackingHook extends HookObserver implements HookMyStudentsLpTrackingObserverInterface
{
/**
* WhispeakMyStudentsLpTrackingHook constructor.
*/
protected function __construct()
{
parent::__construct(
'plugin/whispeakauth/WhispeakAuthPlugin.php',
'whispeakauth'
);
}
/**
* @return array
*/
public function trackingHeader(HookMyStudentsLpTrackingEventInterface $hook)
{
if (false === WhispeakAuthPlugin::create()->isEnabled()) {
return [];
}
return [
'value' => WhispeakAuthPlugin::create()->get_lang('plugin_title'),
'attrs' => ['class' => 'text-center'],
];
}
/**
* @throws \Doctrine\ORM\Query\QueryException
*
* @return array
*/
public function trackingContent(HookMyStudentsLpTrackingEventInterface $hook)
{
if (false === WhispeakAuthPlugin::create()->isEnabled()) {
return [];
}
$data = $hook->getEventData();
$totalCount = WhispeakAuthPlugin::countAllAttemptsInLearningPath($data['lp_id'], $data['student_id']);
if (0 === $totalCount) {
return [
'value' => '-',
'attrs' => ['class' => 'text-center'],
];
}
$successCount = WhispeakAuthPlugin::countSuccessAttemptsInLearningPath($data['lp_id'], $data['student_id']);
$attrs = ['class' => 'text-center '];
$attrs['class'] .= $successCount <= $totalCount / 2 ? 'text-danger' : 'text-success';
return [
'value' => Display::tag('strong', "$successCount / $totalCount"),
'attrs' => $attrs,
];
}
}