Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion main/exercise/question_pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@

$is_allowedToEdit = api_is_allowed_to_edit(null, true);

$extended = api_get_plugin_setting('extendedquestionpool', 'enable_plugin');

if ($extended == 'true') {
$query = $_SERVER['QUERY_STRING'] ?? '';
$urlDest = 'question_pool_extended.php';

if (!empty($query)) {
$urlDest .= '?' . $query;
}
header('Location: ' . $urlDest);
exit;
}

$delete = isset($_GET['delete']) ? (int) $_GET['delete'] : null;
$recup = isset($_GET['recup']) ? (int) $_GET['recup'] : null;
$fromExercise = isset($_REQUEST['fromExercise']) ? (int) $_REQUEST['fromExercise'] : null;
Expand Down Expand Up @@ -510,7 +523,15 @@ function confirm_your_choice() {
$form->addHidden('exercise_id_changed', '0');

$extraField = new ExtraField('question');
$jsForExtraFields = $extraField->addElements($form, 0, [], true);
$extendedExtraFields = array(
"additional_question_category",
"question_data1",
"question_data2",
"question_data3",
"question_extra_info"
);
$jsForExtraFields = $extraField->addElements($form, 0, $extendedExtraFields, true);


$form->addButtonFilter(get_lang('Filter'), 'name');

Expand Down
1,390 changes: 1,390 additions & 0 deletions main/exercise/question_pool_extended.php

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions plugin/extendedquestionpool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Extended Question Pool plugin
==============================
Este plugin amplía las funcionalidades del banco de preguntas.

**Instrucciones de puesta en funcionamiento**

- Habilitar el plugin en la administración de Chamilo.
- Configurar las opciones deseadas

**Accesos a la herramienta**

- Desde plugins, para configurar las opciones

**Funcionalidades que incluye**

- Mostrar el nº de preguntas total del ejercicio
- Campos extra en las preguntas para ampliar la clasificación
- Detectar preguntas ya utilizadas
- Asignar puntuaciones de preguntas de manera masiva
- Contador aciertos y fallos por preguntas
- Ordenar las preguntas por nombre, categoría, dificultad, nº de apariciones, aciertos, fallos


Credits
-------
Contributed by [Nosolored](https://www.nosolored.com/).
12 changes: 12 additions & 0 deletions plugin/extendedquestionpool/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/* For licensing terms, see /license.txt */

/**
* Config the plugin.
*
* @package chamilo.plugin.extended_question_pool
*
* @author NoSoloRed <desarrollo@nosolored.com>
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once api_get_path(SYS_PLUGIN_PATH).'extendedquestionpool/src/extendedquestionpool_plugin.class.php';
200 changes: 200 additions & 0 deletions plugin/extendedquestionpool/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<?php
/* For license terms, see /license.txt */

use Doctrine\DBAL\Types\Type;

/**
* Plugin database installation script. Can only be executed if included
* inside another script loading global.inc.php.
*
* @package chamilo.plugin.extendedquestionpool
*/
/**
* Check if script can be called.
*/
if (!function_exists('api_get_path')) {
exit('This script must be loaded through the Chamilo plugin installer sequence');
}

$entityManager = Database::getManager();

$connection = $entityManager->getConnection();
$platform = $connection->getDatabasePlatform();
$sm = $connection->getSchemaManager();

$extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);

$categoryExtraField = Database::select(
"*",
$extraFieldTable,
[
'where' => ['variable = ?' => 'additional_question_category'],
],
'first'
);

if (!$categoryExtraField) {
Database::insert(
$extraFieldTable,
[
'extra_field_type' => 4,
'field_type' => 1,
'variable' => 'additional_question_category',
'display_text' => 'Categoría adicional',
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 1,
'changeable' => 1,
'filter' => 1,
'created_at' => api_get_utc_datetime(),
]
);
} else {
$query = "UPDATE $extraFieldTable
SET visible_to_self = 1,
visible_to_others = 1,
changeable = 1,
filter = 1
WHERE variable = 'additional_question_category'";
Database::query($query);
}

$categoryExtraField = Database::select(
"*",
$extraFieldTable,
[
'where' => ['variable = ?' => 'question_data1'],
],
'first'
);

if (!$categoryExtraField) {
Database::insert(
$extraFieldTable,
[
'extra_field_type' => 4,
'field_type' => 1,
'variable' => 'question_data1',
'display_text' => 'Campo 1',
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 1,
'changeable' => 1,
'filter' => 1,
'created_at' => api_get_utc_datetime(),
]
);
} else {
$query = "UPDATE $extraFieldTable
SET visible_to_self = 1,
visible_to_others = 1,
changeable = 1,
filter = 1
WHERE variable = 'question_data1'";
Database::query($query);
}

$categoryExtraField = Database::select(
"*",
$extraFieldTable,
[
'where' => ['variable = ?' => 'question_data2'],
],
'first'
);

if (!$categoryExtraField) {
Database::insert(
$extraFieldTable,
[
'extra_field_type' => 4,
'field_type' => 1,
'variable' => 'question_data2',
'display_text' => 'Campo 2',
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 1,
'changeable' => 1,
'filter' => 1,
'created_at' => api_get_utc_datetime(),
]
);
} else {
$query = "UPDATE $extraFieldTable
SET visible_to_self = 1,
visible_to_others = 1,
changeable = 1,
filter = 1
WHERE variable = 'question_data2'";
Database::query($query);
}

$categoryExtraField = Database::select(
"*",
$extraFieldTable,
[
'where' => ['variable = ?' => 'question_data3'],
],
'first'
);

if (!$categoryExtraField) {
Database::insert(
$extraFieldTable,
[
'extra_field_type' => 4,
'field_type' => 1,
'variable' => 'question_data3',
'display_text' => 'Campo 3',
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 1,
'changeable' => 1,
'filter' => 1,
'created_at' => api_get_utc_datetime(),
]
);
} else {
$query = "UPDATE $extraFieldTable
SET visible_to_self = 1,
visible_to_others = 1,
changeable = 1,
filter = 1
WHERE variable = 'question_data3'";
Database::query($query);
}

$categoryExtraField = Database::select(
"*",
$extraFieldTable,
[
'where' => ['variable = ?' => 'question_extra_info'],
],
'first'
);

if (!$categoryExtraField) {
Database::insert(
$extraFieldTable,
[
'extra_field_type' => 4,
'field_type' => 2,
'variable' => 'question_extra_info',
'display_text' => 'Información adicional',
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 1,
'changeable' => 1,
'filter' => 1,
'created_at' => api_get_utc_datetime(),
]
);
} else {
$query = "UPDATE $extraFieldTable
SET visible_to_self = 1,
visible_to_others = 1,
changeable = 1,
filter = 1
WHERE variable = 'question_extra_info'";
Database::query($query);
}
3 changes: 3 additions & 0 deletions plugin/extendedquestionpool/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
/* For license terms, see /license.txt */
require_once 'config.php';
15 changes: 15 additions & 0 deletions plugin/extendedquestionpool/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/* For license terms, see /license.txt */
/**
* This script is included by main/admin/settings.lib.php and generally
* includes things to execute in the main database (settings_current table).
*
* @package chamilo.plugin.extendedquestionpool
*/
require_once __DIR__.'/config.php';

if (!api_is_platform_admin()) {
exit('You must have admin permissions to install plugins');
}

ExtendedQuestionPoolPlugin::create()->install();
12 changes: 12 additions & 0 deletions plugin/extendedquestionpool/lang/english.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$strings['plugin_title'] = "Extended question pool";
$strings['plugin_comment'] = "This plugin adds some extra features to the question pool";
$strings['enable_plugin'] = "Enable plugin";
$strings['enable_extra_data_fields'] = "Use extra info fields";
$strings['enable_stats_count'] = "Enable stats count";
$strings['Occurrences'] = "Occurrences";
$strings['Failures'] = "Failures";
$strings['Successes'] = "Successes";
$strings['setDefaultScore'] = "Assign default score";
$strings['correct_score'] = "Correct score";
$strings['error_score'] = "Error score";
12 changes: 12 additions & 0 deletions plugin/extendedquestionpool/lang/spanish.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$strings['plugin_title'] = "Banco de preguntas extendido";
$strings['plugin_comment'] = "Este plugin añade funcionalidades extendidas al banco de preguntas.";
$strings['enable_plugin'] = "Activar plugin";
$strings['enable_extra_data_fields'] = "Utilizar campos de clasificación adicionales";
$strings['enable_stats_count'] = "Activar recuento de fallos y aciertos";
$strings['Occurrences'] = "Apariciones";
$strings['Failures'] = "Fallos";
$strings['Successes'] = "Aciertos";
$strings['setDefaultScore'] = "Asignar puntuación por defecto";
$strings['correct_score'] = "Puntuación correcta";
$strings['error_score'] = "Puntuación incorrecta";
16 changes: 16 additions & 0 deletions plugin/extendedquestionpool/plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/* For license terms, see /license.txt */

/**
* This script is a configuration file for the date plugin.
* You can use it as a master for other platform plugins (course plugins are slightly different).
* These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins).
*
* @package chamilo.plugin.extendedquestionpool
*/

/**
* Plugin details (must be present).
*/
require_once __DIR__.'/config.php';
$plugin_info = ExtendedQuestionPoolPlugin::create()->get_info();
Loading
Loading