parent
0d054f1750
commit
954b23a95d
@ -0,0 +1,12 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin. |
||||
* |
||||
* @package chamilo.plugin.notebookteacher |
||||
* |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com> |
||||
*/ |
||||
require_once __DIR__ . '/../../main/inc/global.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; |
||||
require_once api_get_path(SYS_PLUGIN_PATH) . 'notebookteacher/src/notebookteacher_plugin.class.php'; |
@ -0,0 +1,41 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* Plugin database installation script. Can only be executed if included |
||||
* inside another script loading global.inc.php. |
||||
* |
||||
* @package chamilo.plugin.notebookteacher |
||||
*/ |
||||
/** |
||||
* Check if script can be called |
||||
*/ |
||||
if (!function_exists('api_get_path')) { |
||||
die('This script must be loaded through the Chamilo plugin installer sequence'); |
||||
} |
||||
|
||||
$entityManager = Database::getManager(); |
||||
$pluginSchema = new \Doctrine\DBAL\Schema\Schema(); |
||||
$connection = $entityManager->getConnection(); |
||||
$platform = $connection->getDatabasePlatform(); |
||||
|
||||
//Create tables |
||||
$notebookTable = $pluginSchema->createTable(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER); |
||||
$notebookTable->addColumn('id', \Doctrine\DBAL\Types\Type::INTEGER, ['autoincrement' => true, 'unsigned' => true]); |
||||
$notebookTable->addColumn('c_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$notebookTable->addColumn('session_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$notebookTable->addColumn('user_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$notebookTable->addColumn('student_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$notebookTable->addColumn('course', \Doctrine\DBAL\Types\Type::STRING); |
||||
$notebookTable->addColumn('title', \Doctrine\DBAL\Types\Type::STRING); |
||||
$notebookTable->addColumn('description', \Doctrine\DBAL\Types\Type::TEXT); |
||||
$notebookTable->addColumn('creation_date', \Doctrine\DBAL\Types\Type::DATETIME); |
||||
$notebookTable->addColumn('update_date', \Doctrine\DBAL\Types\Type::DATETIME); |
||||
$notebookTable->addColumn('status', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$notebookTable->addIndex(['c_id']); |
||||
$notebookTable->setPrimaryKey(['id']); |
||||
|
||||
$queries = $pluginSchema->toSql($platform); |
||||
|
||||
foreach ($queries as $query) { |
||||
Database::query($query); |
||||
} |
@ -0,0 +1,3 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
require_once 'config.php'; |
@ -0,0 +1,16 @@ |
||||
<?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.notebookteacher |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
require_once __DIR__ . '/config.php'; |
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
NotebookTeacherPlugin::create()->install(); |
@ -0,0 +1,13 @@ |
||||
<?php |
||||
$strings['plugin_title'] = "Teacher notes"; |
||||
$strings['plugin_comment'] = "This plugin allows the teachers of a course to have a shared notebook. Students do not have access."; |
||||
$strings['NotebookTeacher'] = "Teacher notes"; |
||||
$strings['enable_plugin_notebookteacher'] = "Enable plugin"; |
||||
$strings['ToolDisabled'] = "The tool is disabled from the administration"; |
||||
$strings['ToolForTeacher'] = "Exclusive tool for teachers"; |
||||
$strings['AllStudent'] = "All students"; |
||||
$strings['StudentFilter'] = "Student filter"; |
||||
$strings['NoNotebookFilter'] = "No notes created with the current filter"; |
||||
$strings['NoNotebook'] = "No notes created in the system"; |
||||
$strings['NoNotebookUser'] = "No notes for this student"; |
||||
$strings['NotebookNoStudentAssigned'] = "Notes without assigned students"; |
@ -0,0 +1,13 @@ |
||||
<?php |
||||
$strings['plugin_title'] = "Notas profesores"; |
||||
$strings['plugin_comment'] = "Este plugin permite a los profesores de un curso tener un bloc de notas compartido. Alumnos no tienen acceso."; |
||||
$strings['NotebookTeacher'] = "Notas profesores"; |
||||
$strings['enable_plugin_notebookteacher'] = "Activar plugin"; |
||||
$strings['ToolDisabled'] = "La herramienta está deshabilitada desde la administración"; |
||||
$strings['ToolForTeacher'] = "Herramienta exclusiva para profesores"; |
||||
$strings['AllStudent'] = "Todos los estudiantes"; |
||||
$strings['StudentFilter'] = "Filtro estudiantes"; |
||||
$strings['NoNotebookFilter'] = "No hay notas creadas con el filtro actual"; |
||||
$strings['NoNotebook'] = "No hay notas creadas en el sistema"; |
||||
$strings['NoNotebookUser'] = "No hay notas para este alumno"; |
||||
$strings['NotebookNoStudentAssigned'] = "Notas sin estudiantes asignados"; |
@ -0,0 +1,14 @@ |
||||
<?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.notebookteacher |
||||
*/ |
||||
/** |
||||
* Plugin details (must be present) |
||||
*/ |
||||
require_once __DIR__ . '/config.php'; |
||||
$plugin_info = NotebookTeacherPlugin::create()->get_info(); |
@ -0,0 +1,19 @@ |
||||
Este plugin da la posibilidad a los profesores de un curso escribir en un bloc de notas compartido.<br> |
||||
Los estudiantes no tienen acceso a las notas compartidas de los profesores.<br/><br/> |
||||
<b>Instrucciones de puesta en funcionamiento:</b><br> |
||||
- Subir la carpeta <b>notebookteacher</b> a la carpeta plugin de chamilo.<br> |
||||
|
||||
- Habilitar el plugin en la administración de Chamilo.<br> |
||||
- El icono de la herramienta aparecerá en pantalla de los cursos con el resto de herramientas<br> |
||||
- Si no se visualiza el icono en el cursos correctamente y sale el icono de plugin genérico:<br> |
||||
<ul> |
||||
<li>Copiar los iconos de la carpeta resources/img/64 dentro de /main/img/icons/64</li> |
||||
<li>Copiar el icono de la carpeta resources/img/22 dentro de /main/img</li> |
||||
</ul> |
||||
<br> |
||||
<b>Solo si ya tiene instalado el plugin previamente:</b><br> |
||||
Para actualizar la base de datos del plugin con los últimos cambios de la estructura deberá poner en su |
||||
navegador la siguiente dirección cambiando el nombre del dominio con el que proceda en su caso.<br> |
||||
http://<i>sudominio.com/</i><b>plugin/notebookteacher/update.php</b> |
||||
</p> |
||||
<br> |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.3 KiB |
@ -0,0 +1,7 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* Index of the Test to pdf plugin courses list. |
||||
* |
||||
* @package chamilo.plugin.notebookteacher |
||||
*/ |
@ -0,0 +1,390 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
$course_plugin = 'notebookteacher'; |
||||
require_once __DIR__.'/../config.php'; |
||||
require_once __DIR__.'/notebookteacher.lib.php'; |
||||
|
||||
$_setting['student_view_enabled'] = 'false'; |
||||
|
||||
$plugin = NotebookTeacherPlugin::create(); |
||||
$current_course_tool = $plugin->get_lang('NotebookTeacher'); |
||||
$enable = $plugin->get('enable_plugin_notebookteacher') == 'true'; |
||||
|
||||
if ($enable) { |
||||
if (api_is_teacher() || api_is_drh()) { |
||||
// The section (tabs) |
||||
$this_section = SECTION_COURSES; |
||||
|
||||
// Notice for unauthorized people. |
||||
api_protect_course_script(true); |
||||
$location = 'index.php?'.api_get_cidreq(); |
||||
|
||||
// Additional javascript |
||||
$htmlHeadXtra[] = NotebookTeacher::javascript_notebook(); |
||||
$htmlHeadXtra[] = '<script> |
||||
function setFocus(){ |
||||
$("#note_title").focus(); |
||||
} |
||||
$(document).ready(function () { |
||||
setFocus(); |
||||
}); |
||||
|
||||
function filter_student() { |
||||
var student_id = $("#student_filter").val(); |
||||
location.href ="'.$location.'&student_id="+student_id; |
||||
} |
||||
</script>'; |
||||
|
||||
// Setting the tool constants |
||||
$tool = $plugin->get_lang('NotebookTeacher'); |
||||
|
||||
// Tracking |
||||
Event::event_access_tool('notebookteacher'); |
||||
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : ''; |
||||
|
||||
// Tool name |
||||
if ($action === 'addnote') { |
||||
$tool = 'NoteAddNew'; |
||||
$interbreadcrumb[] = ['url' => 'index.php?'.api_get_cidreq(), 'name' => $plugin->get_lang('NotebookTeacher')]; |
||||
} |
||||
if ($action === 'editnote') { |
||||
$tool = 'ModifyNote'; |
||||
$interbreadcrumb[] = ['url' => 'index.php?'.api_get_cidreq(), 'name' => $plugin->get_lang('NotebookTeacher')]; |
||||
} |
||||
|
||||
// Displaying the header |
||||
Display::display_header(get_lang(ucfirst($tool))); |
||||
|
||||
// Tool introduction |
||||
Display::display_introduction_section($plugin->get_lang('NotebookTeacher')); |
||||
|
||||
// Action handling: Adding a note |
||||
if ($action === 'addnote') { |
||||
if ((api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true) || api_is_drh())) { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$_SESSION['notebook_view'] = 'creation_date'; |
||||
|
||||
$form = new FormValidator( |
||||
'note', |
||||
'post', |
||||
api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq() |
||||
); |
||||
// Setting the form elements |
||||
$form->addElement('header', '', get_lang('NoteAddNew')); |
||||
$form->addElement('text', 'note_title', get_lang('NoteTitle'), ['id' => 'note_title']); |
||||
|
||||
$student_id = isset($_GET['student_id']) ? $_GET['student_id'] : null; |
||||
$sessionId = api_get_session_id(); |
||||
$courseCode = api_get_course_id(); |
||||
$active = isset($_GET['active']) ? $_GET['active'] : null; |
||||
$status = STUDENT; |
||||
$course_info = api_get_course_info(); |
||||
$courseId = $course_info['real_id']; |
||||
$current_access_url_id = api_get_current_access_url_id(); |
||||
$sort_by_first_name = api_sort_by_first_name(); |
||||
|
||||
if (!empty($sessionId)) { |
||||
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
||||
$table_users = Database::get_main_table(TABLE_MAIN_USER); |
||||
$sql = "SELECT DISTINCT |
||||
user.user_id, ".($is_western_name_order |
||||
? "user.firstname, user.lastname" |
||||
: "user.lastname, user.firstname")." |
||||
FROM $table_session_course_user as session_course_user, |
||||
$table_users as user "; |
||||
if (api_is_multiple_url_enabled()) { |
||||
$sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; |
||||
} |
||||
$sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
||||
$sql .= ' AND session_id = '.$sessionId; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$sql .= " AND user.user_id = au.user_id AND access_url_id = $current_access_url_id "; |
||||
} |
||||
|
||||
// only users no coaches/teachers |
||||
if ($type == COURSEMANAGER) { |
||||
$sql .= " AND session_course_user.status = 2 "; |
||||
} else { |
||||
$sql .= " AND session_course_user.status = 0 "; |
||||
} |
||||
$sql .= $sort_by_first_name ? |
||||
' ORDER BY user.firstname, user.lastname' : |
||||
' ORDER BY user.lastname, user.firstname'; |
||||
|
||||
$rs = Database::query($sql); |
||||
|
||||
$a_course_users = []; |
||||
while ($row = Database::fetch_assoc($rs)) { |
||||
$a_course_users[$row['user_id']] = $row; |
||||
} |
||||
} else { |
||||
$a_course_users = CourseManager::get_user_list_from_course_code( |
||||
$courseCode, |
||||
0, |
||||
null, |
||||
null, |
||||
$status, |
||||
null, |
||||
false, |
||||
false, |
||||
null, |
||||
null, |
||||
null, |
||||
$active |
||||
); |
||||
} |
||||
|
||||
$studentList = []; |
||||
$studentList[0] = ''; |
||||
foreach ($a_course_users as $key => $user_item) { |
||||
$studentList[$key] = $user_item['firstname'].' '.$user_item['lastname']; |
||||
} |
||||
|
||||
$form->addElement( |
||||
'select', |
||||
'student_id', |
||||
get_lang('Student'), |
||||
$studentList, |
||||
[ |
||||
'id' => 'student_id', |
||||
] |
||||
); |
||||
|
||||
$form->addElement( |
||||
'html_editor', |
||||
'note_comment', |
||||
get_lang('NoteComment'), |
||||
null, |
||||
api_is_allowed_to_edit() |
||||
? ['ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300'] |
||||
: ['ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'] |
||||
); |
||||
$form->addButtonCreate(get_lang('AddNote'), 'SubmitNote'); |
||||
|
||||
// Setting the rules |
||||
$form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required'); |
||||
|
||||
// The validation or display |
||||
if ($form->validate()) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$values = $form->exportValues(); |
||||
$res = NotebookTeacher::save_note($values); |
||||
if ($res) { |
||||
echo Display::return_message(get_lang('NoteAdded'), 'confirmation'); |
||||
} |
||||
} |
||||
Security::clear_token(); |
||||
NotebookTeacher::display_notes(); |
||||
} else { |
||||
echo '<div class="actions">'; |
||||
echo '<a href="index.php">'. |
||||
Display::return_icon('back.png', get_lang('BackToNotesList'), '', ICON_SIZE_MEDIUM). |
||||
'</a>'; |
||||
echo '</div>'; |
||||
$token = Security::get_token(); |
||||
$form->addElement('hidden', 'sec_token'); |
||||
$form->setConstants(['sec_token' => $token]); |
||||
$form->display(); |
||||
} |
||||
} elseif ($action === 'editnote' && is_numeric($_GET['notebook_id'])) { |
||||
// Action handling: Editing a note |
||||
if (!empty($_GET['isStudentView']) || api_is_drh()) { |
||||
NotebookTeacher::display_notes(); |
||||
exit; |
||||
} |
||||
|
||||
// Initialize the object |
||||
$form = new FormValidator( |
||||
'note', |
||||
'post', |
||||
api_get_self().'?action='.Security::remove_XSS($_GET['action']). |
||||
'¬ebook_id='.intval($_GET['notebook_id']).'&'.api_get_cidreq() |
||||
); |
||||
// Setting the form elements |
||||
$form->addElement('header', '', get_lang('ModifyNote')); |
||||
$form->addElement('hidden', 'notebook_id'); |
||||
$form->addElement('text', 'note_title', get_lang('NoteTitle'), ['size' => '100']); |
||||
|
||||
$sessionId = api_get_session_id(); |
||||
$courseCode = api_get_course_id(); |
||||
$active = isset($_GET['active']) ? $_GET['active'] : null; |
||||
$status = STUDENT; |
||||
$student_id = isset($_GET['student_id']) ? $_GET['student_id'] : null; |
||||
$course_info = api_get_course_info(); |
||||
$courseId = $course_info['real_id']; |
||||
$current_access_url_id = api_get_current_access_url_id(); |
||||
$sort_by_first_name = api_sort_by_first_name(); |
||||
|
||||
if (!empty($sessionId)) { |
||||
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
||||
$table_users = Database::get_main_table(TABLE_MAIN_USER); |
||||
$sql = "SELECT DISTINCT |
||||
user.user_id, ".($is_western_name_order |
||||
? "user.firstname, user.lastname" |
||||
: "user.lastname, user.firstname")." |
||||
FROM $table_session_course_user as session_course_user, |
||||
$table_users as user "; |
||||
if (api_is_multiple_url_enabled()) { |
||||
$sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; |
||||
} |
||||
$sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
||||
$sql .= ' AND session_id = '.$sessionId; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$sql .= " AND user.user_id = au.user_id AND access_url_id = $current_access_url_id "; |
||||
} |
||||
|
||||
// only users no coaches/teachers |
||||
if ($type == COURSEMANAGER) { |
||||
$sql .= " AND session_course_user.status = 2 "; |
||||
} else { |
||||
$sql .= " AND session_course_user.status = 0 "; |
||||
} |
||||
$sql .= $sort_by_first_name |
||||
? ' ORDER BY user.firstname, user.lastname' |
||||
: ' ORDER BY user.lastname, user.firstname'; |
||||
|
||||
$rs = Database::query($sql); |
||||
|
||||
$a_course_users = []; |
||||
while ($row = Database::fetch_assoc($rs)) { |
||||
$a_course_users[$row['user_id']] = $row; |
||||
} |
||||
} else { |
||||
$a_course_users = CourseManager::get_user_list_from_course_code( |
||||
$courseCode, |
||||
0, |
||||
null, |
||||
null, |
||||
$status, |
||||
null, |
||||
false, |
||||
false, |
||||
null, |
||||
null, |
||||
null, |
||||
$active |
||||
); |
||||
} |
||||
|
||||
$studentList = []; |
||||
$studentList[0] = ''; |
||||
foreach ($a_course_users as $key => $user_item) { |
||||
$studentList[$key] = $user_item['firstname'].' '.$user_item['lastname']; |
||||
} |
||||
|
||||
$form->addElement( |
||||
'select', |
||||
'student_id', |
||||
get_lang('Student'), |
||||
$studentList, |
||||
[ |
||||
'id' => 'student_id', |
||||
] |
||||
); |
||||
|
||||
$form->addElement( |
||||
'html_editor', |
||||
'note_comment', |
||||
get_lang('NoteComment'), |
||||
null, |
||||
api_is_allowed_to_edit() |
||||
? ['ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300'] |
||||
: ['ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'] |
||||
); |
||||
$form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote'); |
||||
|
||||
// Setting the defaults |
||||
$defaults = NotebookTeacher::get_note_information(Security::remove_XSS($_GET['notebook_id'])); |
||||
$form->setDefaults($defaults); |
||||
|
||||
// Setting the rules |
||||
$form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required'); |
||||
|
||||
// The validation or display |
||||
if ($form->validate()) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$values = $form->exportValues(); |
||||
$res = NotebookTeacher::update_note($values); |
||||
if ($res) { |
||||
echo Display::return_message(get_lang('NoteUpdated'), 'confirmation'); |
||||
} |
||||
} |
||||
Security::clear_token(); |
||||
NotebookTeacher::display_notes(); |
||||
} else { |
||||
echo '<div class="actions">'; |
||||
echo '<a href="index.php">'. |
||||
Display::return_icon('back.png', get_lang('BackToNotesList'), '', ICON_SIZE_MEDIUM).'</a>'; |
||||
echo '</div>'; |
||||
$token = Security::get_token(); |
||||
$form->addElement('hidden', 'sec_token'); |
||||
$form->setConstants(['sec_token' => $token]); |
||||
$form->display(); |
||||
} |
||||
} elseif ($action === 'deletenote' && is_numeric($_GET['notebook_id'])) { |
||||
// Action handling: deleting a note |
||||
$res = NotebookTeacher::delete_note($_GET['notebook_id']); |
||||
if ($res) { |
||||
echo Display::return_message(get_lang('NoteDeleted'), 'confirmation'); |
||||
} |
||||
|
||||
NotebookTeacher::display_notes(); |
||||
} elseif ( |
||||
$action === 'changeview' && in_array($_GET['view'], ['creation_date', 'update_date', 'title'])) { |
||||
|
||||
// Action handling: changing the view (sorting order) |
||||
switch ($_GET['view']) { |
||||
case 'creation_date': |
||||
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') { |
||||
echo Display::return_message(get_lang('NotesSortedByCreationDateAsc'), 'confirmation'); |
||||
} else { |
||||
echo Display::return_message(get_lang('NotesSortedByCreationDateDESC'), 'confirmation'); |
||||
} |
||||
break; |
||||
case 'update_date': |
||||
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') { |
||||
echo Display::return_message(get_lang('NotesSortedByUpdateDateAsc'), 'confirmation'); |
||||
} else { |
||||
echo Display::return_message(get_lang('NotesSortedByUpdateDateDESC'), 'confirmation'); |
||||
} |
||||
break; |
||||
case 'title': |
||||
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') { |
||||
echo Display::return_message(get_lang('NotesSortedByTitleAsc'), 'confirmation'); |
||||
} else { |
||||
echo Display::return_message(get_lang('NotesSortedByTitleDESC'), 'confirmation'); |
||||
} |
||||
break; |
||||
} |
||||
$_SESSION['notebook_view'] = $_GET['view']; |
||||
NotebookTeacher::display_notes(); |
||||
} else { |
||||
NotebookTeacher::display_notes(); |
||||
} |
||||
|
||||
Display::display_footer(); |
||||
} else { |
||||
/** @var \Chamilo\CoreBundle\Entity\Session $session */ |
||||
$session = Database::getManager() |
||||
->find('ChamiloCoreBundle:Session', api_get_session_id()); |
||||
$_course = api_get_course_info(); |
||||
$web_course_path = api_get_path(WEB_COURSE_PATH); |
||||
$url = $web_course_path.$_course['path'].'/index.php'.($session ? '?id_session='.$session->getId() : ''); |
||||
|
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('ToolForTeacher')) |
||||
); |
||||
|
||||
header('Location: ' . $url); |
||||
} |
||||
} else { |
||||
echo $plugin->get_lang('ToolDisabled'); |
||||
} |
@ -0,0 +1,487 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
require_once __DIR__.'/../config.php'; |
||||
/** |
||||
* This class provides methods for the notebook management. |
||||
* Include/require it in your code to use its features. |
||||
* |
||||
* @author Carlos Vargas <litox84@gmail.com>, move code of main/notebook up here |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com>, adaptation for the plugin |
||||
* |
||||
* @package chamilo.library |
||||
*/ |
||||
class NotebookTeacher |
||||
{ |
||||
/** |
||||
* Constructor |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* a little bit of javascript to display a prettier warning when deleting a note |
||||
* |
||||
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium |
||||
* |
||||
* @version januari 2009, dokeos 1.8.6 |
||||
* |
||||
* @return string |
||||
*/ |
||||
public static function javascript_notebook() |
||||
{ |
||||
return "<script> |
||||
function confirmation (name) |
||||
{ |
||||
if (confirm(\" " . get_lang("NoteConfirmDelete")." \"+ name + \" ?\")) |
||||
{return true;} |
||||
else |
||||
{return false;} |
||||
} |
||||
</script>"; |
||||
} |
||||
|
||||
/** |
||||
* This functions stores the note in the database |
||||
* |
||||
* @param array $values |
||||
* @param int $userId Optional. The user ID |
||||
* @param int $courseId Optional. The course ID |
||||
* @param int $sessionId Optional. The session ID |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public static function save_note($values, $userId = 0, $courseId = 0, $sessionId = 0) |
||||
{ |
||||
if (!is_array($values) || empty($values['note_title'])) { |
||||
return false; |
||||
} |
||||
|
||||
// Database table definition |
||||
$table = Database::get_main_table(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER); |
||||
$userId = $userId ?: api_get_user_id(); |
||||
$courseId = $courseId ?: api_get_course_int_id(); |
||||
$courseInfo = api_get_course_info_by_id($courseId); |
||||
$courseCode = $courseInfo['code']; |
||||
$sessionId = $sessionId ?: api_get_session_id(); |
||||
$now = api_get_utc_datetime(); |
||||
$params = [ |
||||
'c_id' => $courseId, |
||||
'session_id' => $sessionId, |
||||
'user_id' => $userId, |
||||
'student_id' => intval($values['student_id']), |
||||
'course' => $courseCode, |
||||
'title' => $values['note_title'], |
||||
'description' => $values['note_comment'], |
||||
'creation_date' => $now, |
||||
'update_date' => $now, |
||||
'status' => 0, |
||||
]; |
||||
$id = Database::insert($table, $params); |
||||
|
||||
if ($id > 0) { |
||||
return $id; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @param int $notebook_id |
||||
* |
||||
* @return array|mixed |
||||
*/ |
||||
public static function get_note_information($notebook_id) |
||||
{ |
||||
if (empty($notebook_id)) { |
||||
return []; |
||||
} |
||||
|
||||
// Database table definition |
||||
$tableNotebook = Database::get_main_table(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER); |
||||
$courseId = api_get_course_int_id(); |
||||
|
||||
$sql = "SELECT |
||||
id AS notebook_id, |
||||
title AS note_title, |
||||
description AS note_comment, |
||||
session_id AS session_id, |
||||
student_id AS student_id |
||||
FROM $tableNotebook |
||||
WHERE c_id = $courseId AND id = '".intval($notebook_id)."' "; |
||||
$result = Database::query($sql); |
||||
if (Database::num_rows($result) != 1) { |
||||
return []; |
||||
} |
||||
return Database::fetch_array($result); |
||||
} |
||||
|
||||
/** |
||||
* This functions updates the note in the database. |
||||
* |
||||
* @param array $values |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public static function update_note($values) |
||||
{ |
||||
if (!is_array($values) or empty($values['note_title'])) { |
||||
return false; |
||||
} |
||||
// Database table definition |
||||
$table = Database::get_main_table(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER); |
||||
|
||||
$courseId = api_get_course_int_id(); |
||||
$sessionId = api_get_session_id(); |
||||
|
||||
$params = [ |
||||
'user_id' => api_get_user_id(), |
||||
'student_id' => intval($values['student_id']), |
||||
'course' => api_get_course_id(), |
||||
'session_id' => $sessionId, |
||||
'title' => $values['note_title'], |
||||
'description' => $values['note_comment'], |
||||
'update_date' => api_get_utc_datetime() |
||||
]; |
||||
|
||||
Database::update( |
||||
$table, |
||||
$params, |
||||
[ |
||||
'c_id = ? AND id = ?' => [ |
||||
$courseId, |
||||
$values['notebook_id'] |
||||
], |
||||
] |
||||
); |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @param int $notebook_id |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public static function delete_note($notebook_id) |
||||
{ |
||||
if (empty($notebook_id) || $notebook_id != strval(intval($notebook_id))) { |
||||
return false; |
||||
} |
||||
|
||||
// Database table definition |
||||
$tableNotebook = Database::get_main_table(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER); |
||||
|
||||
$courseId = api_get_course_int_id(); |
||||
|
||||
$sql = "DELETE FROM $tableNotebook |
||||
WHERE |
||||
c_id = $courseId AND |
||||
id = '".intval($notebook_id)."' AND |
||||
user_id = '" . api_get_user_id()."'"; |
||||
$result = Database::query($sql); |
||||
|
||||
if (Database::affected_rows($result) != 1) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Display notes. |
||||
*/ |
||||
public static function display_notes() |
||||
{ |
||||
$plugin = NotebookTeacherPlugin::create(); |
||||
$_user = api_get_user_info(); |
||||
if (!isset($_GET['direction'])) { |
||||
$sortDirection = 'ASC'; |
||||
$linkSortDirection = 'DESC'; |
||||
} elseif ($_GET['direction'] == 'ASC') { |
||||
$sortDirection = 'ASC'; |
||||
$linkSortDirection = 'DESC'; |
||||
} else { |
||||
$sortDirection = 'DESC'; |
||||
$linkSortDirection = 'ASC'; |
||||
} |
||||
|
||||
$studentId = isset($_GET['student_id']) ? $_GET['student_id'] : null; |
||||
$selectStudent = ''; |
||||
$sessionId = api_get_session_id(); |
||||
$courseCode = api_get_course_id(); |
||||
$active = isset($_GET['active']) ? $_GET['active'] : null; |
||||
$status = STUDENT; |
||||
$courseInfo = api_get_course_info(); |
||||
$courseId = $courseInfo['real_id']; |
||||
$currentAccessUrlId = api_get_current_access_url_id(); |
||||
$sortByfirstName = api_sort_by_first_name(); |
||||
|
||||
if (!empty($sessionId)) { |
||||
$tableSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
||||
$tableUsers = Database::get_main_table(TABLE_MAIN_USER); |
||||
$sql = "SELECT DISTINCT |
||||
user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname")." |
||||
FROM $tableSessionCourseUser as session_course_user, |
||||
$tableUsers as user "; |
||||
if (api_is_multiple_url_enabled()) { |
||||
$sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; |
||||
} |
||||
$sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
||||
$sql .= ' AND session_id = '.$sessionId; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$sql .= " AND user.user_id = au.user_id AND access_url_id = $currentAccessUrlId "; |
||||
} |
||||
|
||||
// only users no coaches/teachers |
||||
if ($type == COURSEMANAGER) { |
||||
$sql .= " AND session_course_user.status = 2 "; |
||||
} else { |
||||
$sql .= " AND session_course_user.status = 0 "; |
||||
} |
||||
$sql .= $sortByfirstName ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; |
||||
|
||||
$rs = Database::query($sql); |
||||
|
||||
$courseUsersList = []; |
||||
while ($row = Database::fetch_assoc($rs)) { |
||||
$courseUsersList[$row['user_id']] = $row; |
||||
} |
||||
} else { |
||||
$courseUsersList = CourseManager::get_user_list_from_course_code( |
||||
$courseCode, |
||||
0, |
||||
null, |
||||
null, |
||||
$status, |
||||
null, |
||||
false, |
||||
false, |
||||
null, |
||||
null, |
||||
null, |
||||
$active |
||||
); |
||||
} |
||||
|
||||
$form = new FormValidator('search_student'); |
||||
|
||||
// Status |
||||
$students = []; |
||||
$students[] = $plugin->get_lang('AllStudent'); |
||||
foreach ($courseUsersList as $key => $userItem) { |
||||
$students[$key] = $userItem['firstname'].' '.$userItem['lastname']; |
||||
} |
||||
|
||||
$form->addElement( |
||||
'select', |
||||
'student_filter', |
||||
$plugin->get_lang('StudentFilter'), |
||||
$students, |
||||
[ |
||||
'id' => 'student_filter', |
||||
'onchange' => 'javascript: filter_student();', |
||||
] |
||||
); |
||||
$user_data = ['student_filter' => $studentId]; |
||||
$form->setDefaults($user_data); |
||||
|
||||
$selectStudent = $form->returnForm(); |
||||
|
||||
// action links |
||||
echo '<div class="actions">'; |
||||
if (!api_is_drh()) { |
||||
if (!api_is_anonymous()) { |
||||
if (api_get_session_id() == 0) { |
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=addnote">'. |
||||
Display::return_icon( |
||||
'new_note.png', |
||||
get_lang('NoteAddNew'), |
||||
'', |
||||
'32' |
||||
).'</a>'; |
||||
} elseif (api_is_allowed_to_session_edit(false, true)) { |
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=addnote">'. |
||||
Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32').'</a>'; |
||||
} |
||||
} else { |
||||
echo '<a href="javascript:void(0)">'. |
||||
Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32').'</a>'; |
||||
} |
||||
} |
||||
|
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=creation_date&direction='.$linkSortDirection.'&student_id='.$studentId.'">'. |
||||
Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32').'</a>'; |
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=update_date&direction='.$linkSortDirection.'&student_id='.$studentId.'">'. |
||||
Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32').'</a>'; |
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=title&direction='.$linkSortDirection.'&student_id='.$studentId.'">'. |
||||
Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32').'</a>'; |
||||
|
||||
echo '</div>'; |
||||
echo '<div class="row">'.$selectStudent.'</div>'; |
||||
|
||||
if (!isset($_SESSION['notebook_view']) || |
||||
!in_array($_SESSION['notebook_view'], ['creation_date', 'update_date', 'title']) |
||||
) { |
||||
$_SESSION['notebook_view'] = 'creation_date'; |
||||
} |
||||
|
||||
// Database table definition |
||||
$tableNotebook = Database::get_main_table(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER); |
||||
if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') { |
||||
$orderBy = " ORDER BY ".$_SESSION['notebook_view']." $sortDirection "; |
||||
} else { |
||||
$orderBy = " ORDER BY ".$_SESSION['notebook_view']." $sortDirection "; |
||||
} |
||||
|
||||
//condition for the session |
||||
$session_id = api_get_session_id(); |
||||
$conditionSession = api_get_session_condition($session_id); |
||||
|
||||
$condExtra = ($_SESSION['notebook_view'] == 'update_date') ? " AND update_date <> ''" : " "; |
||||
$courseId = api_get_course_int_id(); |
||||
|
||||
if ($studentId > 0) { |
||||
// Only one student |
||||
$conditionStudent = " AND student_id = $studentId"; |
||||
|
||||
$sql = "SELECT * FROM $tableNotebook |
||||
WHERE |
||||
c_id = $courseId |
||||
$conditionSession |
||||
$conditionStudent |
||||
$condExtra $orderBy |
||||
"; |
||||
$first = true; |
||||
$result = Database::query($sql); |
||||
if (Database::num_rows($result) > 0) { |
||||
while ($row = Database::fetch_array($result)) { |
||||
if ($first) { |
||||
if ($row['student_id'] > 0) { |
||||
$studentInfo = api_get_user_info($row['student_id']); |
||||
$studentText = $studentInfo['complete_name']; |
||||
} else { |
||||
$studentText = ''; |
||||
} |
||||
echo Display::page_subheader($studentText); |
||||
$first = false; |
||||
} |
||||
// Validation when belongs to a session |
||||
$sessionImg = api_get_session_image($row['session_id'], $_user['status']); |
||||
$updateValue = ''; |
||||
if ($row['update_date'] <> $row['creation_date']) { |
||||
$updateValue = ', '.get_lang('UpdateDate').': '.Display::dateToStringAgoAndLongDate($row['update_date']); |
||||
} |
||||
$userInfo = api_get_user_info($row['user_id']); |
||||
$author = ', '.get_lang('Teacher').': '.$userInfo['complete_name']; |
||||
|
||||
if (intval($row['user_id']) == api_get_user_id()) { |
||||
$actions = '<a href="'.api_get_self().'?'.api_get_cidreq().'action=editnote¬ebook_id='.$row['id'].'">'. |
||||
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
||||
$actions .= '<a href="'.api_get_self().'?action=deletenote¬ebook_id='.$row['id'].'" onclick="return confirmation(\''.$row['title'].'\');">'. |
||||
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
||||
} else { |
||||
$actions = ''; |
||||
} |
||||
|
||||
echo Display::panel( |
||||
$row['description'], |
||||
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>', |
||||
get_lang('CreationDate').': '.Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author |
||||
); |
||||
} |
||||
} else { |
||||
echo Display::return_message($plugin->get_lang('NoNotebookUser'), 'warning'); |
||||
} |
||||
} else { |
||||
// All students |
||||
foreach ($courseUsersList as $key => $userItem) { |
||||
$studentId = $key; |
||||
$studentText = $userItem['firstname'].' '.$userItem['lastname']; |
||||
|
||||
$conditionStudent = " AND student_id = $studentId"; |
||||
|
||||
$sql = "SELECT * FROM $tableNotebook |
||||
WHERE |
||||
c_id = $courseId |
||||
$conditionSession |
||||
$conditionStudent |
||||
$condExtra $orderBy |
||||
"; |
||||
|
||||
$result = Database::query($sql); |
||||
if (Database::num_rows($result) > 0) { |
||||
echo Display::page_subheader($studentText); |
||||
while ($row = Database::fetch_array($result)) { |
||||
|
||||
// Validation when belongs to a session |
||||
$sessionImg = api_get_session_image($row['session_id'], $_user['status']); |
||||
$updateValue = ''; |
||||
|
||||
if ($row['update_date'] <> $row['creation_date']) { |
||||
$updateValue = ', '.get_lang('UpdateDate').': '.Display::dateToStringAgoAndLongDate($row['update_date']); |
||||
} |
||||
|
||||
$userInfo = api_get_user_info($row['user_id']); |
||||
$author = ', '.get_lang('Teacher').': '.$userInfo['complete_name']; |
||||
|
||||
if (intval($row['user_id']) == api_get_user_id()) { |
||||
$actions = '<a href="'.api_get_self().'?action=editnote¬ebook_id='.$row['id'].'&'.api_get_cidreq().'">'. |
||||
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
||||
$actions .= '<a href="'.api_get_self().'?action=deletenote¬ebook_id='.$row['id'].'" onclick="return confirmation(\''.$row['title'].'\');">'. |
||||
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
||||
} else { |
||||
$actions = ''; |
||||
} |
||||
|
||||
echo Display::panel( |
||||
$row['description'], |
||||
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>', |
||||
get_lang('CreationDate').': '.Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author |
||||
); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$conditionStudent = " AND student_id = 0"; |
||||
|
||||
$sql = "SELECT * FROM $tableNotebook |
||||
WHERE |
||||
c_id = $courseId |
||||
$conditionSession |
||||
$conditionStudent |
||||
$condExtra $orderBy |
||||
"; |
||||
|
||||
$result = Database::query($sql); |
||||
if (Database::num_rows($result) > 0) { |
||||
echo Display::page_subheader($plugin->get_lang('NotebookNoStudentAssigned')); |
||||
while ($row = Database::fetch_array($result)) { |
||||
|
||||
// Validation when belongs to a session |
||||
$sessionImg = api_get_session_image($row['session_id'], $_user['status']); |
||||
$updateValue = ''; |
||||
|
||||
if ($row['update_date'] <> $row['creation_date']) { |
||||
$updateValue = ', '.get_lang('UpdateDate').': '.Display::dateToStringAgoAndLongDate($row['update_date']); |
||||
} |
||||
|
||||
$userInfo = api_get_user_info($row['user_id']); |
||||
$author = ', '.get_lang('Teacher').': '.$userInfo['complete_name']; |
||||
|
||||
if (intval($row['user_id']) == api_get_user_id()) { |
||||
$actions = '<a href="'.api_get_self().'?action=editnote¬ebook_id='.$row['id'].'&'.api_get_cidreq().'">'. |
||||
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
||||
$actions .= '<a href="'.api_get_self().'?action=deletenote¬ebook_id='.$row['id'].'" onclick="return confirmation(\''.$row['title'].'\');">'. |
||||
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
||||
} else { |
||||
$actions = ''; |
||||
} |
||||
|
||||
echo Display::panel( |
||||
$row['description'], |
||||
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>', |
||||
get_lang('CreationDate').': '.Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,125 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* Description of notebookteacher_plugin. |
||||
* |
||||
* @package chamilo.plugin.notebookteacher |
||||
* |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com> |
||||
*/ |
||||
/** |
||||
* Plugin class for the NotebookTeacher plugin. |
||||
*/ |
||||
class NotebookTeacherPlugin extends Plugin |
||||
{ |
||||
const TABLE_NOTEBOOKTEACHER = 'plugin_notebook_teacher'; |
||||
public $isCoursePlugin = true; |
||||
|
||||
protected function __construct() |
||||
{ |
||||
parent::__construct( |
||||
'1.1', |
||||
'Jose Angel Ruiz - NoSoloRed (original author)', |
||||
[ |
||||
'enable_plugin_notebookteacher' => 'boolean', |
||||
] |
||||
); |
||||
|
||||
$this->isAdminPlugin = true; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @return StaticPlugin |
||||
*/ |
||||
public static function create() |
||||
{ |
||||
static $result = null; |
||||
|
||||
return $result ? $result : $result = new self(); |
||||
} |
||||
|
||||
/** |
||||
* This method creates the tables required to this plugin. |
||||
*/ |
||||
public function install() |
||||
{ |
||||
//Installing course settings |
||||
$this->install_course_fields_in_all_courses(); |
||||
|
||||
$tablesToBeCompared = [ |
||||
self::TABLE_NOTEBOOKTEACHER |
||||
]; |
||||
$em = Database::getManager(); |
||||
$cn = $em->getConnection(); |
||||
$sm = $cn->getSchemaManager(); |
||||
$tables = $sm->tablesExist($tablesToBeCompared); |
||||
|
||||
if ($tables) { |
||||
return false; |
||||
} |
||||
|
||||
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png'; |
||||
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png'; |
||||
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png'; |
||||
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png'; |
||||
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png'; |
||||
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png'; |
||||
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png'; |
||||
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png'; |
||||
copy($srcfile1, $dstfile1); |
||||
copy($srcfile2, $dstfile2); |
||||
copy($srcfile3, $dstfile3); |
||||
copy($srcfile4, $dstfile4); |
||||
|
||||
require_once api_get_path(SYS_PLUGIN_PATH) . 'notebookteacher/database.php'; |
||||
} |
||||
|
||||
/** |
||||
* This method drops the plugin tables. |
||||
*/ |
||||
public function uninstall() |
||||
{ |
||||
//Deleting course settings |
||||
$this->uninstall_course_fields_in_all_courses($this->course_settings); |
||||
|
||||
$tablesToBeDeleted = [ |
||||
TABLE_NOTEBOOKTEACHER |
||||
]; |
||||
foreach ($tablesToBeDeleted as $tableToBeDeleted) { |
||||
$table = Database::get_main_table($tableToBeDeleted); |
||||
$sql = "DROP TABLE IF EXISTS $tableToBeDeleted"; |
||||
Database::query($sql); |
||||
} |
||||
$this->manageTab(false); |
||||
} |
||||
|
||||
public function update() |
||||
{ |
||||
$tableNotebookTeacher = self::TABLE_NOTEBOOKTEACHER; |
||||
|
||||
$sql = 'SHOW COLUMNS FROM '.$tableNotebookTeacher.' WHERE Field = "student_id"'; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) === 0) { |
||||
$sql = "ALTER TABLE ".$tableNotebookTeacher." ADD student_id INT( 10 ) UNSIGNED NOT NULL AFTER user_id"; |
||||
Database::query($sql); |
||||
} |
||||
|
||||
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png'; |
||||
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png'; |
||||
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png'; |
||||
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png'; |
||||
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png'; |
||||
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png'; |
||||
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png'; |
||||
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png'; |
||||
copy($srcfile1, $dstfile1); |
||||
copy($srcfile2, $dstfile2); |
||||
copy($srcfile3, $dstfile3); |
||||
copy($srcfile4, $dstfile4); |
||||
|
||||
Display::display_header(get_lang(ucfirst($tool))); |
||||
echo 'Plugin actualizado'; |
||||
Display::display_footer(); |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
<?php |
||||
/** |
||||
* This script initiates a notebookteacher plugin. |
||||
* |
||||
* @package chamilo.plugin.notebookteacher |
||||
*/ |
||||
|
||||
$course_plugin = 'notebookteacher'; |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
$plugin = NotebookTeacherPlugin::create(); |
||||
$enable = $plugin->get('enable_plugin_notebookteacher') == 'true'; |
||||
|
||||
if ($enable) { |
||||
if (api_is_teacher() || api_is_drh()) { |
||||
$url = 'src/index.php?'.api_get_cidreq(); |
||||
header('Location: ' . $url); |
||||
exit; |
||||
} else { |
||||
/** @var \Chamilo\CoreBundle\Entity\Session $session */ |
||||
$session = Database::getManager() |
||||
->find('ChamiloCoreBundle:Session', api_get_session_id()); |
||||
$_course = api_get_course_info(); |
||||
$webCoursePath = api_get_path(WEB_COURSE_PATH); |
||||
$url = $webCoursePath.$_course['path'].'/index.php'.($session ? '?id_session='.$session->getId() : ''); |
||||
|
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('ToolForTeacher')) |
||||
); |
||||
|
||||
header('Location: ' . $url); |
||||
} |
||||
} else { |
||||
echo $plugin->get_lang('ToolDisabled'); |
||||
} |
@ -0,0 +1,14 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* This script is included by main/admin/settings.lib.php when unselecting a plugin |
||||
* and is meant to remove things installed by the install.php script in both |
||||
* the global database and the courses tables. |
||||
* |
||||
* @package chamilo.plugin.notebookteacher |
||||
*/ |
||||
/** |
||||
* Queries |
||||
*/ |
||||
require_once __DIR__ . '/config.php'; |
||||
NotebookTeacherPlugin::create()->uninstall(); |
@ -0,0 +1,16 @@ |
||||
<?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.notebookteacher |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
require_once __DIR__ . '/config.php'; |
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
NotebookTeacherPlugin::create()->update(); |
Loading…
Reference in new issue