Skip to content

Commit

Permalink
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ywarnier committed Oct 29, 2024
2 parents 23d2100 + 8ff67c3 commit 896b085
Show file tree
Hide file tree
Showing 49 changed files with 3,482 additions and 15 deletions.
2 changes: 2 additions & 0 deletions main/exercise/exercise_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@
'comparative_group_report.php?'.api_get_cidreq().'&id='.$exercise_id,
['class' => 'btn btn-default']
);

$actions .= ExerciseFocusedPlugin::create()->getLinkReporting($exercise_id);
}
} else {
$actions .= '<a href="exercise.php">'.
Expand Down
12 changes: 4 additions & 8 deletions main/glossary/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ function sorter($item1, $item2)
$form->addHtmlEditor(
'name',
get_lang('TermName'),
false,
true,
false,
['ToolbarSet' => 'TitleAsHtml']
);
} else {
$form->addElement('text', 'name', get_lang('TermName'), ['id' => 'glossary_title']);
$form->addText('name', get_lang('TermName'), true, ['id' => 'glossary_title']);
}

$form->addHtmlEditor(
Expand All @@ -107,7 +107,6 @@ function sorter($item1, $item2)
);
$form->addButtonCreate(get_lang('TermAddButton'), 'SubmitGlossary');
// setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
Expand Down Expand Up @@ -154,12 +153,12 @@ function sorter($item1, $item2)
$form->addHtmlEditor(
'name',
get_lang('TermName'),
false,
true,
false,
['ToolbarSet' => 'TitleAsHtml']
);
} else {
$form->addElement('text', 'name', get_lang('TermName'), ['id' => 'glossary_title']);
$form->addText('name', get_lang('TermName'), true, ['id' => 'glossary_title']);
}

$form->addHtmlEditor(
Expand Down Expand Up @@ -192,9 +191,6 @@ function sorter($item1, $item2)
$form->addButtonUpdate(get_lang('TermUpdateButton'), 'SubmitGlossary');
$form->setDefaults($glossary_data);

// setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');

// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
Expand Down
Binary file added main/img/icons/22/webcam_na.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions main/inc/lib/TrackingCourseLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ public static function getItemResourcesData($from, $numberOfItems, $column, $dir
$row[4] = $ip;
}

$row[5] = Security::remove_XSS($row[5]);

$resources[] = $row;
}
}
Expand Down
10 changes: 3 additions & 7 deletions main/inc/lib/formvalidator/FormValidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2102,14 +2102,10 @@ function plain_url_filter($html, $mode = NO_HTML)

/**
* Prevent execution of event handlers in HTML elements.
*
* @param string $html
*
* @return string
*/
function attr_on_filter($html)
function attr_on_filter(string $html): string
{
$prefix = uniqid('data-cke-').'-';
$pattern = '/\s*on\w+=(?:"[^"]*"|\'[^\']*\'|[^\s>]+)/i';

return preg_replace('/\b(on[a-z]+)\b\s*=/i', '$1'.$prefix.'$2', $html);
return preg_replace($pattern, '', $html);
}
32 changes: 32 additions & 0 deletions plugin/exercisefocused/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/* For licensing terms, see /license.txt */

use Chamilo\PluginBundle\ExerciseFocused\Controller\AdminController;
use Chamilo\PluginBundle\ExerciseFocused\Entity\Log;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Symfony\Component\HttpFoundation\Response as HttpResponse;

$cidReset = true;

require_once __DIR__.'/../../main/inc/global.inc.php';

api_protect_admin_script();

$em = Database::getManager();
$logRepository = $em->getRepository(Log::class);

$reportingController = new AdminController(
ExerciseFocusedPlugin::create(),
HttpRequest::createFromGlobals(),
$em,
$logRepository
);

try {
$response = $reportingController();
} catch (Exception $e) {
$response = HttpResponse::create('', HttpResponse::HTTP_FORBIDDEN);
}

$response->send();
48 changes: 48 additions & 0 deletions plugin/exercisefocused/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/* For licensing terms, see /license.txt */

use Chamilo\CoreBundle\Entity\TrackEExercises;
use Chamilo\PluginBundle\ExerciseFocused\Entity\Log;

$plugin = ExerciseFocusedPlugin::create();

$exerciseId = (int) ($_GET['exerciseId'] ?? 0);

$renderRegion = $plugin->isEnableForExercise($exerciseId);

if ($renderRegion) {
$_template['show_region'] = true;

$em = Database::getManager();

$existingExeId = (int) ChamiloSession::read('exe_id');
$trackingExercise = null;

if ($existingExeId) {
$trackingExercise = $em->find(TrackEExercises::class, $existingExeId);
}

$_template['sec_token'] = Security::get_token('exercisefocused');

if ('true' === $plugin->get(ExerciseFocusedPlugin::SETTING_ENABLE_OUTFOCUSED_LIMIT)) {
$logRepository = $em->getRepository(Log::class);

if ($trackingExercise) {
$countOutfocused = $logRepository->countByActionInExe($trackingExercise, Log::TYPE_OUTFOCUSED);
} else {
$countOutfocused = 0;
}

$_template['count_outfocused'] = $countOutfocused;
$_template['remaining_outfocused'] = (int) $plugin->get(ExerciseFocusedPlugin::SETTING_OUTFOCUSED_LIMIT) - $countOutfocused;
}

if ($trackingExercise) {
$exercise = new Exercise($trackingExercise->getCId());

if ($exercise->read($trackingExercise->getExeExoId())) {
$_template['exercise_type'] = (int) $exercise->selectType();
}
}
}
5 changes: 5 additions & 0 deletions plugin/exercisefocused/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

/* For licensing terms, see /license.txt */

ExerciseFocusedPlugin::create()->install();
39 changes: 39 additions & 0 deletions plugin/exercisefocused/lang/english.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/* For licensing terms, see /license.txt */

$strings['plugin_title'] = "Exercise Focused";
$strings['plugin_comment'] = "Show a message to return to the exercise when the user exits the Chamilo window/tab.";

$strings['tool_enable'] = "Enable tool";
$strings['enable_time_limit'] = 'Enable time limit';
$strings['time_limit'] = "Limit time";
$strings['time_limit_help'] = "Limit time (in seconds) to return to the exercise. After this time the exercise will be closed.";
$strings['enable_outfocused_limit'] = "Enable maximum of outfocused";
$strings['outfocused_limit'] = "Maximum number of outfocused allowed";
$strings['outfocused_limit_help'] = "Number of outfocused allowed. After this limit the exercise will be closed.";
$strings['session_field_filters'] = "Session field as filter";
$strings['session_field_filters_help'] = "Extra field names separeted by a comma.";
$strings['percentage_sampling'] = "Percentage of sampling attempts";
$strings['percentage_sampling_help'] = "A percentage of attempts will be selected for random review";

$strings['ReportByAttempts'] = "Exercise focused: Report by attempts";
$strings['YouHaveLeftTheExercise'] = "Careful! We detect that you have left the exam window.<br><br>You must return and complete it.";
$strings['YouHaveXTimeToReturn'] = "You have <span class=\"h3 text-danger\" id=\"time-limit-target\">%s</span> seconds to return";
$strings['YouAreAllowedXOutfocused'] = "You are allowed <span class=\"h3 text-danger\" id=\"outfocused-limit-target\">%d</span> outfocused";
$strings['OutfocusedLimitExceeded'] = "You have exceeded the allowed limit of outfocused";
$strings['SelectExercise'] = "Select exercise";
$strings['UnselectExercise'] = "Unselect exercise";
$strings['Returns'] = "Returns";
$strings['MaxOutfocusedReached'] = "Max outfocused reached";
$strings['TimeLimitReached'] = "Time limit reached";
$strings['Outfocused'] = "Outfocused";
$strings['Return'] = "Return";
$strings['Motive'] = "Motive";
$strings['AlertBeforeLeaving'] = "Please stay within the exam";
$strings['RandomSampling'] = "Random sampling";
$strings['WindowTitleOutfocused'] = '🚨 Stay within the exam!';
$strings['LevelReached'] = 'Level reached';
$strings['ExerciseStartDateAndTime'] = "Exercise start date and time";
$strings['ExerciseEndDateAndTime'] = "Exercise end date and time";
$strings['MotiveExerciseFinished'] = "Successfully completed the exam";
39 changes: 39 additions & 0 deletions plugin/exercisefocused/lang/spanish.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/* For licensing terms, see /license.txt */

$strings['plugin_title'] = "Enfoque en el Ejercicio";
$strings['plugin_comment'] = "Mostrar un mensaje para regresar al ejercicio cuando el usuario sale de la ventana/pestaña de Chamilo.";

$strings['tool_enable'] = "Habilitar herramienta";
$strings['enable_time_limit'] = 'Habilitar límite de tiempo';
$strings['time_limit'] = "Límite de tiempo";
$strings['time_limit_help'] = "Límite el tiempo (en segundos) para regresar al ejercicio. Pasado este tiempo, el ejercicio se cerrará.";
$strings['enable_outfocused_limit'] = "Habilitar el máximo de desenfoque";
$strings['outfocused_limit'] = "Número máximo de desenfoques permitidos";
$strings['outfocused_limit_help'] = "Número de desenfoques permitidos. Después de este límite, el ejercicio se cerrará.";
$strings['session_field_filters'] = "Campo de sesión como filtro";
$strings['session_field_filters_help'] = "Nombres de campos adicionales separados por comas.";
$strings['percentage_sampling'] = "Porcentaje de intentos de muestreo";
$strings['percentage_sampling_help'] = "Se seleccionará un porcentaje de intentos para una revisión aleatoria";

$strings['ReportByAttempts'] = "Enfoque en el Ejercicio: Informe por intentos";
$strings['YouHaveLeftTheExercise'] = "¡Cuidado! Detectamos que has abandonado la ventana del examen.<br><br>Debes retornar y culminarlo.";
$strings['YouHaveXTimeToReturn'] = "Tienes <span class=\"h3 text-danger\" id=\"time-limit-target\">%s</span> segundos para regresar";
$strings['YouAreAllowedXOutfocused'] = "Se te permite <span class=\"h3 text-danger\" id=\"outfocused-limit-target\">%d</span> desenfoques";
$strings['OutfocusedLimitExceeded'] = "Has excedido el límite permitido de desenfoques";
$strings['SelectExercise'] = "Seleccionar ejercicio";
$strings['UnselectExercise'] = "Deseleccionar ejercicio";
$strings['Returns'] = "Regresos";
$strings['MaxOutfocusedReached'] = "Se ha alcanzado el máximo de desenfoques";
$strings['TimeLimitReached'] = "Se ha alcanzado el límite de tiempo";
$strings['Outfocused'] = "Desenfoques";
$strings['Return'] = "Regresos";
$strings['Motive'] = "Motivo";
$strings['AlertBeforeLeaving'] = "Por favor, mantente dentro del examen.";
$strings['RandomSampling'] = "Muestreo Aleatorio";
$strings['WindowTitleOutfocused'] = '🚨 Retorna y culmina tu examen';
$strings['LevelReached'] = 'Nivel alcanzado';
$strings['ExerciseStartDateAndTime'] = "Fecha y hora de inicio del ejercicio";
$strings['ExerciseEndDateAndTime'] = "Fecha y hora de finalización del ejercicio";
$strings['MotiveExerciseFinished'] = "Culminó exitosamente el examen";
32 changes: 32 additions & 0 deletions plugin/exercisefocused/pages/detail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/* For licensing terms, see /license.txt */

use Chamilo\PluginBundle\ExerciseFocused\Controller\DetailController;
use Chamilo\PluginBundle\ExerciseFocused\Entity\Log;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Symfony\Component\HttpFoundation\Response as HttpResponse;

require_once __DIR__.'/../../../main/inc/global.inc.php';

if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}

$em = Database::getManager();
$logRepository = $em->getRepository(Log::class);

$detailController = new DetailController(
ExerciseFocusedPlugin::create(),
HttpRequest::createFromGlobals(),
$em,
$logRepository
);

try {
$response = $detailController();
} catch (Exception $e) {
$response = HttpResponse::create('', HttpResponse::HTTP_FORBIDDEN);
}

$response->send();
Loading

0 comments on commit 896b085

Please sign in to comment.