Skip to content
Snippets Groups Projects
Commit 2740dbfd authored by 3i Logic LMS's avatar 3i Logic LMS
Browse files

Merge pull request #3 from michael-milette/Learning-Block-Fix-For-Errors-in-Moodle-2.5.1-and-2.6

Learning Block - Fix for errors in Moodle 2.5.1 and 2.6
parents 23699d3b 0ebea0bb
Branches
No related tags found
No related merge requests found
......@@ -37,6 +37,11 @@ $t_id = optional_param('t_id', null, PARAM_INT); // $_GET['t_id'];
$status = optional_param('status', null, PARAM_INT); // $_GET['status'];
$hidetraining = optional_param('hidetraining', null, PARAM_INT); // $_GET['hidetraining'];
$hideusers = optional_param('hideusers', null, PARAM_INT); //$_GET['hideusers'];
require_login(0, false);
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/blocks/learning_plan/ajax_bridge.php');
if($lp_id && $t_id) {
$form = new search();
$table = $form->display_list($lp_id, $t_id, $status);
......@@ -49,7 +54,7 @@ if($lp_id && $t_id) {
lpt inner join {learning_user_trainingplan} lut on lut.lpt_id=lpt.id where lpt.lp_id=? AND lut.u_id=?',
array ($lp_id, $u_id), $limitfrom=0, $limitnum=0);
}
// Find traiing on the base of lp Id.
// Find training on the base of lp Id.
else if($lp_id && $t) {
$attributes = $DB->get_records_sql_menu('SELECT t_id as id,(select training_name from {learning_training} where id =t_id) as name FROM {learning_plan_training}
where lp_id= ?', array ($lp_id), $limitfrom=0, $limitnum=0);
......
......@@ -20,7 +20,7 @@
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -69,7 +69,6 @@ $string['wrong_url'] = 'Wrong URL';
$string['elearning'] = 'eLearning';
$string['classroom'] = 'Class room';
$string['onthejob'] = 'On the job';
$string['training_m'] = 'Training method';
$string['assignee'] = 'Assignee';
$string['remove'] = 'Remove';
$string['setting'] = 'Setting';
......@@ -80,7 +79,3 @@ $string['learning_plan:addinstance'] = 'Add instance';
$string['learning_plan:managepages'] = 'Manage pages';
$string['learning_plan:viewpages'] = 'View pages';
$string['user'] = 'User';
\ No newline at end of file
......@@ -29,19 +29,22 @@ require_once("{$CFG->libdir}/formslib.php");
class learningplan_form extends moodleform {
public function definition() {
$mform =& $this->_form;
$errors= array();
$mform->addElement('header', 'displayinfo', get_string('learningpath', 'block_learning_plan'));
$mform->addElement('text', 'learning_plan', get_string('learningplan', 'block_learning_plan'));
$mform->addRule('learning_plan', get_string('plan_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
$mform->addRule('learning_plan', $errors, 'required', null, 'server');
$mform->setType('learningplan', PARAM_RAW);
$mform->setType('learning_plan', PARAM_RAW);
$attributes = array('rows' => '8', 'cols' => '40');
$mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes);
$mform->setType('description', PARAM_TEXT);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}
public function validation($data) {
public function validation($data, $files) {
global $DB;
$errors= array();
if($data['id']) {
......@@ -122,6 +125,8 @@ class training_form extends moodleform {
$mform =& $this->_form;
$mform->addElement('header', 'displayinfo', get_string('add_training', 'block_learning_plan'));
$radioarray=array();
if (!isset($attributes)) $attributes = "";
if (!isset($errors)) $errors = array();
$radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('elearning', 'block_learning_plan'), 1 );
$radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('classroom', 'block_learning_plan'), 2, $attributes);
$radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('onthejob', 'block_learning_plan'), 3, $attributes);
......@@ -130,19 +135,23 @@ class training_form extends moodleform {
$mform->addElement('text', 'training_name', get_string('training_name', 'block_learning_plan'));
$mform->addRule('training_name', get_string('training_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
$mform->addRule('training_name', $errors, 'required', null, 'server');
$mform->setType('training_name', PARAM_TEXT);
// $attributes = array('maxbytes' => '4194304', 'accepted_types' => "*");
// $mform->addElement('file', 'attachment', get_string('attachment', 'block_learning_plan'), $attributes );
// $mform->addElement('filepicker', 'attachment', get_string('attachment', 'block_learning_plan'), null, $attributes);
$mform->addElement('text', 'url', get_string('url', 'block_learning_plan'));
$mform->addRule('url', get_string('wrong_url', 'block_learning_plan'), 'regex', '/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', 'client');
$mform->setType('url', PARAM_LOCALURL);
$mform->addElement('date_time_selector', 'start_date', get_string('start_date', 'block_learning_plan'));
$mform->addElement('date_time_selector', 'end_date', get_string('end_date', 'block_learning_plan'));
$mform->addElement('static', 'errormsg');
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}
public function validation($data) {
public function validation($data, $files) {
global $DB;
$errors= array();
if($data['id']) {
......@@ -246,7 +255,9 @@ class trainingmethod_form extends moodleform {
$attributes = array('rows' => '8', 'cols' => '40');
$mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}
......@@ -276,7 +287,9 @@ class assigntraining_learningplan__form extends moodleform {
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2', 'label' => get_string('add_training', 'block_learning_plan')));
$select->setmultiple(true);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}
......@@ -348,6 +361,7 @@ class assignlerningplan_user_form extends moodleform {
public function definition() {
global $DB, $CFG, $USER;
$mform =& $this->_form;
if (!isset($attributes1)) $attributes1 = "";
$mform->addElement('header', 'displayinfo', get_string('assign_learningplan_user', 'block_learning_plan'));
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom=0, $limitnum=0);
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null,
......@@ -358,7 +372,9 @@ class assignlerningplan_user_form extends moodleform {
$select->setMultiple(true);
// $mform->addElement('hidden', 'assignee', $USER->id);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}
......@@ -428,8 +444,11 @@ class trainingstatus_form extends moodleform {
$mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes);
$attributes = array('size' => '50', 'maxlength' => '1000');
$mform->addElement('text', 'remarks', get_string('remarks', 'block_learning_plan'), $attributes);
$mform->setType('remarks', PARAM_TEXT);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}
......@@ -452,10 +471,12 @@ class search extends moodleform {
$attributes = array('In-progress', 'Not Yet Started', 'Complete', 'All Status');
$mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes);
$mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('button', 'showuser', 'Search', array("id" => "btnajax"));
}
public function display_list($lp_id, $t_id, $status) {
public function display_list($lp_id = "", $t_id = "", $status = "") {
// if ($lp_id && $t_id) {
global $DB, $OUTPUT, $CFG;
$table = new html_table();
......
......@@ -64,7 +64,7 @@ function user_learningplan($u_id) {
return $training;
}
function status_value($status_id) {
$status_value;
$status_value = '';
if($status_id == '0') {
$status_value = 'In-Progress';
} else if ($status_id == '1') {
......@@ -124,7 +124,7 @@ function display_list($lp_id, $u_id) {
global $DB, $OUTPUT, $CFG;
$table = new html_table();
$table->id = 'statuslist';
$table->head = array(get_string('s_no', 'block_learning_plan'), get_string('training_m', 'block_learning_plan'), get_string('user', 'block_learning_plan'), get_string('start_date', 'block_learning_plan'), get_string('end_date', 'block_learning_plan'), get_string('status', 'block_learning_plan'), get_string('remarks', 'block_learning_plan'));
$table->head = array(get_string('s_no', 'block_learning_plan'), get_string('training_name', 'block_learning_plan'), get_string('user', 'block_learning_plan'), get_string('start_date', 'block_learning_plan'), get_string('end_date', 'block_learning_plan'), get_string('status', 'block_learning_plan'), get_string('remarks', 'block_learning_plan'));
$table->size = array('5%', '30%', '20%', '10%', '10%', '10%', '25%', '10%' );
$table->align = array('center', 'left', 'left', 'center', 'center', 'center', 'left', 'left', 'center');
$table->width = '100%';
......
......@@ -2,8 +2,8 @@ Learning Plan Block
Author: Azmat Ullah, Talha Noor
Plugin Installation
1 ) Extract plugin into block folder in moodle
Plugin Installation:
1 ) Extract plugin folder into block folder in moodle
2 ) Login with Administrator on Moodle site
3) Install the plugin by clicking on 'update database'
......
......@@ -24,7 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$plugin->version = 2011033015; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2011033017; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011033003; // Requires this Moodle version
$plugin->release = '2.3';
$plugin->maturity = MATURITY_BETA;
......
......@@ -25,6 +25,8 @@
*/
require_once('../../config.php');
$setting = null;
$row = array();
require_once('learning_plan_form.php');
require_once('lib.php');
require_once("{$CFG->libdir}/formslib.php");
......@@ -34,6 +36,10 @@ $rem = optional_param('rem', null, PARAM_RAW);
$edit = optional_param('edit', null, PARAM_RAW);
$delete = optional_param('delete', null, PARAM_RAW);
$id = optional_param('id', null, PARAM_INT);
require_login();
$context = context_system::instance();
$PAGE->set_context($context);
$PAGE->set_url('/blocks/learning_plan/view.php');
$PAGE->set_pagelayout('standard');
$PAGE->set_heading('Learning Plan');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment