diff --git a/plugin/h5p/README.md b/plugin/h5p/README.md index d14e0c645c..5acf1eea61 100644 --- a/plugin/h5p/README.md +++ b/plugin/h5p/README.md @@ -1,11 +1,7 @@ -H5P - -=== - -This plugin is compatible for chamilo-1-11-10 and > only -For tools on document editor plaese select region pre_footer - +H5P plugin === +This plugin is only compatible with Chamilo version 1.11.10 and above +To enable tools in the document editor, please enable it in region pre_footer. Other docs : https://www.ludiscape.com/ressources/resources-elearning-en/integration-of-h5p-into-our-lms-chamilo/ \ No newline at end of file diff --git a/plugin/h5p/h5p_plugin.class.php b/plugin/h5p/h5p_plugin.class.php index 7067fa6f47..ea220dc51f 100644 --- a/plugin/h5p/h5p_plugin.class.php +++ b/plugin/h5p/h5p_plugin.class.php @@ -3,6 +3,8 @@ class H5PPlugin extends Plugin { + public $table = 'plugin_mindmap'; + protected function __construct() { parent::__construct( @@ -22,6 +24,9 @@ class H5PPlugin extends Plugin return $result ? $result : $result = new self(); } + /** + * Install the structure necessary for the plugin + */ public function install() { $sql = "CREATE TABLE IF NOT EXISTS plugin_h5p( @@ -31,7 +36,7 @@ class H5PPlugin extends Plugin url_id INT, title VARCHAR(255) NOT NULL, descript VARCHAR(255) NOT NULL, - date_create VARCHAR(12) NOT NULL, + creation_date VARCHAR(12) NOT NULL, terms_a VARCHAR(512) NOT NULL, terms_b VARCHAR(512) NOT NULL, terms_c VARCHAR(512) NOT NULL, @@ -46,9 +51,12 @@ class H5PPlugin extends Plugin } + /** + * Uninstall the plugin structure + */ public function uninstall() { - //$sql = "DROP TABLE IF EXISTS plugin_h5p"; - //Database::query($sql); + $sql = "DROP TABLE IF EXISTS plugin_h5p"; + Database::query($sql); } } diff --git a/plugin/h5p/img/bloctext.png b/plugin/h5p/img/bloctext.png deleted file mode 100644 index 8de25d8c7d..0000000000 Binary files a/plugin/h5p/img/bloctext.png and /dev/null differ diff --git a/plugin/h5p/img/chamilo-h5p.jpg b/plugin/h5p/img/chamilo-h5p.jpg deleted file mode 100644 index ecc3b04404..0000000000 Binary files a/plugin/h5p/img/chamilo-h5p.jpg and /dev/null differ diff --git a/plugin/h5p/img/dialogcard.jpg b/plugin/h5p/img/dialogcard.jpg deleted file mode 100644 index 6336acbb35..0000000000 Binary files a/plugin/h5p/img/dialogcard.jpg and /dev/null differ diff --git a/plugin/h5p/img/eyes.png b/plugin/h5p/img/eyes.png deleted file mode 100644 index 396a560cd2..0000000000 Binary files a/plugin/h5p/img/eyes.png and /dev/null differ diff --git a/plugin/h5p/img/h5p.png b/plugin/h5p/img/h5p.png deleted file mode 100644 index c94c044d4a..0000000000 Binary files a/plugin/h5p/img/h5p.png and /dev/null differ diff --git a/plugin/h5p/img/memory - Copie.png b/plugin/h5p/img/memory - Copie.png deleted file mode 100644 index fbcf8f814b..0000000000 Binary files a/plugin/h5p/img/memory - Copie.png and /dev/null differ diff --git a/plugin/h5p/img/shop.png b/plugin/h5p/img/shop.png deleted file mode 100644 index 7567a8c143..0000000000 Binary files a/plugin/h5p/img/shop.png and /dev/null differ diff --git a/plugin/h5p/img/sumin.png b/plugin/h5p/img/sumin.png deleted file mode 100644 index 68b8c96a44..0000000000 Binary files a/plugin/h5p/img/sumin.png and /dev/null differ diff --git a/plugin/h5p/inc/action.switch.php b/plugin/h5p/inc/action.switch.php new file mode 100644 index 0000000000..b434eedcf8 --- /dev/null +++ b/plugin/h5p/inc/action.switch.php @@ -0,0 +1,75 @@ +validate()) { + $values = $form->getSubmitValues(); + $date = new DateTime(); + $year = $date->format("Y"); + $month = $date->format('m'); + $day = $date->format('j'); + $dateStr = $day.'/'.$month.'/'.$year; + $params = [ + 'title' => $values['title'], + 'creation_date' => $dateStr, + 'user_id' => $userId, + 'node_type' => $values['node_type'], + 'terms_a' => $values['terms_a'], + 'terms_b' => $values['terms_b'], + 'terms_c' => $values['terms_c'], + 'terms_d' => $values['terms_d'], + 'terms_e' => $values['terms_e'], + 'terms_f' => $values['terms_f'], + 'descript' => $values['descript'], + 'url_id' => $urlId + ]; + $result = Database::insert($table, $params); + + $objectId = 0; + if (!$result) { + } else { + Display::addFlash(Display::return_message(get_lang('Added'))); + $objectId = Database::insert_id(); + } + + $varUrlProcess = $varUrlProcess.'?id='.$objectId.'&action=add'; + header('Location: '.$varUrlProcess); + exit; + } + break; + case 'edit': + $form->setDefaults($term); + if ($form->validate()) { + $values = $form->getSubmitValues(); + $params = [ + 'title' => $values['title'], + 'terms_a' => $values['terms_a'], + 'terms_b' => $values['terms_b'], + 'terms_c' => $values['terms_c'], + 'terms_d' => $values['terms_d'], + 'terms_e' => $values['terms_e'], + 'terms_f' => $values['terms_f'], + 'descript' => $values['descript'] + ]; + Database::update($table, $params, ['id = ?' => $id]); + Display::addFlash(Display::return_message(get_lang('Updated'))); + $varUrlProcess = $varUrlProcess.'?id='.$id.'&action=edit'; + header('Location: '.$varUrlProcess); + exit; + } + break; + case 'delete': + if (!empty($term)) { + Database::delete($table, ['id = ?' => $id]); + Display::addFlash(Display::return_message(get_lang('Deleted'))); + header('Location: '.$varUrlList); + exit; + } + break; +} diff --git a/plugin/h5p/inc/edit.form.php b/plugin/h5p/inc/edit.form.php new file mode 100644 index 0000000000..90390fe3b4 --- /dev/null +++ b/plugin/h5p/inc/edit.form.php @@ -0,0 +1,98 @@ +"; + + $tableOfnodes .= ""; + $tableOfnodes .= $plugin->get_lang('TypeContent').""; + + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= "Find the words"; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= " ".$plugin->get_lang('Use')." "; + $tableOfnodes .= ""; + + + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= "Drag the words"; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= " ".$plugin->get_lang('Use')." "; + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= "Dialog card"; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= " ".$plugin->get_lang('Use')." "; + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= "%emory"; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= " ".$plugin->get_lang('Use')." "; + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= "Mark the words"; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= " ".$plugin->get_lang('Use')." "; + $tableOfnodes .= ""; + + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= "Guess the answer"; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= " ".$plugin->get_lang('Use')." "; + $tableOfnodes .= ""; + $tableOfnodes .= ""; + $tableOfnodes .= ""; +} + +// Use $tds defined in translate.php +$html = $translations.''; + +$form->addText('title', get_lang('Title'), false); + +$form->addText('descript', get_lang('Description'), false); + +$nodeTypeForm = $form->addText('node_type', 'node_type', false); +$nodeTypeForm->setValue($nodeType); + +$form->addText('terms_a', 'terms_a', false); +$form->addText('terms_b', 'terms_b', false); +$form->addText('terms_c', 'terms_c', false); +$form->addText('terms_d', 'terms_d', false); +$form->addText('terms_e', 'terms_e', false); +$form->addText('terms_f', 'terms_f', false); + +$form->addElement('static', '', '', $html); + +$form->addButtonSave(get_lang('Save')); diff --git a/plugin/h5p/inc/form-h5p.php b/plugin/h5p/inc/form-h5p.php deleted file mode 100644 index ae0d2a3d68..0000000000 --- a/plugin/h5p/inc/form-h5p.php +++ /dev/null @@ -1,104 +0,0 @@ -"; - - $tableOfnodes .= ""; - $tableOfnodes .= $plugin->get_lang('TypeContent').""; - - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= "Finds The words"; - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= " ".$plugin->get_lang('Use')." "; - $tableOfnodes .= ""; - - - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= "Drag the words"; - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= " ".$plugin->get_lang('Use')." "; - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= "dialogcard"; - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= " ".$plugin->get_lang('Use')." "; - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= "memory"; - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= " ".$plugin->get_lang('Use')." "; - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - - - /* */ - - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= "markthewords"; - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= " ".$plugin->get_lang('Use')." "; - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= "guesstheanswer"; - $tableOfnodes .= ""; - $tableOfnodes .= ""; - $tableOfnodes .= " ".$plugin->get_lang('Use')." "; - $tableOfnodes .= ""; - - $tableOfnodes .= ""; - - - $tableOfnodes .= ""; - - } - - $h = $tds.''; - - $form->addText('title',get_lang('Title'),false); - - $form->addText('descript',get_lang('Description'),false); - - $nodeTypeForm = $form->addText('node_type','node_type',false); - $nodeTypeForm->setValue($nodeType); - - $form->addText('terms_a','terms_a',false); - $form->addText('terms_b','terms_b',false); - $form->addText('terms_c','terms_c',false); - $form->addText('terms_d','terms_d',false); - $form->addText('terms_e','terms_e',false); - $form->addText('terms_f','terms_f',false); - - $form->addElement('static','','',$h); - - $form->addButtonSave(get_lang('Save')); diff --git a/plugin/h5p/inc/switchaction-h5p.php b/plugin/h5p/inc/switchaction-h5p.php deleted file mode 100644 index d04d62e6b6..0000000000 --- a/plugin/h5p/inc/switchaction-h5p.php +++ /dev/null @@ -1,73 +0,0 @@ -validate()){ - $values = $form->getSubmitValues(); - $date = new DateTime(); - $year = $date->format("Y"); - $month = $date->format('m'); - $day = $date->format('j'); - $dateStr = $day.'/'.$month.'/'.$year; - $params = [ - 'title' => $values['title'], - 'date_create' => $dateStr, - 'user_id' => $userId, - 'node_type' => $values['node_type'], - 'terms_a' => $values['terms_a'], - 'terms_b' => $values['terms_b'], - 'terms_c' => $values['terms_c'], - 'terms_d' => $values['terms_d'], - 'terms_e' => $values['terms_e'], - 'terms_f' => $values['terms_f'], - 'descript' => $values['descript'], - 'url_id' => $idurl - ]; - $result = Database::insert($table, $params); - - $objectId = 0; - if(!$result){ - }else{ - Display::addFlash(Display::return_message(get_lang('Added'))); - $objectId = Database::insert_id(); - } - - $varUrlProcess = $varUrlProcess.'?id='.$objectId.'&action=add'; - header('Location: '.$varUrlProcess); - exit; - } - break; - case 'edit': - $form->setDefaults($term); - if($form->validate()) { - $values = $form->getSubmitValues(); - $params = [ - 'title' => $values['title'], - 'terms_a' => $values['terms_a'], - 'terms_b' => $values['terms_b'], - 'terms_c' => $values['terms_c'], - 'terms_d' => $values['terms_d'], - 'terms_e' => $values['terms_e'], - 'terms_f' => $values['terms_f'], - 'descript' => $values['descript'] - ]; - Database::update($table, $params, ['id = ?' => $id]); - Display::addFlash(Display::return_message(get_lang('Updated'))); - $varUrlProcess = $varUrlProcess.'?id='.$id.'&action=edit'; - header('Location: '.$varUrlProcess); - exit; - } - break; - case 'delete': - if(!empty($term)){ - Database::delete($table, ['id = ?' => $id]); - Display::addFlash(Display::return_message(get_lang('Deleted'))); - header('Location: '.$varUrlList); - exit; - } - break; - } diff --git a/plugin/h5p/inc/trad-h5p.php b/plugin/h5p/inc/trad-h5p.php deleted file mode 100644 index d172e44c34..0000000000 --- a/plugin/h5p/inc/trad-h5p.php +++ /dev/null @@ -1,32 +0,0 @@ -'.$plugin->get_lang('h5p_title_help').''; - $tds .= ''; - $tds .= ''; - - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; - - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; - - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; - - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; - - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; - $tds .= ''; diff --git a/plugin/h5p/inc/translate.php b/plugin/h5p/inc/translate.php new file mode 100644 index 0000000000..6e0689a625 --- /dev/null +++ b/plugin/h5p/inc/translate.php @@ -0,0 +1,34 @@ +'.$plugin->get_lang('h5p_title_help').''; +$translations .= ''; +$translations .= ''; + +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; + +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; + +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; + +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; + +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; +$translations .= ''; diff --git a/plugin/h5p/index.php b/plugin/h5p/index.php index e00c0fce50..1c1564a2ef 100644 --- a/plugin/h5p/index.php +++ b/plugin/h5p/index.php @@ -1,38 +1,28 @@ get_info(); -} +/* For license terms, see /license.txt */ $parsedUrl = parse_url($_SERVER['REQUEST_URI']); $parsedUrlpathCtr = $parsedUrl['path']; -$posCtr = strrpos($parsedUrlpathCtr,"lp_controller.php"); +$posCtr = strrpos($parsedUrlpathCtr, "lp_controller.php"); $fh = ''; -if($posCtr===false){ - - echo ''; - -}else{ +if ($posCtr === false) { + echo ''; +} else { + $ctrAction = isset($_GET['action']) ? (string) $_GET['action'] : ''; - $ctrAction = isset($_GET['action']) ? (string) $_GET['action']:''; - - $version = '?v=09'; + $version = '?v=09'; $loginAccepted = isset($_SESSION['h5p']) ? $_SESSION['h5p_accepted'] : null; - $pwp = api_get_path(WEB_PLUGIN_PATH); - if($ctrAction=='edit_item'||$ctrAction=='add_item'){ - $fh .= ''; - $fh .= ''; - $fh .= ''; - $fh .= ''; - + $pluginPath = api_get_path(WEB_PLUGIN_PATH); + $webPath = api_get_path(WEB_PATH); + if ($ctrAction == 'edit_item' || $ctrAction == 'add_item') { + $fh .= ''; + $fh .= ''; + $fh .= ''; + $fh .= ''; } - - - } echo $fh; diff --git a/plugin/h5p/list.php b/plugin/h5p/list.php new file mode 100644 index 0000000000..ca61fb9ef0 --- /dev/null +++ b/plugin/h5p/list.php @@ -0,0 +1,140 @@ +isEnabled(true)) { + api_not_allowed(true); + exit; +} + +//Update 1.5 comment after first update +$sqlUpdate = "SELECT COUNT(*) as nb FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'terms_d' and TABLE_NAME LIKE 'plugin_h5p'"; +$resultUpdate = Database::query($sqlUpdate); +$rowUpdate = Database::fetch_array($resultUpdate); +$intUpdate = (int) $rowUpdate['nb']; +if ($intUpdate == 0) { + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'h5p/update.php?version=1-5'); + exit; +} +//Update 1.5 + +$userId = $user['id']; + +$vers = 6; + +$plugin = H5PPlugin::create(); + +//wordsmatch +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; +$nodeType = isset($_GET['node_type']) ? Security::remove_XSS($_GET['node_type']) : ''; +$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'add'; + +$table = 'plugin_h5p'; + +$urlId = api_get_current_access_url_id(); +$UrlWhere = ""; +if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) { + $UrlWhere = " AND url_id = $urlId "; +} + +$sql = "SELECT * FROM $table WHERE user_id = $userId $UrlWhere ORDER BY title"; +if (isset($_GET['id'])) { + $sql = "SELECT * FROM $table WHERE id <> $id AND user_id = $userId $UrlWhere LIMIT 2"; +} + +$result = Database::query($sql); +$terms = Database::store_result($result, 'ASSOC'); +$countData = count($terms); + +$term = null; + +if ($id > 0) { + if (!empty($id)) { + $sql = "SELECT * FROM $table WHERE id = $id AND user_id = $userId "; + $result = Database::query($sql); + $term = Database::fetch_array($result, 'ASSOC'); + if (empty($term)) { + api_not_allowed(true); + } + } +} + +include __DIR__.'/inc/translate.php'; +include __DIR__.'/inc/edit.form.php'; + +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; + +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; + +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ""; + +if ($nodeType != '') { + $htmlHeadXtra[] = ""; +} + +$htmlHeadXtra[] = ""; + +include 'inc/action.switch.php'; + +$tpl = new Template('H5P'); +if ($nodeType == '') { + $tpl->assign('terms', $terms); +} + +$tpl->assign('tables', $tableOfnodes); +$tpl->assign('form', $form->returnForm()); + +$content = $tpl->fetch('h5p/view/list.tpl'); + +$tpl->assign('content', $content); + +$tpl->display_one_col_template(); diff --git a/plugin/h5p/node_list.php b/plugin/h5p/node_list.php deleted file mode 100644 index 8a168de1fc..0000000000 --- a/plugin/h5p/node_list.php +++ /dev/null @@ -1,143 +0,0 @@ -location.href = '../../index.php';"; - exit; - } - } - - }else{ - echo ""; - exit; - } - - //Update 1.5 comment after first update - $sqlMaj = "SELECT COUNT(*) as nb FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'terms_d' and TABLE_NAME LIKE '%h5p%'"; - $rsMaj = Database::query($sqlMaj); - $rowMaj = Database::fetch_array($rsMaj); - $intMaj = intVal($rowMaj['nb']); - if($intMaj==0){ - echo ""; - exit; - } - //Update 1.5 - - $userId = $user['id']; - - $vers = 6; - - $plugin = H5PPlugin::create(); - - //wordsmatch - $id = isset($_GET['id']) ? (int) $_GET['id']:0; - $nodeType = isset($_GET['node_type']) ? Security::remove_XSS($_GET['node_type']) : ''; - $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']):'add'; - - $table = 'plugin_h5p'; - - $idurl = api_get_current_access_url_id(); - $UrlWhere = ""; - if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) { - $UrlWhere = " AND url_id = $idurl "; - } - - $sql = "SELECT * FROM $table WHERE user_id = $userId $UrlWhere ORDER BY title"; - if(isset($_GET['id'])){ - $sql = "SELECT * FROM $table WHERE id <> $id AND user_id = $userId $UrlWhere LIMIT 2"; - } - - $result = Database::query($sql); - $terms = Database::store_result($result,'ASSOC'); - $countData = count($terms); - - $term = null; - - if($id>0){ - if(!empty($id)){ - $sql = "SELECT * FROM $table WHERE id = $id AND user_id = $userId "; - $result = Database::query($sql); - $term = Database::fetch_array($result, 'ASSOC'); - if(empty($term)){ - api_not_allowed(true); - } - } - } - - include("inc/trad-h5p.php"); - include("inc/form-h5p.php"); - - $awp = api_get_path(WEB_PATH); - - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ''; - - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ''; - - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ''; - $htmlHeadXtra[] = ""; - - if($nodeType!=''){ - $htmlHeadXtra[] = ""; - } - - $htmlHeadXtra[] = ""; - - include("inc/switchaction-h5p.php"); - - $tpl = new Template("H5P"); - if($nodeType==''){ - $tpl->assign('terms', $terms); - } - - $tpl->assign('tables', $tableOfnodes); - $tpl->assign('form', $form->returnForm()); - - $content = $tpl->fetch('/h5p/view/node_list-v13.tpl'); - - $tpl->assign('content', $content); - - $tpl->display_one_col_template(); diff --git a/plugin/h5p/node_process.php b/plugin/h5p/node_process.php index 13a4ae55b4..c6b7fcde1a 100644 --- a/plugin/h5p/node_process.php +++ b/plugin/h5p/node_process.php @@ -1,225 +1,229 @@ setTimeout(function(){location.href = '../../index.php';},1000);"; - exit; - } +$awp = api_get_path(WEB_PATH); +$pathPlugH5P = api_get_path(WEB_PLUGIN_PATH).'h5p/'; - $vers = 6; - $htmlHeadXtra[] = ''; - - $id = isset($_GET['id']) ? (int) $_GET['id']:0; - $nodeType = isset($_GET['node_type']) ? Security::remove_XSS($_GET['node_type']) : ''; - - $terma = ""; - $termb = ""; - $termc = ""; - $termd = ""; - $terme = ""; - $termf = ""; +if (api_is_anonymous()) { + header('Location: '.$awp.'index.php'); + exit; +} - $opt1 = ""; - $opt2 = ""; - $opt3 = ""; +$version = 6; - $description = ""; +$htmlHeadXtra[] = ''; - $term = null; +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; +$nodeType = isset($_GET['node_type']) ? Security::remove_XSS($_GET['node_type']) : ''; - $contentForm = '

Error

'; +$termA = ''; +$termB = ''; +$termC = ''; +$termD = ''; +$termE = ''; +$termF = ''; - if($id>0){ +$option1 = ''; +$option2 = ''; +$option3 = ''; - $sql = "SELECT * FROM plugin_h5p WHERE id = $id "; - $result = Database::query($sql); +$description = ''; - while($rowP=Database::fetch_array($result)){ - $nodeType = $rowP['node_type']; +$term = null; - $terma = $rowP['terms_a']; - $termb = $rowP['terms_b']; - $termc = $rowP['terms_c']; +$contentForm = '

Error

'; - $termd = $rowP['terms_d']; - $terme = $rowP['terms_e']; - $termf = $rowP['terms_f']; +if ($id > 0) { - $opt1 = $rowP['opt_1']; - $opt2 = $rowP['opt_2']; - $opt3 = $rowP['opt_3']; + $sql = "SELECT * FROM plugin_h5p WHERE id = $id "; + $result = Database::query($sql); - $description = $rowP['descript']; - } - - //copyr($source, $dest, $exclude = [], $copied_files = []) - $fld_id = 'source-'.$id; - - $src_h5p ='cache-h5p/launch/source-'.$nodeType; - $dest_h5p ='cache-h5p/launch/'.$fld_id; - - //mkdir($dest_h5p); - - recurse_copy($src_h5p, $dest_h5p); - - $content_src ='cache-h5p/launch/'.$fld_id.'/content/content.json'; - $content_flx = file_get_contents($content_src); - - if($nodeType=='dialogcard'||$nodeType=='memory'){ - - if(controlSourceCards($terma)){ - $base_flx = getSourceCards($terma,$nodeType); - } - if(controlSourceCards($termb)){ - $base_flx .= ','; - $base_flx .= getSourceCards($termb,$nodeType); - } - if(controlSourceCards($termc)){ - $base_flx .= ','; - $base_flx .= getSourceCards($termc,$nodeType); - } - if(controlSourceCards($termd)){ - $base_flx .= ','; - $base_flx .= getSourceCards($termd,$nodeType); - } - if(controlSourceCards($terme)){ - $base_flx .= ','; - $base_flx .= getSourceCards($terme,$nodeType); - } - if(controlSourceCards($termf)){ - $base_flx .= ','; - $base_flx .= getSourceCards($termf,$nodeType); - } - - $content_flx = str_replace("\"@base_cards@\"",$base_flx,$content_flx); - - } - - if($nodeType=='guesstheanswer'){ - - $extractImgData = "images/dialogcard.jpg"; - $path_parts = pathinfo($termb); - $fileN = $path_parts['filename']; - $fileE = $path_parts['extension']; - if($fileN!=''){ - $fileN = $fileN.'.'.$fileE; - $p1 = $termb; - if($p1!=''&&$p1!='dialogcard.jpg'&&$p1!='img/dialogcard.jpg'&&$p1!='images/dialogcard.jpg'){ - $p2 = api_get_path(SYS_PATH).'plugin/h5p/cache-h5p/launch/img/'.$fileN; - copy($p1,$p2); - $extractImgData = "../../img/".$fileN; - }else{ - $extractImgData = api_get_path(WEB_PATH).'plugin/h5p/cache-h5p/launch/img/dialogcard.jpg'; - } - } - - $content_flx = str_replace("@image_b@",json_encode($extractImgData),$content_flx); - - } - - $content_flx = str_replace("@terms_a@",$terma,$content_flx); - $content_flx = str_replace("@terms_b@",$termb,$content_flx); - $content_flx = str_replace("@terms_c@",$termc,$content_flx); - - $content_flx = str_replace("@descript@",$description,$content_flx); - - $langUi = getLangUi(); - - if($langUi=='fr'||$langUi=='french'){ - - - $content_flx = str_replace("\"solution label\"","\"Voir la solution\"",$content_flx); - $content_flx = str_replace("\"Turn\"","\"Tourner\"",$content_flx); - $content_flx = str_replace("\"Check\"","\"Vérifier\"",$content_flx); - $content_flx = str_replace("\"Retry\"","\"Recommencer\"",$content_flx); - $content_flx = str_replace("\"Correct!\"","\"Bravo!\"",$content_flx); - $content_flx = str_replace("\"Incorrect!\"","\"Réponse incorrecte!\"",$content_flx); - $content_flx = str_replace("\"Answer not found!\"","\"Réponse non trouvé!\"",$content_flx); - $content_flx = str_replace("\"You got :num out of :total points\"","\"Votre score :num out sur :total points\"",$content_flx); - $content_flx = str_replace("\"Show solution\"","\"Voir la solution\"",$content_flx); - } - - $fp = fopen($content_src,'w'); - fwrite($fp,$content_flx); - fclose($fp); - - $tar_htm ='cache-h5p/launch/'.$fld_id.'.html'; - $src_h5p = file_get_contents('cache-h5p/launch/source-h.html'); - - $src_h5p = str_replace("{folder}",$fld_id,$src_h5p); - - //{folder} - $fp = fopen($tar_htm,'w'); - fwrite($fp,$src_h5p); - fclose($fp); - - $pathPlugH5P = api_get_path(WEB_PLUGIN_PATH).'h5p/'; - - $contentForm = ''; - - } - - $contentForm .= '

Code embeded

'; - $contentForm .= ''; - $contentForm .= '

'; - $contentForm .= ''; - $contentForm .= ''.get_lang('Close').''; - $contentForm .= '

'; - $tpl = new Template("H5P"); - - $tpl->assign('form', $contentForm); - - $content = $tpl->fetch('/h5p/view/node_view.tpl'); - - $tpl->assign('content', $content); - - $tpl->display_one_col_template(); - - //echo ""; - function recurse_copy($src,$dst) { - $dir = opendir($src); - @mkdir($dst); - while(false !== ( $file = readdir($dir)) ) { - if (( $file != '.' ) && ( $file != '..' )) { - if ( is_dir($src . '/' . $file) ) { - recurse_copy($src . '/' . $file,$dst . '/' . $file); - } - else { - copy($src . '/' . $file,$dst . '/' . $file); - } - } - } - closedir($dir); - } - - function controlSourceCards($termData){ - - if($termData==''){ - return false; - } - $partTerm = explode("|", $termData); - $txtWarp = $partTerm[0]; - $txtWarp = strip_tags($txtWarp); - if($txtWarp!=''){ - return true; - }else{ - return false; - } - - } - - function getSourceCards($termData,$nodeType){ - - $base_flx = '{"tips":{}, + while ($rowP = Database::fetch_array($result)) { + $nodeType = $rowP['node_type']; + + $termA = $rowP['terms_a']; + $termB = $rowP['terms_b']; + $termC = $rowP['terms_c']; + + $termD = $rowP['terms_d']; + $termE = $rowP['terms_e']; + $termF = $rowP['terms_f']; + + $option1 = $rowP['opt_1']; + $option2 = $rowP['opt_2']; + $option3 = $rowP['opt_3']; + + $description = $rowP['descript']; + } + + $fieldId = 'source-'.$id; + + $h5pSource = 'cache-h5p/launch/source-'.$nodeType; + $h5pDestination = 'cache-h5p/launch/'.$fieldId; + + //mkdir($dest_h5p); + + copyr($h5pSource, $h5pDestination); + + $contentSource = 'cache-h5p/launch/'.$fieldId.'/content/content.json'; + $contentFlx = file_get_contents($contentSource); + + if ($nodeType == 'dialogcard' || $nodeType == 'memory') { + + if (controlSourceCards($termA)) { + $baseFlx = getSourceCards($termA, $nodeType); + } + if (controlSourceCards($termB)) { + $baseFlx .= ','; + $baseFlx .= getSourceCards($termB, $nodeType); + } + if (controlSourceCards($termC)) { + $baseFlx .= ','; + $baseFlx .= getSourceCards($termC, $nodeType); + } + if (controlSourceCards($termD)) { + $baseFlx .= ','; + $baseFlx .= getSourceCards($termD, $nodeType); + } + if (controlSourceCards($termE)) { + $baseFlx .= ','; + $baseFlx .= getSourceCards($termE, $nodeType); + } + if (controlSourceCards($termF)) { + $baseFlx .= ','; + $baseFlx .= getSourceCards($termF, $nodeType); + } + + $contentFlx = str_replace("\"@base_cards@\"", $baseFlx, $contentFlx); + + } + + if ($nodeType == 'guesstheanswer') { + + $extractImgData = "images/dialogcard.jpg"; + $pathParts = pathinfo($termB); + $fileN = $pathParts['filename']; + $fileE = $pathParts['extension']; + if ($fileN != '') { + $fileN = $fileN.'.'.$fileE; + $p1 = $termB; + if ($p1 != '' && $p1 != 'dialogcard.jpg' && $p1 != 'img/dialogcard.jpg' && $p1 != 'images/dialogcard.jpg') { + $p2 = api_get_path(SYS_PLUGIN_PATH).'h5p/cache-h5p/launch/img/'.$fileN; + copy($p1, $p2); + $extractImgData = "../../img/".$fileN; + } else { + $extractImgData = $pathPlugH5P.'cache-h5p/launch/img/dialogcard.jpg'; + } + } + + $contentFlx = str_replace("@image_b@", json_encode($extractImgData), $contentFlx); + + } + + $contentFlx = str_replace("@terms_a@", $termA, $contentFlx); + $contentFlx = str_replace("@terms_b@", $termB, $contentFlx); + $contentFlx = str_replace("@terms_c@", $termC, $contentFlx); + + $contentFlx = str_replace("@descript@", $description, $contentFlx); + + $interfaceLanguage = api_get_language_isocode(); + + // @TODO support translations in a better way (only en/fr now) + if ($interfaceLanguage == 'fr' || $interfaceLanguage == 'french') { + $contentFlx = str_replace("\"solution label\"", "\"Voir la solution\"", $contentFlx); + $contentFlx = str_replace("\"Turn\"", "\"Tourner\"", $contentFlx); + $contentFlx = str_replace("\"Check\"", "\"Vérifier\"", $contentFlx); + $contentFlx = str_replace("\"Retry\"", "\"Recommencer\"", $contentFlx); + $contentFlx = str_replace("\"Correct!\"", "\"Bravo!\"", $contentFlx); + $contentFlx = str_replace("\"Incorrect!\"", "\"Réponse incorrecte!\"", $contentFlx); + $contentFlx = str_replace("\"Answer not found!\"", "\"Réponse non trouvée!\"", $contentFlx); + $contentFlx = str_replace("\"You got :num out of :total points\"", + "\"Votre score :num out sur :total points\"", $contentFlx); + $contentFlx = str_replace("\"Show solution\"", "\"Voir la solution\"", $contentFlx); + } elseif ($interfaceLanguage == 'es') { + $contentFlx = str_replace("\"solution label\"", "\"Ver la solución\"", $contentFlx); + $contentFlx = str_replace("\"Turn\"", "\"Girar\"", $contentFlx); + $contentFlx = str_replace("\"Check\"", "\"Verificar\"", $contentFlx); + $contentFlx = str_replace("\"Retry\"", "\"Volver a intentar\"", $contentFlx); + $contentFlx = str_replace("\"Correct!\"", "\"¡Bravo!\"", $contentFlx); + $contentFlx = str_replace("\"Incorrect!\"", "\"¡Respuesta incorrecta!\"", $contentFlx); + $contentFlx = str_replace("\"Answer not found!\"", "\"¡Respuesta no encontrada!\"", $contentFlx); + $contentFlx = str_replace("\"You got :num out of :total points\"", + "\"Su nota es de :num sobre :total puntos\"", $contentFlx); + $contentFlx = str_replace("\"Show solution\"", "\"Ver la solución\"", $contentFlx); + } + + $fp = fopen($contentSource, 'w'); + fwrite($fp, $contentFlx); + fclose($fp); + + $htmlFile = 'cache-h5p/launch/'.$fieldId.'.html'; + $h5pSource = file_get_contents('cache-h5p/launch/source-h.html'); + + $h5pSource = str_replace("{folder}", $fieldId, $h5pSource); + + //{folder} + $fp = fopen($htmlFile, 'w'); + fwrite($fp, $h5pSource); + fclose($fp); + + + $contentForm = ''; + +} + +$contentForm .= '

Embedded code

'; +$contentForm .= ''; +$contentForm .= '

'; +$contentForm .= ''; +$contentForm .= ''.get_lang('Close').''; +$contentForm .= '

'; + +$tpl = new Template("H5P"); +$tpl->assign('form', $contentForm); +$content = $tpl->fetch('/h5p/view/view.tpl'); +$tpl->assign('content', $content); + +$tpl->display_one_col_template(); + +/** + * Check if a source card is not empty. + * @param string $termData A string from which we extract the first part + * @return bool False on empty, true otherwise + */ +function controlSourceCards($termData) +{ + if ($termData == '') { + return false; + } + $partTerm = explode("|", $termData); + $txtWarp = $partTerm[0]; + $txtWarp = strip_tags($txtWarp); + if ($txtWarp != '') { + return true; + } + return false; +} + +/** + * Parse and reformat base image tags with the given terms string. + * @param string $termData A string from which we only take the first elements (we split it on | ) + * @param string $nodeType The type of node ('memory', 'cards', etc) + * @return string|string[] + */ +function getSourceCards($termData, $nodeType) +{ + + $baseFlx = '{"tips":{}, "text": @text_a@ , "answer": @answer_a@ , "image":{"path":@image_a@, @@ -229,56 +233,37 @@ "height":100 }}'; - if($nodeType=='memory'){ - $base_flx = '{"image":{"path":@image_a@, + if ($nodeType == 'memory') { + $baseFlx = '{"image":{"path":@image_a@, "mime":"image\/jpeg", "copyright":{"license":"U"}, "width":100,"height":100}, "description":@text_a@,"matchAlt":@text_a@,"imageAlt":@text_a@}'; - } - - $partTerm = explode("|", $termData); - $base_flx = str_replace("@text_a@",json_encode($partTerm[0]),$base_flx); - $base_flx = str_replace("@answer_a@",json_encode($partTerm[1]),$base_flx); - - $extractImg = "images/dialogcard.jpg"; - - $path_parts = pathinfo($partTerm[2]); - $fileN = $path_parts['filename']; - $fileE = $path_parts['extension']; - - if($fileN!=''){ - $fileN = $fileN.'.'.$fileE; - $p1 = $partTerm[2]; - if($p1!=''&&$p1!='dialogcard.jpg'&&$p1!='img/dialogcard.jpg'&&$p1!='images/dialogcard.jpg'){ - - $p2 = api_get_path(SYS_PATH).'plugin/h5p/cache-h5p/launch/img/'.$fileN; - - copy($p1,$p2); - - $extractImg = "../../img/".$fileN; - - }else{ - $extractImg = api_get_path(WEB_PATH).'plugin/h5p/cache-h5p/launch/img/dialogcard.jpg'; - } - } - - $base_flx = str_replace("@image_a@",json_encode($extractImg),$base_flx); - - return $base_flx; - - } - - function getLangUi() - { - - $language = 'en'; - - global $language_interface; - if(!empty($language_interface)){ - $language = $language_interface; - } - - return $language; - - } + } + + $partTerm = explode("|", $termData); + $baseFlx = str_replace("@text_a@", json_encode($partTerm[0]), $baseFlx); + $baseFlx = str_replace("@answer_a@", json_encode($partTerm[1]), $baseFlx); + + $extractImg = "images/dialogcard.jpg"; + + $pathParts = pathinfo($partTerm[2]); + $fileN = $pathParts['filename']; + $fileE = $pathParts['extension']; + + if ($fileN != '') { + $fileN = $fileN.'.'.$fileE; + $p1 = $partTerm[2]; + if ($p1 != '' && $p1 != 'dialogcard.jpg' && $p1 != 'img/dialogcard.jpg' && $p1 != 'images/dialogcard.jpg') { + $p2 = api_get_path(SYS_PLUGIN_PATH).'h5p/cache-h5p/launch/img/'.$fileN; + copy($p1, $p2); + $extractImg = '../../img/'.$fileN; + } else { + $extractImg = api_get_path(WEB_PLUGIN_PATH).'h5p/cache-h5p/launch/img/dialogcard.jpg'; + } + } + $baseFlx = str_replace("@image_a@", json_encode($extractImg), $baseFlx); + + return $baseFlx; + +} diff --git a/plugin/h5p/page-descri.php b/plugin/h5p/page-descri.php deleted file mode 100644 index 47bd493634..0000000000 --- a/plugin/h5p/page-descri.php +++ /dev/null @@ -1,55 +0,0 @@ -'; - echo 'location.href="'.api_get_path(WEB_PATH).'custompages/landchami-'.$id.'.html";'; - echo ''; - }else{ - echo ' the page ('.api_get_path(WEB_PATH).'custompages/landchami-'.$id.'.html) no exist !"'; - } - - - } - } - - }else{ - echo ' No ID !"'; - } diff --git a/plugin/h5p/resources/ajax/getnodes.php b/plugin/h5p/resources/ajax/getnodes.php index c06d29c546..9dd0b4b702 100644 --- a/plugin/h5p/resources/ajax/getnodes.php +++ b/plugin/h5p/resources/ajax/getnodes.php @@ -1,32 +1,33 @@ location.href = '../../index.php';"; - exit; - } - - $id = isset($_GET['id']) ? (int) $_GET['id']:0; - - $idurl = api_get_current_access_url_id(); - $UrlWhere = ""; - if(api_get_multiple_access_url()){ - $UrlWhere = " WHERE url_id = $idurl "; - } - - $sql = "SELECT id,title,node_type FROM plugin_chamilo_h5p $UrlWhere ORDER BY title"; - - $resultset = Database::query($sql); - - $h = ''; - - while ($row = Database::fetch_array($resultset)){ - - $id = $row['id']; - $title = $row['title']; - $nodeType = $row['node_type']; - $h .= '
'.$title.'
'; - } - - echo $h; +/* For license terms, see /license.txt */ +/** + * Return HTML list for AJAX request + */ +require_once __DIR__.'/../../../../main/inc/global.inc.php'; + +if (api_is_anonymous()) { + header('Location: '.api_get_path(WEB_PATH).'index.php'); + exit; +} + +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; + +$urlId = api_get_current_access_url_id(); +$UrlWhere = ""; +if (api_get_multiple_access_url()) { + $UrlWhere = " WHERE url_id = $urlId "; +} + +$sql = "SELECT id,title,node_type FROM plugin_h5p $UrlWhere ORDER BY title"; +$resultSet = Database::query($sql); +$html = ''; + +while ($row = Database::fetch_array($resultSet)) { + $id = $row['id']; + $title = $row['title']; + $nodeType = $row['node_type']; + $html .= '
'.$title.'
'; +} + +echo $html; diff --git a/plugin/h5p/img/dialogcard.png b/plugin/h5p/resources/img/dialogcard.png similarity index 100% rename from plugin/h5p/img/dialogcard.png rename to plugin/h5p/resources/img/dialogcard.png diff --git a/plugin/h5p/resources/img/docx.png b/plugin/h5p/resources/img/docx.png deleted file mode 100644 index 2e535a8df7..0000000000 Binary files a/plugin/h5p/resources/img/docx.png and /dev/null differ diff --git a/plugin/h5p/resources/img/download.png b/plugin/h5p/resources/img/download.png deleted file mode 100644 index 4bd6267a82..0000000000 Binary files a/plugin/h5p/resources/img/download.png and /dev/null differ diff --git a/plugin/h5p/img/dragthewords.png b/plugin/h5p/resources/img/dragthewords.png similarity index 100% rename from plugin/h5p/img/dragthewords.png rename to plugin/h5p/resources/img/dragthewords.png diff --git a/plugin/h5p/img/edit.png b/plugin/h5p/resources/img/edit.png similarity index 100% rename from plugin/h5p/img/edit.png rename to plugin/h5p/resources/img/edit.png diff --git a/plugin/h5p/resources/img/file-docx.png b/plugin/h5p/resources/img/file-docx.png deleted file mode 100644 index 36a2470367..0000000000 Binary files a/plugin/h5p/resources/img/file-docx.png and /dev/null differ diff --git a/plugin/h5p/resources/img/file-none.png b/plugin/h5p/resources/img/file-none.png deleted file mode 100644 index 3073a9cca8..0000000000 Binary files a/plugin/h5p/resources/img/file-none.png and /dev/null differ diff --git a/plugin/h5p/resources/img/file-pdf.png b/plugin/h5p/resources/img/file-pdf.png deleted file mode 100644 index 3d79b2b47a..0000000000 Binary files a/plugin/h5p/resources/img/file-pdf.png and /dev/null differ diff --git a/plugin/h5p/resources/img/forum_listview.png b/plugin/h5p/resources/img/forum_listview.png deleted file mode 100644 index bc31d03e45..0000000000 Binary files a/plugin/h5p/resources/img/forum_listview.png and /dev/null differ diff --git a/plugin/h5p/resources/img/g91884.png b/plugin/h5p/resources/img/g91884.png deleted file mode 100644 index 412ba3b046..0000000000 Binary files a/plugin/h5p/resources/img/g91884.png and /dev/null differ diff --git a/plugin/h5p/img/guesstheanswer.png b/plugin/h5p/resources/img/guesstheanswer.png similarity index 100% rename from plugin/h5p/img/guesstheanswer.png rename to plugin/h5p/resources/img/guesstheanswer.png diff --git a/plugin/h5p/resources/img/h5p-chamilo - Copie.png b/plugin/h5p/resources/img/h5p-chamilo - Copie.png deleted file mode 100644 index 1f68253dc7..0000000000 Binary files a/plugin/h5p/resources/img/h5p-chamilo - Copie.png and /dev/null differ diff --git a/plugin/h5p/resources/img/lock.png b/plugin/h5p/resources/img/lock.png deleted file mode 100644 index 81638d3104..0000000000 Binary files a/plugin/h5p/resources/img/lock.png and /dev/null differ diff --git a/plugin/h5p/img/markthewords.png b/plugin/h5p/resources/img/markthewords.png similarity index 100% rename from plugin/h5p/img/markthewords.png rename to plugin/h5p/resources/img/markthewords.png diff --git a/plugin/h5p/img/memory.png b/plugin/h5p/resources/img/memory.png similarity index 100% rename from plugin/h5p/img/memory.png rename to plugin/h5p/resources/img/memory.png diff --git a/plugin/h5p/resources/img/pdf.png b/plugin/h5p/resources/img/pdf.png deleted file mode 100644 index 50147d9dc7..0000000000 Binary files a/plugin/h5p/resources/img/pdf.png and /dev/null differ diff --git a/plugin/h5p/resources/img/reading-comprehension_na.png b/plugin/h5p/resources/img/reading-comprehension_na.png deleted file mode 100644 index 224bb3103b..0000000000 Binary files a/plugin/h5p/resources/img/reading-comprehension_na.png and /dev/null differ diff --git a/plugin/h5p/resources/img/statistics.png b/plugin/h5p/resources/img/statistics.png deleted file mode 100644 index 42dc708b0e..0000000000 Binary files a/plugin/h5p/resources/img/statistics.png and /dev/null differ diff --git a/plugin/h5p/resources/img/stats.png b/plugin/h5p/resources/img/stats.png deleted file mode 100644 index 4ef79f5a33..0000000000 Binary files a/plugin/h5p/resources/img/stats.png and /dev/null differ diff --git a/plugin/h5p/resources/img/survey_reporting_overall.png b/plugin/h5p/resources/img/survey_reporting_overall.png deleted file mode 100644 index 39d593dbb3..0000000000 Binary files a/plugin/h5p/resources/img/survey_reporting_overall.png and /dev/null differ diff --git a/plugin/h5p/img/wordsmatch.png b/plugin/h5p/resources/img/wordsmatch.png similarity index 100% rename from plugin/h5p/img/wordsmatch.png rename to plugin/h5p/resources/img/wordsmatch.png diff --git a/plugin/h5p/resources/js/demo.js b/plugin/h5p/resources/js/demo.js deleted file mode 100644 index dbf721c76a..0000000000 --- a/plugin/h5p/resources/js/demo.js +++ /dev/null @@ -1,72 +0,0 @@ - -function getbyelem(n){ - - if(document.getElementById(n)){ - - var tagName = document.getElementById(n).tagName; - - if(tagName=='SELECT'){ - var get_id = document.getElementById(n); - var resultselect = get_id.options[get_id.selectedIndex].value; - //console.log(resultselect); - return resultselect; - } - - if(tagName=='INPUT'){ - return document.getElementById(n).value; - } - - if(tagName=='TEXTAREA'){ - var ct = document.getElementById(n).value; - ct = ct.replace('\n','
'); - return ct; - } - - }else{ - - return "-" - - } - - -} - -setTimeout(function(){ applikSelectDemo(); }, 500); - -function applikSelectDemo(){ - - var textIconImg = getbyelem('dictionary_iconimg'); - var textTitle = getbyelem('dictionary_title'); - - $("#icodemo").removeClass(); - $("#icodemo").addClass(textIconImg); - $("#icodemo").addClass('document-vignette'); - $("#titledemo").html(textTitle); - - setTimeout(function(){ applikSelectDemo(); }, 500); - -} - - -$(document).ready(function(){ - - var u = window.top.location.href; - - if(u.indexOf('action=edit')==-1){ - $("#dictionary").css("display","none"); - var btn = ''; - btn += 'Créer un espace client

'; - $("#dictionary").parent().prepend(btn); - } - - $("#dictionary_listOfUsers").parent().parent().css("display","none"); - -}); - -function showEditFormulaire(){ - $("#dictionary").css("display",""); - $("#addElement").css("display","none"); -} - - - diff --git a/plugin/h5p/resources/js/h5p_extras.js b/plugin/h5p/resources/js/h5p_extras.js index a71b130329..a6c16c407e 100644 --- a/plugin/h5p/resources/js/h5p_extras.js +++ b/plugin/h5p/resources/js/h5p_extras.js @@ -1,6 +1,9 @@ +/* For licensing terms, see /license.txt */ +console.log('h5p extras is active'); -console.log('chamilo_h5p extras is active'); - +/** + * Find CKEditor's instance and add an H5P button to it + */ function installInTinyH5p(){ if (window.jQuery) { @@ -15,7 +18,7 @@ function installInTinyH5p(){ gi += ' title="H5P insert" tabindex="-1" hidefocus="true" '; gi += ' role="button" aria-labelledby="cke_50_label" '; gi += ' aria-describedby="cke_50_description" aria-haspopup="false" >'; - gi += '  '; + gi += '  '; gi += ''; gi += ''; $(".cke_button__source").after(gi); @@ -42,12 +45,18 @@ setTimeout(function(){installInTinyH5p();},600); //#H5P:1# +/** + * Load H5P objects through CKEditor + */ function loadExtrasObjectsH5p(){ insertExtrasObjectsH5p(); $(".cke_dialog_background_cover").css('display','block'); $("#extrasobjectH5p").css('display','block'); } +/** + * Insert H5P objects in the body of the area edited through CKEditor + */ function insertExtrasObjectsH5p(){ if($(".cke_dialog_background_cover").length==0){ @@ -61,6 +70,10 @@ function insertExtrasObjectsH5p(){ } +/** + * Generate the HTML to insert H5P objects in an HTML document + * @returns {string} + */ function inExtrasObjectsH5p(){ var h = ''; @@ -74,12 +87,18 @@ function inExtrasObjectsH5p(){ } +/** + * Visually remove H5P objects from CKEditor + */ function closeExtrasH5p(){ $("#extrasobjectH5p").css('display','none'); $(".cke_dialog_background_cover").css('display','none'); } +/** + * Show the H5P options + */ function showEditH5pLoad(){ $(".cke_dialog_background_cover").css('z-index','97'); @@ -108,17 +127,20 @@ function showEditH5pLoad(){ } +/** + * Load (AJAX) the H5P node types + */ function loadDataH5Pbase(){ - $('.bloch5pGrid').html('

'); + $('.bloch5pGrid').html('

'); - var urlpath = _p['web_plugin'] +'chamilo_h5p/resources/ajax/getnodes.php'; + var urlpath = _p['web_plugin'] +'h5p/resources/ajax/getnodes.php'; $.ajax({ url : urlpath,cache : false }).done(function(codeHtml){ - var urlH5p = _p['web_plugin'] +'chamilo_h5p/node_list.php'; + var urlH5p = _p['web_plugin'] +'h5p/list.php'; codeHtml += ' '; @@ -134,16 +156,24 @@ function loadDataH5Pbase(){ } +/** + * Select a type of node for the base element of an H5P object + * @param id + * @param node_type + */ function selectH5Pbase(id,node_type){ $(".bloch5pLine").css("background-color","white").css("color","black"); $(".bloch5pLine" + id).css("background-color","#2575be").css("color","white"); - var pgid = "chamilo_h5p/cache-h5p/launch/source-" + id + ".html?tn=" + node_type; + var pgid = "h5p/cache-h5p/launch/source-" + id + ".html?tn=" + node_type; $("#inputSelH5PUrl").val(pgid); } +/** + * Add an H5P object in CKEditor + */ function addObjectH5PInCKEDITORByBase(){ var pg = $("#inputSelH5PUrl").val(); @@ -172,4 +202,3 @@ function addObjectH5PInCKEDITORByBase(){ } } - diff --git a/plugin/h5p/resources/js/interface.js b/plugin/h5p/resources/js/interface.js index 8256cd62c2..b7e42814cf 100644 --- a/plugin/h5p/resources/js/interface.js +++ b/plugin/h5p/resources/js/interface.js @@ -1,578 +1,654 @@ +/* For licensing terms, see /license.txt */ +/** + * When the document is ready, do some preparation for the dictionary H5P content type elements + */ +$(document).ready(function () { + + var u = window.top.location.href + + if (u.indexOf('action=edit') == -1) { + $('#dictionary').css('display', 'none') + var btn = '' + btn += 'Create Page

' + //$("#dictionary").parent().prepend(btn); + } + + $('#dictionary_title').parent().parent().css('display', 'none') + $('#dictionary_node_type').parent().parent().css('display', 'none') + $('#dictionary_submit').parent().parent().css('display', 'none') + $('#dictionary_descript').parent().parent().css('display', 'none') + + $('#dictionary_terms_a').parent().parent().css('display', 'none') + $('#dictionary_terms_b').parent().parent().css('display', 'none') + $('#dictionary_terms_c').parent().parent().css('display', 'none') + $('#dictionary_terms_d').parent().parent().css('display', 'none') + $('#dictionary_terms_e').parent().parent().css('display', 'none') + $('#dictionary_terms_f').parent().parent().css('display', 'none') + + $('#dictionary_opt_1').parent().parent().css('display', 'none') + $('#dictionary_opt_2').parent().parent().css('display', 'none') + $('#dictionary_opt_3').parent().parent().css('display', 'none') + + $('#dictionary_submit').parent().prepend('' + $('#h5p_cancel').html() + '') + + $('#dictionary_submit').click(function (e) { + + var pagetype = $('#dictionary_node_type').val() + + if (pagetype == 'dialogcard') { + if (controlsFieldsdialogcard() == false) { + e.preventDefault() + } + } -$(document).ready(function(){ - - var u = window.top.location.href; - - if(u.indexOf('action=edit')==-1){ - $("#dictionary").css("display","none"); - var btn = ''; - btn += 'Create Page

'; - //$("#dictionary").parent().prepend(btn); - } - - $("#dictionary_title").parent().parent().css("display","none"); - $("#dictionary_node_type").parent().parent().css("display","none"); - $("#dictionary_submit").parent().parent().css("display","none"); - $("#dictionary_descript").parent().parent().css("display","none"); - - $("#dictionary_terms_a").parent().parent().css("display","none"); - $("#dictionary_terms_b").parent().parent().css("display","none"); - $("#dictionary_terms_c").parent().parent().css("display","none"); - $("#dictionary_terms_d").parent().parent().css("display","none"); - $("#dictionary_terms_e").parent().parent().css("display","none"); - $("#dictionary_terms_f").parent().parent().css("display","none"); - - $("#dictionary_opt_1").parent().parent().css("display","none"); - $("#dictionary_opt_2").parent().parent().css("display","none"); - $("#dictionary_opt_3").parent().parent().css("display","none"); - - $("#dictionary_submit").parent().prepend('' + $("#h5p_cancel").html() + ''); - - $("#dictionary_submit").click(function(e){ - - var pagetype = $("#dictionary_node_type").val(); - - if(pagetype=='dialogcard'){ - if(controlsFieldsdialogcard()==false){ - e.preventDefault(); - } - } - - var title = $("#dictionary_title").val(); - if(title==''){ - $("#dictionary_title").css("background","pink"); - e.preventDefault(); - }else{ - if(u.indexOf('action=edit')==-1){ - if(pagetype==''){ - e.preventDefault(); - } - } - } - }); - -}); - -$(document).ready(function(){ - - var menuBc = '
  •   '; - menuBc += 'H5P  
  • '; - - var btn = '  ').dialog({modal: true, width: "80%", title: "Select your file", zIndex: 99999, - create: function(event,ui){ - $(this).elfinder({ - resizable: false, - url: "../../main/inc/lib/elfinder/connectorAction.php", - commandsOptions:{ - getfile: { - oncomplete: 'destroy' - } - },getFileCallback: function(file){ - $("#" + targetInputImg).val(file.url); - var imgBlok = targetInputImg.replace('imagecard','imageBlockPreview'); - var imgPath = $("#"+targetInputImg).val(); - $('.'+imgBlok).css('background-image','url(' + imgPath + ')'); - jQuery('a.ui-dialog-titlebar-close[role="button"]').click(); - jQuery('button.ui-dialog-titlebar-close[role="button"]').click(); - } - }).elfinder('instance') - } - }); +/** + * Show the CKEditor files manager + */ +function showFileManger () { + var urlContent = '../../main/inc/lib/elfinder/filemanager.php' + var OpenWind = window.open(urlContent, 'FileManager', 'menubar=no, scrollbars=no, top=50, left=50, width=700, height=600') + console.log(OpenWind.setUrl) +} +/** + * Show the images selection filemanager of CKEditor + * @type {string} + */ +var targetInputImg = '' + +function showFileMangerSelectImg () { + + $('
    ').dialog({ + modal: true, width: '80%', title: 'Select your file', zIndex: 99999, + create: function (event, ui) { + $(this).elfinder({ + resizable: false, + url: '../../main/inc/lib/elfinder/connectorAction.php', + commandsOptions: { + getfile: { + oncomplete: 'destroy' + } + }, getFileCallback: function (file) { + $('#' + targetInputImg).val(file.url) + var imgBlok = targetInputImg.replace('imagecard', 'imageBlockPreview') + var imgPath = $('#' + targetInputImg).val() + $('.' + imgBlok).css('background-image', 'url(' + imgPath + ')') + jQuery('a.ui-dialog-titlebar-close[role="button"]').click() + jQuery('button.ui-dialog-titlebar-close[role="button"]').click() + } + }).elfinder('instance') + } + }) } +/** + * Get an element by Id + * @param n + * @returns {string|*} + */ +function getbyelem (n) { -function getbyelem(n){ - - if(document.getElementById(n)){ - - var tagName = document.getElementById(n).tagName; - - if(tagName=='SELECT'){ - var get_id = document.getElementById(n); - var resultselect = get_id.options[get_id.selectedIndex].value; - //console.log(resultselect); - return resultselect; - } - - if(tagName=='INPUT'){ - return document.getElementById(n).value; - } - - if(tagName=='TEXTAREA'){ - var ct = document.getElementById(n).value; - ct = ct.replace('\n','
    '); - return ct; - } - - }else{ - - return "-"; - - } + if (document.getElementById(n)) { -} + var tagName = document.getElementById(n).tagName -function checkRadio(r){ - $('#rad' + r).prop('checked',true); - $('#dictionary_node_type').val(r); + if (tagName == 'SELECT') { + var get_id = document.getElementById(n) + var resultselect = get_id.options[get_id.selectedIndex].value + //console.log(resultselect); + return resultselect + } + + if (tagName == 'INPUT') { + return document.getElementById(n).value + } + + if (tagName == 'TEXTAREA') { + var ct = document.getElementById(n).value + ct = ct.replace('\n', '
    ') + return ct + } + } else { + + return '-' + } } -function interfacewordsmatch(){ - - $(".dataTables_wrapper").css("display","none"); - $("#dictionary_node_type").parent().parent().css("display","none"); - $("#nodeselection").parent().parent().css("display","none"); - - $("#dictionary_title").parent().parent().css("display",""); - $("#dictionary_title").parent().append("" + $("#h5p_title_help").html() + ""); - - $("#dictionary_submit").parent().parent().css("display",""); - - $("#dictionary_descript").parent().parent().css("display",""); - $("#dictionary_descript").parent().append("" + $("#h5p_descr_help").html() + ""); - $("#dictionary_descript").val($("#h5p_wordsmatch_tutor").html()); - - $("#dictionary").css("display",""); - $("#addElement").css("display","none"); - $("#nodeselection").css("display","none"); - - $("#dictionary_terms_a").parent().parent().css("display",""); - $("#dictionary_terms_a").val($("#h5p_wordsmatch_load").html()); - $("#dictionary_terms_a").parent().append("" + $("#h5p_wordsmatch_help").html() + ""); - - interfaceNameLabel('terms_a',$("#h5p_wordsmatch_term_a").html()); - +/** + * Check the given radio button + * @param r + */ +function checkRadio (r) { + $('#rad' + r).prop('checked', true) + $('#dictionary_node_type').val(r) } -function interfaceNameLabel(idjq,name){ - - $("label").each(function( index ) { +/** + * Show the interface for the words match H5P element type + */ +function interfacewordsmatch () { - var forSrcAttr = $( this ).attr("for"); - if(typeof forSrcAttr === "undefined"){ - forSrcAttr = ''; - } - if(forSrcAttr.indexOf('_' + idjq)!=-1){ - $(this).html(name); - } - - }); + $('.dataTables_wrapper').css('display', 'none') + $('#dictionary_node_type').parent().parent().css('display', 'none') + $('#nodeselection').parent().parent().css('display', 'none') + + $('#dictionary_title').parent().parent().css('display', '') + $('#dictionary_title').parent().append('' + $('#h5p_title_help').html() + '') + + $('#dictionary_submit').parent().parent().css('display', '') + + $('#dictionary_descript').parent().parent().css('display', '') + $('#dictionary_descript').parent().append('' + $('#h5p_descr_help').html() + '') + $('#dictionary_descript').val($('#h5p_wordsmatch_tutor').html()) + + $('#dictionary').css('display', '') + $('#addElement').css('display', 'none') + $('#nodeselection').css('display', 'none') + + $('#dictionary_terms_a').parent().parent().css('display', '') + $('#dictionary_terms_a').val($('#h5p_wordsmatch_load').html()) + $('#dictionary_terms_a').parent().append('' + $('#h5p_wordsmatch_help').html() + '') + + interfaceNameLabel('terms_a', $('#h5p_wordsmatch_term_a').html()) } -function interfacememory(){ - interfacedialogcard(); +/** + * Show the interface for the Name Label H5P element type + */ +function interfaceNameLabel (idjq, name) { + + $('label').each(function (index) { + + var forSrcAttr = $(this).attr('for') + if (typeof forSrcAttr === 'undefined') { + forSrcAttr = '' + } + if (forSrcAttr.indexOf('_' + idjq) != -1) { + $(this).html(name) + } + + }) + } -function interfacedialogcard(){ - - $(".dataTables_wrapper").css("display","none"); - $("#dictionary_node_type").parent().parent().css("display","none"); - $("#nodeselection").parent().parent().css("display","none"); - - $("#dictionary_title").parent().parent().css("display",""); - $("#dictionary_title").parent().append("" + $("#h5p_title_help").html() + ""); - - $("#dictionary_submit").parent().parent().css("display",""); - - $("#dictionary_descript").parent().parent().css("display",""); - $("#dictionary_descript").parent().append("" + $("#h5p_dialogcard_help").html() + ""); - $("#dictionary_descript").val($("#h5p_dialogcard_tutor").html()); - - $("#dictionary").css("display",""); - $("#addElement").css("display","none"); - $("#nodeselection").css("display","none"); - - $("#dictionary_terms_a").parent().parent().css("display",""); - var dterma = $("#dictionary_terms_a").val(); - $("#dictionary_terms_a").parent().append(interfaceCard('a',dterma)); - interfaceNameLabel('terms_a',$("#h5p_dialogcard_term_a").html()); - - $("#dictionary_terms_b").parent().parent().css("display",""); - var dtermb = $("#dictionary_terms_b").val(); - $("#dictionary_terms_b").parent().append(interfaceCard('b',dtermb)); - interfaceNameLabel('terms_b',""); - - $("#dictionary_terms_c").parent().parent().css("display",""); - var dtermc = $("#dictionary_terms_c").val(); - $("#dictionary_terms_c").parent().append(interfaceCard('c',dtermc)); - interfaceNameLabel('terms_c',""); - - $("#dictionary_terms_d").parent().parent().css("display",""); - var dtermd = $("#dictionary_terms_d").val(); - $("#dictionary_terms_d").parent().append(interfaceCard('d',dtermd)); - - interfaceNameLabel('terms_d',""); - - $("#dictionary_terms_e").parent().parent().css("display",""); - var dterme = $("#dictionary_terms_e").val(); - $("#dictionary_terms_e").parent().append(interfaceCard('e',dterme)); - - interfaceNameLabel('terms_e',""); - - $("#dictionary_terms_f").parent().parent().css("display",""); - var dtermf = $("#dictionary_terms_f").val(); - $("#dictionary_terms_f").parent().append(interfaceCard('f',dtermf)); - - interfaceNameLabel('terms_f',""); - - plusDialogCard(); - - setTimeout(function(){ - interfaceEvents(dterma,'a'); - interfaceEvents(dtermb,'b'); - interfaceEvents(dtermc,'c'); - interfaceEvents(dtermd,'d'); - interfaceEvents(dterme,'e'); - interfaceEvents(dtermf,'f'); - displayInterfaceCardAll(); - },200); - setTimeout(function(){ - compileInterfaceCardAll(); - },500); +/** + * Show the interface for the Memory H5P element type + */ +function interfacememory () { + interfacedialogcard() } -function plusDialogCard(){ +/** + * Show the interface for the Dialog Card H5P element type + */ +function interfacedialogcard () { + + $('.dataTables_wrapper').css('display', 'none') + $('#dictionary_node_type').parent().parent().css('display', 'none') + $('#nodeselection').parent().parent().css('display', 'none') + + $('#dictionary_title').parent().parent().css('display', '') + $('#dictionary_title').parent().append('' + $('#h5p_title_help').html() + '') + + $('#dictionary_submit').parent().parent().css('display', '') + + $('#dictionary_descript').parent().parent().css('display', '') + $('#dictionary_descript').parent().append('' + $('#h5p_dialogcard_help').html() + '') + $('#dictionary_descript').val($('#h5p_dialogcard_tutor').html()) + + $('#dictionary').css('display', '') + $('#addElement').css('display', 'none') + $('#nodeselection').css('display', 'none') + + $('#dictionary_terms_a').parent().parent().css('display', '') + var dterma = $('#dictionary_terms_a').val() + $('#dictionary_terms_a').parent().append(interfaceCard('a', dterma)) + interfaceNameLabel('terms_a', $('#h5p_dialogcard_term_a').html()) + + $('#dictionary_terms_b').parent().parent().css('display', '') + var dtermb = $('#dictionary_terms_b').val() + $('#dictionary_terms_b').parent().append(interfaceCard('b', dtermb)) + interfaceNameLabel('terms_b', '') + + $('#dictionary_terms_c').parent().parent().css('display', '') + var dtermc = $('#dictionary_terms_c').val() + $('#dictionary_terms_c').parent().append(interfaceCard('c', dtermc)) + interfaceNameLabel('terms_c', '') + + $('#dictionary_terms_d').parent().parent().css('display', '') + var dtermd = $('#dictionary_terms_d').val() + $('#dictionary_terms_d').parent().append(interfaceCard('d', dtermd)) + + interfaceNameLabel('terms_d', '') + + $('#dictionary_terms_e').parent().parent().css('display', '') + var dterme = $('#dictionary_terms_e').val() + $('#dictionary_terms_e').parent().append(interfaceCard('e', dterme)) + + interfaceNameLabel('terms_e', '') + + $('#dictionary_terms_f').parent().parent().css('display', '') + var dtermf = $('#dictionary_terms_f').val() + $('#dictionary_terms_f').parent().append(interfaceCard('f', dtermf)) + + interfaceNameLabel('terms_f', '') - var h = '
    '; - h += ''; - h += '
    '; - $("#dictionary_terms_f").parent().append(h); + plusDialogCard() + + setTimeout(function () { + interfaceEvents(dterma, 'a') + interfaceEvents(dtermb, 'b') + interfaceEvents(dtermc, 'c') + interfaceEvents(dtermd, 'd') + interfaceEvents(dterme, 'e') + interfaceEvents(dtermf, 'f') + displayInterfaceCardAll() + }, 200) + setTimeout(function () { + compileInterfaceCardAll() + }, 500) } -function plusDialogCardProcess(){ - - if(lastCardBlockId=='a'){ - $(".cardBlockEditb").css("display","block"); - $('#outrecto' + 'b').val('?'); - } - if(lastCardBlockId=='b'){ - $(".cardBlockEditc").css("display","block"); - $('#outrecto' + 'c').val('?'); - } - if(lastCardBlockId=='c'){ - $(".cardBlockEditd").css("display","block"); - $('#outrecto' + 'd').val('?'); - } - if(lastCardBlockId=='d'){ - $(".cardBlockEdite").css("display","block"); - $('#outrecto' + 'e').val('?'); - } - if(lastCardBlockId=='e'){ - $(".cardBlockEditf").css("display","block"); - $('#outrecto' + 'f').val('?'); - } +/** + * Add a dialog card + */ +function plusDialogCard () { + + var h = '
    ' + h += '' + h += '
    ' + $('#dictionary_terms_f').parent().append(h) - displayInterfaceCardAll(); } -function interfaceCard(letterId,collTerms){ +/** + * Add a dialog card process + */ +function plusDialogCardProcess () { + + if (lastCardBlockId == 'a') { + $('.cardBlockEditb').css('display', 'block') + $('#outrecto' + 'b').val('?') + } + if (lastCardBlockId == 'b') { + $('.cardBlockEditc').css('display', 'block') + $('#outrecto' + 'c').val('?') + } + if (lastCardBlockId == 'c') { + $('.cardBlockEditd').css('display', 'block') + $('#outrecto' + 'd').val('?') + } + if (lastCardBlockId == 'd') { + $('.cardBlockEdite').css('display', 'block') + $('#outrecto' + 'e').val('?') + } + if (lastCardBlockId == 'e') { + $('.cardBlockEditf').css('display', 'block') + $('#outrecto' + 'f').val('?') + } + + displayInterfaceCardAll() +} - $("#dictionary_terms_" + letterId).css("display","none"); +/** + * Show the interface for the Card H5P element type + */ +function interfaceCard (letterId, collTerms) { - $("#dictionary_terms_" + letterId).parent().parent().css("margin-bottom","0px"); - - var h = '
    '; + $('#dictionary_terms_' + letterId).css('display', 'none') - h += '

    Recto : 
    '; - h += '
    '; - - if(GlobalTypeNode=='memory'){ - h += '