Actualización

This commit is contained in:
Xes
2025-04-10 12:36:07 +02:00
parent 1da7c3f3b9
commit 4aff98e77b
3147 changed files with 320647 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?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,
];
}
}