Skip to content

Commit

Permalink
Plugin: Add new AI Helper plugin for questions generation - refs CT#4534
Browse files Browse the repository at this point in the history
  • Loading branch information
cfasanando committed Jan 15, 2023
1 parent ed4382a commit 13c12a4
Show file tree
Hide file tree
Showing 14 changed files with 973 additions and 223 deletions.
8 changes: 8 additions & 0 deletions main/exercise/aiken.php
Expand Up @@ -40,8 +40,16 @@
exit;
}
}
if (isset($_REQUEST['submit_aiken_generated'])) {
$id = aikenImportExercise(null, $_REQUEST);
if (is_numeric($id) && !empty($id)) {
header('Location: admin.php?'.api_get_cidreq().'&exerciseId='.$id);
exit;
}
}
}

Display::display_header(get_lang('ImportAikenQuiz'), 'Exercises');
aiken_display_form();
generateAikenForm();
Display::display_footer();
543 changes: 320 additions & 223 deletions main/exercise/export/aiken/aiken_import.inc.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions main/inc/lib/plugin.lib.php
Expand Up @@ -283,6 +283,7 @@ public function getOfficialPlugins()
'whispeakauth',
'zoom',
'xapi',
'ai_helper',
];

return $officialPlugins;
Expand Down
83 changes: 83 additions & 0 deletions plugin/ai_helper/AiHelperPlugin.php
@@ -0,0 +1,83 @@
<?php
/* For license terms, see /license.txt */

/**
* Description of AiHelperPlugin.
*
* @author Christian Beeznest <christian.fasanando@beeznest.com>
*/
class AiHelperPlugin extends Plugin
{
public const OPENAI_API = 'openai';

protected function __construct()
{
$version = '1.0';
$author = 'Christian Beeznest';

$message = Display::return_message($this->get_lang('Description'));

$settings = [
$message => 'html',
'tool_enable' => 'boolean',
'api_name' => [
'type' => 'select',
'options' => $this->getApiList(),
],
'api_key' => 'text',
'organization_id' => 'text',
];

parent::__construct($version, $author, $settings);
}

/**
* Get the list of apis availables.
*
* @return array
*/
public function getApiList()
{
$list = [
self::OPENAI_API => $this->get_lang('OpenAi'),
];

return $list;
}

/**
* Get the plugin directory name.
*/
public function get_name(): string
{
return 'ai_helper';
}

/**
* Get the class instance.
*
* @staticvar AiHelperPlugin $result
*/
public static function create(): AiHelperPlugin
{
static $result = null;

return $result ?: $result = new self();
}

/**
* Install the plugin. Set the database up.
*/
public function install()
{

}

/**
* Unistall plugin. Clear the database.
*/
public function uninstall()
{

}
}
10 changes: 10 additions & 0 deletions plugin/ai_helper/README.md
@@ -0,0 +1,10 @@
AI Helper plugin
======

Version 1.0

> This plugin is meant to be later integrated into Chamilo (in a major version
release).

The AI helper plugin integrates into parts of the platform that seem the most useful to teachers/trainers or learners.
Because available Artificial Intelligence (to use the broad term) now allows us to ask for meaningful texts to be generated, we can use those systems to pre-generate content, then let the teacher/trainer review the content before publication.
16 changes: 16 additions & 0 deletions plugin/ai_helper/install.php
@@ -0,0 +1,16 @@
<?php
/* For license terms, see /license.txt */

/**
* Install the Ai Helper Plugin.
*
* @package chamilo.plugin.ai_helper
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/AiHelperPlugin.php';

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

AiHelperPlugin::create()->install();
13 changes: 13 additions & 0 deletions plugin/ai_helper/lang/english.php
@@ -0,0 +1,13 @@
<?php
/* For license terms, see /license.txt */

$strings['plugin_title'] = 'AI Helper plugin';
$strings['plugin_comment'] = 'Integrates into parts of the platform that seem the most useful to teachers/trainers or learners';
$strings['Description'] = 'Due available Artificial Intelligence (to use the broad term) now allows us to ask for meaningful texts to be generated, we can use those systems to pre-generate content, then let the teacher/trainer review the content before publication.';
$strings['tool_enable'] = 'Enable plugin';
$strings['api_name'] = 'Ai Api to connect';
$strings['api_key'] = 'Api key';
$strings['api_key_help'] = 'Secret key generated for your Ai api';
$strings['organization_id'] = 'Organization ID';
$strings['organization_id_help'] = 'In case your api account is from an organization.';
$strings['OpenAI'] = 'OpenAI';
13 changes: 13 additions & 0 deletions plugin/ai_helper/lang/french.php
@@ -0,0 +1,13 @@
<?php
/* For license terms, see /license.txt */

$strings['plugin_title'] = 'AI Helper plugin.';
$strings['plugin_comment'] = 'S\'intègre dans les parties de la plateforme qui semblent les plus utiles aux enseignants.';
$strings['Description'] = 'L\'intelligence artificielle disponible (pour utiliser le terme large) nous permet désormais de demander la génération de textes significatifs, nous pouvons utiliser ces systèmes pour pré-générer du contenu, puis laisser l\'enseignant/formateur réviser le contenu avant publication.';
$strings['tool_enable'] = 'Activer le plug-in';
$strings['api_name'] = 'Ai Api pour se connecter';
$strings['api_key'] = 'Api key';
$strings['api_key_help'] = 'Clé secrète générée pour votre API Ai';
$strings['organization_id'] = 'Organization ID';
$strings['organization_id_help'] = 'Si votre compte api provient d\'une organisation.';
$strings['OpenAI'] = 'OpenAI';
13 changes: 13 additions & 0 deletions plugin/ai_helper/lang/spanish.php
@@ -0,0 +1,13 @@
<?php
/* For license terms, see /license.txt */

$strings['plugin_title'] = 'AI Helper plugin.';
$strings['plugin_comment'] = 'Se integra en partes de la plataforma que parecen más útiles para profesores/formadores o alumnos.';
$strings['Description'] = 'Debido a que la Inteligencia Artificial disponible (para usar el término amplio) ahora nos permite solicitar que se generen textos significativos, podemos usar esos sistemas para generar contenido previamente y luego dejar que el maestro/entrenador revise el contenido antes de publicarlo..';
$strings['tool_enable'] = 'Habilitar complemento';
$strings['api_name'] = 'Ai API para conectar';
$strings['api_key'] = 'Api key';
$strings['api_key_help'] = 'Clave secreta generada para su Ai api';
$strings['organization_id'] = 'Identificación de la organización';
$strings['organization_id_help'] = 'En caso de que su cuenta api sea de una organización.';
$strings['OpenAI'] = 'OpenAI';
6 changes: 6 additions & 0 deletions plugin/ai_helper/plugin.php
@@ -0,0 +1,6 @@
<?php
/* For license terms, see /license.txt */

require_once __DIR__.'/AiHelperPlugin.php';

$plugin_info = AiHelperPlugin::create()->get_info();

0 comments on commit 13c12a4

Please sign in to comment.