Plugin: SendMailWhenLpIsPublish: Making pluign to set extrafield notify_student_and_hrm_when_available - refs BT#18214

pull/3743/head
Carlos Alvarado 5 years ago
parent 68967d966f
commit 3b019742d3
No known key found for this signature in database
GPG Key ID: B612DB1EE6658FBB
  1. 17
      plugin/send_notification_new_lp/README.md
  2. 120
      plugin/send_notification_new_lp/SendNotificationToPublishLp.php
  3. 9
      plugin/send_notification_new_lp/index.php
  4. 11
      plugin/send_notification_new_lp/install.php
  5. 22
      plugin/send_notification_new_lp/plugin.php
  6. 10
      plugin/send_notification_new_lp/uninstall.php

@ -0,0 +1,17 @@
Create a field to remedial course
======
The purpose of this plugin is the possibility of adding remedial courses or advanced courses so that, when a course is
approved or failed, you can opt for a set of remedial courses or advanced courses.
* For remedial courses:
When activating the plugin, in the test settings, a remedialCourseList field is enabled, where the course (s) to be
taken is established if the user fails all the course attempts.
For this to work, the number of attempts must be activated and also, have an exam success rate enabled.
After the user fails the last attempt, they automatically enroll in the selected courses.
* For advanced courses:
When activating the plugin, in the test settings, the advanceCourseList field is enabled, which allows you to select
one or more courses that will be added to the user when they have passed an exam.
This function is independent of the number of attempts, but the passing percentage must be established from the test
configuration.

@ -0,0 +1,120 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class SendNotificationToPublishLp.
*/
class SendNotificationToPublishLp extends Plugin
{
/**
* @var array
*/
protected $notifyStudentField;
/**
* SendNotificationToPublishLp constructor.
*/
public function __construct()
{
parent::__construct(
'1.0',
'Carlos Alvarado'
);
$field = new ExtraField('lp');
$notifyStudentField = $field->get_handler_field_info_by_field_variable('notify_student_and_hrm_when_available');
if (empty($notifyStudentField)) {
$notifyStudentField = [
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'notify_student_and_hrm_when_available',
'display_text' => 'NotifyStudentAndHrmWhenAvailable',
'default_value' => 1,
'field_order' => 0,
'visible_to_self' => 0,
'visible_to_others' => 0,
'changeable' => 0,
'filter' => 0,
];
}
$this->notifyStudentField = $notifyStudentField;
}
/**
* Create a new instance of SendNotificationToPublishLp.
*
* @return SendNotificationToPublishLp
*/
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* Perform the plugin installation.
*/
public function install()
{
$this->SaveRemedialField();
}
/**
* Save the arrangement for notify_student_and_hrm_when_available, it is adjusted internally so that the values
* match the necessary ones.
*/
public function SaveRemedialField()
{
$schedule = new ExtraField('lp');
$data = $this->getDataRemedialField();
$data['default_value'] = 1;
$data['visible_to_self'] = 0;
if (isset($data['id'])) {
$schedule->update($data);
} else {
$schedule->save($data);
}
}
/**
* Make a array clean of notify_student_and_hrm_when_available.
*
* @return array|bool
*/
public function getDataRemedialField($install = true)
{
$data = $this->notifyStudentField;
$data['field_type'] = isset($data['field_type']) ? $data['field_type'] : ExtraField::FIELD_TYPE_INTEGER;
$data['field_order'] = isset($data['field_order']) ? $data['field_order'] : $data['field_order']; // at
$data['variable'] = isset($data['variable']) ? $data['variable'] : 'notify_student_and_hrm_when_available';
$data['display_text'] = isset($data['display_text']) ? $data['display_text'] : 'NotifyStudentAndHrmWhenAvailable';
$data['default_value'] = (int) $install;
$data['field_order'] = isset($data['field_order']) ? $data['field_order'] : 0;
$data['visible_to_self'] = isset($data['visible_to_self']) ? $data['visible_to_self'] : 0;
$data['visible_to_others'] = isset($data['visible_to_others']) ? $data['visible_to_others'] : 0;
$data['changeable'] = isset($data['changeable']) ? $data['changeable'] : 0;
$data['filter'] = isset($data['filter']) ? $data['filter'] : 0;
return $data;
}
/**
* Set default_value to 0.
*/
public function uninstall()
{
$schedule = new ExtraField('lp');
$data = $this->getDataRemedialField(false);
$data['default_value'] = 0;
$data['visible_to_self'] = 0;
if (isset($data['id'])) {
$schedule->update($data);
} else {
$schedule->save($data);
}
}
}

@ -0,0 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
// Check extra_field remedialcourselist and advancedCourseList
require_once __DIR__.'/../../main/inc/global.inc.php';
if (api_is_anonymous()) {
}

@ -0,0 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
// Check extra_field remedialcourselist and advancedCourseList
require_once 'SendNotificationToPublishLp.php';
if (!api_is_platform_admin()) {
exit('You must have admin permissions to install plugins');
}
SendNotificationToPublishLp::create()->install();

@ -0,0 +1,22 @@
<?php
/* For licensing 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
*
* @author Carlos Alvarado <alvaradocarlo@gmail.com>
*/
/**
* Plugin details (must be present).
*/
$plugin_info['title'] = 'Remedial and Advance Courses';
$plugin_info['comment'] = 'It adds the possibility of enrolling the user in a remedial course when the last '.
'attempt of an exercise fails or an advanced course when they pass an exercise. The success rate of '.
'the exercise must be established';
$plugin_info['version'] = '1.0'; // o la versión que corresponda
$plugin_info['author'] = 'Carlos Alvarado';

@ -0,0 +1,10 @@
<?php
/* For license terms, see /license.txt */
require_once 'SendNotificationToPublishLp.php';
if (!api_is_platform_admin()) {
exit('You must have admin permissions to uninstall plugins');
}
SendNotificationToPublishLp::create()->uninstall();
Loading…
Cancel
Save