Actualización

This commit is contained in:
Xes
2025-04-10 12:36:07 +02:00
parent 1da7c3f3b9
commit 4aff98e77b
3147 changed files with 320647 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
Este plugin da la posibilidad a los profesores de un curso escribir en un bloc de notas compartido.
Los estudiantes no tienen acceso a las notas compartidas de los profesores.
**Instrucciones de puesta en funcionamiento**
- Subir la carpeta **notebookteacher** a la carpeta plugin de chamilo.
- Habilitar el plugin en la administración de Chamilo.
- El icono de la herramienta aparecerá en pantalla de los cursos con el resto de herramientas
- Si no se visualiza el icono en el cursos correctamente y sale el icono de plugin genérico:
- Copiar los iconos de la carpeta resources/img/64 dentro de /main/img/icons/64
- Copiar el icono de la carpeta resources/img/22 dentro de /main/img
**Solo si ya tiene instalado el plugin previamente:**
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.
http://*sudominio.com*/**plugin/notebookteacher/update.php**

View File

@@ -0,0 +1,10 @@
<?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';

View File

@@ -0,0 +1,46 @@
<?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')) {
exit('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();
if ($pluginSchema->hasTable(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER)) {
return;
}
//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);
}

View File

@@ -0,0 +1,3 @@
<?php
/* For license terms, see /license.txt */
require_once 'config.php';

View File

@@ -0,0 +1,14 @@
<?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
*/
require_once __DIR__.'/config.php';
if (!api_is_platform_admin()) {
exit('You must have admin permissions to install plugins');
}
NotebookTeacherPlugin::create()->install();

View File

@@ -0,0 +1,14 @@
<?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";

View File

@@ -0,0 +1,14 @@
<?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";

View File

@@ -0,0 +1,16 @@
<?php
/* For license terms, see /license.txt */
/**
* This script is a configuration file for the date plugin.
* You can use it as a master for other platform plugins (course plugins are slightly different).
* These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins).
*
* @package chamilo.plugin.notebookteacher
*/
/**
* Plugin details (must be present).
*/
require_once __DIR__.'/config.php';
$plugin_info = NotebookTeacherPlugin::create()->get_info();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,533 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* 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
* @author Julio Montoya
*
* @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 javascriptNotebook()
{
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 saveNote($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 $notebookId
*
* @return array|mixed
*/
public static function getNoteInformation($notebookId)
{
if (empty($notebookId)) {
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($notebookId)."' ";
$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 updateNote($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 $notebookId
*
* @return bool
*/
public static function deleteNote($notebookId)
{
if (empty($notebookId) || $notebookId != strval(intval($notebookId))) {
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($notebookId)."' 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 displayNotes()
{
$plugin = NotebookTeacherPlugin::create();
$userInfo = api_get_user_info();
$sortDirection = 'DESC';
$linkSortDirection = 'ASC';
if (!isset($_GET['direction'])) {
$sortDirection = 'ASC';
$linkSortDirection = 'DESC';
} elseif ($_GET['direction'] == 'ASC') {
$sortDirection = 'ASC';
$linkSortDirection = 'DESC';
}
$studentId = isset($_GET['student_id']) ? (int) $_GET['student_id'] : 0;
$currentUrl = api_get_self().'?'.api_get_cidreq().'&student_id='.$studentId;
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
$courseId = api_get_course_int_id();
if (empty($sessionId)) {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
0,
null,
null,
STUDENT
);
} else {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
null,
null,
0
);
}
$form = new FormValidator('search_student');
// Status
$students = [];
$students[] = $plugin->get_lang('AllStudent');
foreach ($userList as $key => $userItem) {
$students[$key] = api_get_person_name($userItem['firstname'], $userItem['lastname']);
}
$form->addElement(
'select',
'student_filter',
$plugin->get_lang('StudentFilter'),
$students,
[
'id' => 'student_filter',
'onchange' => 'javascript: studentFilter();',
]
);
$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 (empty($sessionId)) {
echo '<a href="'.$currentUrl.'&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="'.$currentUrl.'&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="'.$currentUrl.
'&action=changeview&view=creation_date&direction='.$linkSortDirection.'">'.
Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32').'</a>';
echo '<a href="'.$currentUrl.
'&action=changeview&view=update_date&direction='.$linkSortDirection.'">'.
Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32').'</a>';
echo '<a href="'.$currentUrl.
'&action=changeview&view=title&direction='.$linkSortDirection.'">'.
Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32').'</a>';
echo '</div>';
echo '<div class="row">'.$selectStudent.'</div>';
$view = Session::read('notebook_view');
if (!isset($view) ||
!in_array($view, ['creation_date', 'update_date', 'title'])
) {
Session::write('notebook_view', 'creation_date');
}
$view = Session::read('notebook_view');
// Database table definition
$tableNotebook = Database::get_main_table(NotebookTeacherPlugin::TABLE_NOTEBOOKTEACHER);
if ($view == 'creation_date' || $view == 'update_date') {
$orderBy = " ORDER BY `$view` $sortDirection ";
} else {
$orderBy = " ORDER BY `$view` $sortDirection ";
}
// condition for the session
$conditionSession = api_get_session_condition($sessionId);
$condExtra = $view == 'update_date' ? " AND update_date <> ''" : " ";
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) {
$studentText = '';
if ($row['student_id'] > 0) {
$studentInfo = api_get_user_info($row['student_id']);
$studentText = $studentInfo['complete_name_with_username'];
}
echo Display::page_subheader2($studentText);
$first = false;
}
// Validation when belongs to a session
$sessionImg = api_get_session_image($row['session_id'], $userInfo['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'];
$actions = '';
if (intval($row['user_id']) == api_get_user_id()) {
$actions = '<a href="'.
api_get_self().'?'.
api_get_cidreq().'&student_id='.$studentId.'&action=editnote&notebook_id='.$row['id'].'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
$actions .= '<a href="'.
api_get_self().
'?action=deletenote&student_id='.$studentId.'&notebook_id='.$row['id'].
'" onclick="return confirmation(\''.$row['title'].'\');">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
}
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 ($userList 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'], $userInfo['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'];
$actions = '';
if (intval($row['user_id']) == api_get_user_id()) {
$actions = '<a href="'.api_get_self().
'?action=editnote&notebook_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&notebook_id='.$row['id'].
'" onclick="return confirmation(\''.$row['title'].'\');">'.
Display::return_icon(
'delete.png',
get_lang('Delete'),
'',
ICON_SIZE_SMALL
).'</a>';
}
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'], $userInfo['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'];
$actions = '';
if (intval($row['user_id']) == api_get_user_id()) {
$actions = '<a href="'.api_get_self().
'?action=editnote&notebook_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&notebook_id='.$row['id'].
'" onclick="return confirmation(\''.$row['title'].'\');">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
}
echo Display::panel(
$row['description'],
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>',
get_lang('CreationDate').': '.
Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author
);
}
}
}
}
/**
* @param FormValidator $form
* @param int $studentId
*
* @return FormValidator
*/
public static function getForm($form, $studentId)
{
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
if (empty($sessionId)) {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
0,
null,
null,
STUDENT
);
} else {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
null,
null,
0
);
}
$students = ['' => ''];
foreach ($userList as $key => $userItem) {
$students[$key] = api_get_person_name($userItem['firstname'], $userItem['lastname']);
}
$form->addElement(
'select',
'student_id',
get_lang('Student'),
$students
);
$form->addElement('text', 'note_title', get_lang('NoteTitle'), ['id' => 'note_title']);
$form->applyFilter('text', 'html_filter');
$form->applyFilter('text', 'attr_on_filter');
$form->addHtmlEditor(
'note_comment',
get_lang('NoteComment'),
false,
false,
api_is_allowed_to_edit()
? ['ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300']
: ['ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student']
);
$form->addButtonCreate(get_lang('Save'), 'SubmitNote');
// Setting the rules
$form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
}

View File

@@ -0,0 +1,130 @@
<?php
/* For license terms, see /license.txt */
/**
* Plugin class for the NotebookTeacher plugin.
*
* @package chamilo.plugin.notebookteacher
*
* @author Jose Angel Ruiz <desarrollo@nosolored.com>
* @author Julio Montoya
*/
class NotebookTeacherPlugin extends Plugin
{
public const TABLE_NOTEBOOKTEACHER = 'plugin_notebook_teacher';
public $isCoursePlugin = true;
/**
* NotebookTeacherPlugin constructor.
*/
protected function __construct()
{
parent::__construct(
'1.1',
'Jose Angel Ruiz - NoSoloRed (original author), Julio Montoya',
[
'enable_plugin_notebookteacher' => 'boolean',
]
);
$this->isAdminPlugin = true;
}
/**
* @return NotebookTeacherPlugin
*/
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;
}
$list = [
'/64/notebookteacher.png',
'/64/notebookteacher_na.png',
'/32/notebookteacher.png',
'/32/notebookteacher_na.png',
'/32/test2pdf_na.png',
'/22/notebookteacher.png',
];
foreach ($list as $file) {
$source = __DIR__.'/../resources/img/'.$file;
$destination = __DIR__.'/../../../main/img/icons/'.$file;
$res = @copy($source, $destination);
if (!$res) {
break;
}
}
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();
$tablesToBeDeleted = [self::TABLE_NOTEBOOKTEACHER];
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
$table = Database::get_main_table($tableToBeDeleted);
$sql = "DROP TABLE IF EXISTS $table";
Database::query($sql);
}
$this->manageTab(false);
}
/**
* Update.
*/
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(self::TABLE_NOTEBOOKTEACHER)));
echo 'Plugin actualizado';
Display::display_footer();
}
}

View File

@@ -0,0 +1,225 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
$course_plugin = 'notebookteacher';
require_once __DIR__.'/../config.php';
// Notice for unauthorized people.
api_protect_course_script(true);
$_setting['student_view_enabled'] = 'false';
$plugin = NotebookTeacherPlugin::create();
$enable = $plugin->get('enable_plugin_notebookteacher') == 'true';
if (!$enable) {
api_not_allowed(true, $plugin->get_lang('ToolDisabled'));
}
$allow = api_is_teacher() || api_is_drh();
if (!$allow) {
api_not_allowed(true);
}
$current_course_tool = $plugin->get_lang('NotebookTeacher');
$notebookId = isset($_GET['notebook_id']) ? (int) $_GET['notebook_id'] : 0;
$studentId = isset($_GET['student_id']) ? $_GET['student_id'] : 0;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
$currentUrl = api_get_self().'?'.api_get_cidreq().'&student_id='.$studentId;
// The section (tabs)
$this_section = SECTION_COURSES;
$location = api_get_self().'?'.api_get_cidreq();
// Additional javascript
$htmlHeadXtra[] = NotebookTeacher::javascriptNotebook();
$htmlHeadXtra[] = '<script>
function setFocus(){
$("#note_title").focus();
}
$(document).ready(function () {
setFocus();
});
function studentFilter() {
var student_id = $("#student_filter").val();
location.href ="'.$location.'&student_id="+student_id;
}
</script>';
// Tracking
Event::event_access_tool('notebookteacher');
$noteBookTeacher = $tool = $plugin->get_lang('NotebookTeacher');
switch ($action) {
case 'addnote':
$tool = 'NoteAddNew';
$interbreadcrumb[] = [
'url' => 'index.php?'.api_get_cidreq(),
'name' => $noteBookTeacher,
];
if ((api_get_session_id() != 0 &&
!api_is_allowed_to_session_edit(false, true) || api_is_drh())) {
api_not_allowed();
}
Session::write('notebook_view', 'creation_date');
$form = new FormValidator(
'note',
'post',
$currentUrl.'&action=addnote'
);
$form->addHeader(get_lang('NoteAddNew'));
$form = NotebookTeacher::getForm($form, $studentId);
$form->setDefaults(['student_id' => $studentId]);
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
$res = NotebookTeacher::saveNote($values);
if ($res) {
Display::addFlash(Display::return_message(get_lang('NoteAdded'), 'confirmation'));
}
}
header('Location: '.$currentUrl);
exit;
} else {
// Displaying the header
Display::display_header(get_lang(ucfirst($tool)));
// Tool introduction
Display::display_introduction_section($noteBookTeacher);
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();
}
break;
case 'editnote':
$tool = 'ModifyNote';
$interbreadcrumb[] = [
'url' => 'index.php?'.api_get_cidreq(),
'name' => $noteBookTeacher,
];
if (empty($notebookId)) {
api_not_allowed(true);
}
$defaults = NotebookTeacher::getNoteInformation($notebookId);
if (empty($defaults)) {
api_not_allowed(true);
}
$form = new FormValidator(
'note',
'post',
$currentUrl.'&action='.$action.'&notebook_id='.$notebookId
);
// Setting the form elements
$form->addHeader(get_lang('ModifyNote'));
$form->addHidden('notebook_id', $notebookId);
$form = NotebookTeacher::getForm($form, $defaults['student_id']);
// Setting the defaults
$form->setDefaults($defaults);
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
$res = NotebookTeacher::updateNote($values);
if ($res) {
Display::addFlash(Display::return_message(get_lang('NoteUpdated'), 'confirmation'));
}
}
header('Location: '.$currentUrl);
exit;
} else {
// Displaying the header
Display::display_header(get_lang(ucfirst($tool)));
// Tool introduction
Display::display_introduction_section($noteBookTeacher);
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();
}
break;
case 'deletenote':
$res = NotebookTeacher::deleteNote($notebookId);
if ($res) {
Display::addFlash(Display::return_message(get_lang('NoteDeleted'), 'confirmation'));
}
header('Location: '.$currentUrl);
exit;
break;
case 'changeview':
if (in_array($_GET['view'], ['creation_date', 'update_date', 'title'])) {
switch ($_GET['view']) {
case 'creation_date':
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') {
Display::addFlash(
Display::return_message(get_lang('NotesSortedByCreationDateAsc'), 'confirmation')
);
} else {
Display::addFlash(
Display::return_message(get_lang('NotesSortedByCreationDateDESC'), 'confirmation')
);
}
break;
case 'update_date':
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') {
Display::addFlash(
Display::return_message(get_lang('NotesSortedByUpdateDateAsc'), 'confirmation')
);
} else {
Display::addFlash(
Display::return_message(get_lang('NotesSortedByUpdateDateDESC'), 'confirmation')
);
}
break;
case 'title':
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') {
Display::addFlash(Display::return_message(get_lang('NotesSortedByTitleAsc'), 'confirmation'));
} else {
Display::addFlash(Display::return_message(get_lang('NotesSortedByTitleDESC'), 'confirmation'));
}
break;
}
Session::write('notebook_view', Security::remove_XSS($_GET['view']));
header('Location: '.$currentUrl);
exit;
}
break;
default:
// Displaying the header
Display::display_header(get_lang(ucfirst($tool)));
// Tool introduction
Display::display_introduction_section($noteBookTeacher);
NotebookTeacher::displayNotes();
break;
}
Display::display_footer();

View File

@@ -0,0 +1,33 @@
<?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 {
$session = api_get_session_entity(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);
exit;
}
} else {
api_not_allowed(true, $plugin->get_lang('ToolDisabled'));
}

View File

@@ -0,0 +1,12 @@
<?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
*/
require_once __DIR__.'/config.php';
NotebookTeacherPlugin::create()->uninstall();

View File

@@ -0,0 +1,14 @@
<?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
*/
require_once __DIR__.'/config.php';
if (!api_is_platform_admin()) {
exit('You must have admin permissions to install plugins');
}
NotebookTeacherPlugin::create()->update();