Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plugin: SendMailWhenLpIsPublish: Making pluign to set extrafield noti…
…fy_student_and_hrm_when_available - refs BT#18214
- Loading branch information
1 parent
68967d9
commit 3b01974
Showing
6 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
120 changes: 120 additions & 0 deletions
120
plugin/send_notification_new_lp/SendNotificationToPublishLp.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |