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

Files uploaded

parents
No related branches found
No related tags found
No related merge requests found
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once('learning_plan_form.php');
require_once("lib.php");
global $DB;
$attributes = array();
$lp_id = $_GET['id'];
$u_id = $_GET['u_id'];
$t = $_GET['t'];
$t_id = $_GET['t_id'];
$status = $_GET['status'];
$hidetraining = $_GET['hidetraining'];
$hideusers = $_GET['hideusers'];
if($lp_id && $t_id) {
$form = new search();
$table = $form->display_list($lp_id, $t_id, $status);
$a = html_writer::table($table);
echo $a;
} else {
// Change training on the base of learning plan and user.
if($lp_id && $u_id) {
$attributes = $DB->get_records_sql_menu('select lpt.t_id as id, (select training_name from {learning_training} where id =lpt.t_id) as name from {learning_plan_training}
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.
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);
}
// Change users on the base of Learning plan
else if($lp_id && $hidetraining) {
$attributes1 = $DB->get_records_sql_menu('SELECT id, training_name as name from {learning_training} ', null, $limitfrom=0, $limitnum=0);
$attributes2 = $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);
$attributes = array_diff($attributes1, $attributes2);
}
else if( $lp_id && $hideusers) {
$attributes3 = $DB->get_records_sql_menu('SELECT id, CONCAT(firstname," ", lastname) as name FROM {user} where firstname != "Guest User"', null, $limitfrom=0, $limitnum=0);
$attributes4 = $DB->get_records_sql_menu('SELECT u_id as id, (SELECT concat(firstname," ", lastname) FROM {user} WHERE id = u_id) as name FROM {learning_user_learningplan}
where lp_id = ?', array($lp_id), $limitfrom=0, $limitnum=0);
$attributes = array_diff($attributes3, $attributes4);
}
else if($lp_id) {
$attributes = $DB->get_records_sql_menu('SELECT u.u_id as id, (SELECT CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u. u_id) as name FROM
{learning_user_learningplan} as u where lp_id= ?', array ($lp_id), $limitfrom=0, $limitnum=0);
}
$data = "";
foreach ($attributes as $key => $attrib) {
$data .= $key.'~'.$attrib .'^';
}
return print_r($data);
}
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('lib.php');
class block_learning_plan extends block_base {
public function init() {
global $CFG, $USER, $COURSE;
$context = context_course::instance($COURSE->id);
if (has_capability('block/learning_plan:managepages', $context)) {
$this->title = get_string('learning_plan', 'block_learning_plan');
} else if (has_capability('block/learning_plan:viewpages', $context)) {
$this->title = get_string('myview', 'block_learning_plan');
} else {
$this->title = get_string('learning_plan', 'block_learning_plan');
}
}
public function get_content() {
if ($this->content !== null) {
return $this->content;
}
global $CFG, $USER, $COURSE, $PAGE;
$this->content = new stdClass;
$context = context_course::instance($COURSE->id);
if (has_capability('block/learning_plan:managepages', $context)) {
$pageurl = new moodle_url('/blocks/learning_plan/view.php?viewpage=');
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.'1', get_string('learningpath', 'block_learning_plan'));
$this->content->text .= html_writer::end_tag('li');
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.'2', get_string('add_training', 'block_learning_plan'));
$this->content->text .= html_writer::end_tag('li');
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.'4', get_string('assign_training_learningplan', 'block_learning_plan'));
$this->content->text .= html_writer::end_tag('li');
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.'5', get_string('assign_learningplan_user', 'block_learning_plan'));
$this->content->text .= html_writer::end_tag('li');
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.'6', get_string('trainingstatus', 'block_learning_plan'));
$this->content->text .= html_writer::end_tag('li');
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.'7', get_string('search', 'block_learning_plan'));
$this->content->text .= html_writer::end_tag('li');
} else {
$pageurl = new moodle_url('/blocks/learning_plan/student/view.php?id=');
$learning_plan=user_learningplan($USER->id);
foreach($learning_plan as $lp) {
$this->content->text .= html_writer::start_tag('li');
$this->content->text .= html_writer::link($pageurl.$lp->id, $lp->learningplan);
$this->content->text .= html_writer::end_tag('li');
}
}
return $this->content;
}
}
\ No newline at end of file
<?php
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/learning_plan:viewpages' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'guest' => CAP_PREVENT,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'block/learning_plan:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
'block/learning_plan:managepages' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'guest' => CAP_PREVENT,
'student' => CAP_PREVENT,
'teacher' => CAP_PREVENT,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/learning_plan/db" VERSION="20130712" COMMENT="XMLDB file for Moodle blocks/learning_plan"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="block_learning_plan" COMMENT="Default comment for block_learning_plan, please edit me" NEXT="learning_learningplan">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="learning_learningplan" COMMENT="Learning Plan" PREVIOUS="block_learning_plan" NEXT="learning_training">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="learning_plan"/>
<FIELD NAME="learning_plan" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="description"/>
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" PREVIOUS="learning_plan"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="learning_training" COMMENT="Default comment for the table, please edit me" PREVIOUS="learning_learningplan" NEXT="learning_plan_training">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="training_name"/>
<FIELD NAME="training_name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="type_id"/>
<FIELD NAME="type_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="training_name" NEXT="file"/>
<FIELD NAME="file" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="type_id" NEXT="url"/>
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="file" NEXT="start_date"/>
<FIELD NAME="start_date" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="url" NEXT="end_date"/>
<FIELD NAME="end_date" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="start_date"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="learning_plan_training" COMMENT="Default comment for the table, please edit me" PREVIOUS="learning_training" NEXT="learning_traningtype">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="lp_id"/>
<FIELD NAME="lp_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="t_id"/>
<FIELD NAME="t_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="lp_id"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="lp_id"/>
<KEY NAME="lp_id" TYPE="foreign" FIELDS="lp_id" REFTABLE="learning_learningplan" REFFIELDS="id" PREVIOUS="primary" NEXT="t_id"/>
<KEY NAME="t_id" TYPE="foreign" FIELDS="t_id" REFTABLE="learning_training" REFFIELDS="id" PREVIOUS="lp_id"/>
</KEYS>
</TABLE>
<TABLE NAME="learning_traningtype" COMMENT="Default comment for the table, please edit me" PREVIOUS="learning_plan_training" NEXT="learning_user_learningplan">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="training_type"/>
<FIELD NAME="training_type" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="description"/>
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" PREVIOUS="training_type"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="learning_user_learningplan" COMMENT="Default comment for the table, please edit me" PREVIOUS="learning_traningtype" NEXT="learning_user_trainingplan">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="u_id"/>
<FIELD NAME="u_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="lp_id"/>
<FIELD NAME="lp_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="u_id" NEXT="assignee_id"/>
<FIELD NAME="assignee_id" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="lp_id"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="lp_id"/>
<KEY NAME="lp_id" TYPE="foreign" FIELDS="lp_id" REFTABLE="learning_learningplan" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
</TABLE>
<TABLE NAME="learning_user_trainingplan" COMMENT="Default comment for the table, please edit me" PREVIOUS="learning_user_learningplan">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="lpt_id"/>
<FIELD NAME="lpt_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="u_id"/>
<FIELD NAME="u_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="lpt_id" NEXT="status"/>
<FIELD NAME="status" TYPE="char" LENGTH="25" NOTNULL="false" DEFAULT="Not Yet Started" SEQUENCE="false" PREVIOUS="u_id" NEXT="remarks"/>
<FIELD NAME="remarks" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="status"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="lpt_id"/>
<KEY NAME="lpt_id" TYPE="foreign" FIELDS="lpt_id" REFTABLE="learning_plan_training" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Learning plan';
$string['learning_plan'] = 'Learning plan';
$string['learning_plan_name'] = 'Name';
$string['learningpath'] = 'Add learning plan';
$string['desc'] = 'Description';
$string['end_date'] = 'End date';
$string['attachment'] = 'Upload file';
$string['start_date'] = 'Start date';
$string['end_date'] = 'End date';
$string['onthejob'] = 'On the job';
$string['classroom'] = 'Class room';
$string['elearning'] = 'eLearning';
$string['url'] = 'URL';
$string['add_training'] = 'Add training';
$string['add_training_method'] = 'Add training method';
$string['training_method'] = 'Training method';
$string['assign_training_learningplan'] = 'Assign training into learning plan';
$string['training_name'] = 'Training name';
$string['learningplan'] = 'Learning plan';
$string['training'] = 'Training';
$string['add_learningplan'] = 'Add learning plan';
$string['trainingstatus'] = 'Set training status';
$string['users'] = 'Users';
$string['remarks'] = 'Remarks';
$string['status'] = 'Status';
$string['assign_learningplan_user'] = 'Assign learning plan to users';
$string['addusers'] = 'Add users';
$string['searchusers'] = 'Search users';
$string['showuser'] = 'Show users';
$string['block/learning_plan:viewpages'] = 'Learning plan view pages';
$string['block/learning_plan:managepages'] = 'Learning plan manage pages';
$string['myview'] = 'My training';
$string['search'] = 'Search';
$string['status_report'] = 'Status report';
$string['report_at'] = 'Report as at';
$string['plan_format'] = 'Please add learning plan in correct format.';
$string['plan_exist'] = 'Learning Plan already exist';
$string['training_format'] = 'Please add training in correct format';
$string['training_exist'] = 'Training already exist.';
$string['date_val'] = 'Start date should be greater than end date.';
$string['s_no'] = 'Serial no.';
$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';
$string['plan_delete'] = 'Do you want to delete learning plan?';
$string['training_delete'] = 'Do You Want to Delete training?';
$string['record_delete'] = 'Do you want to delete record?';
$string['learning_plan:addinstance'] = 'Add instance';
$string['learning_plan:managepages'] = 'Manage pages';
$string['learning_plan:viewpages'] = 'View pages';
$string['user'] = 'User';
This diff is collapsed.
lib.php 0 → 100644
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function get_lpt_id($l_id, $t_id) {
global $DB;
$lpt_id=$DB->get_record_sql('select id from {learning_plan_training} where lp_id=? AND t_id=?',
array($l_id, $t_id));
$lpt_id=$lpt_id->id;
return $lpt_id;
}
function islp_assign_user($l_id) {
global $DB;
$return;
$isexist = $DB->record_exists('learning_user_learningplan', array ('lp_id'=>$l_id));
if($isexist > 0) {
$return = true;
}
else {
$return = false;
}
return $return;
}
function get_learningplan_user($lp_id) {
global $DB;
$users = $DB->get_records('learning_user_learningplan', array('lp_id' => $lp_id));
return $users;
}
function learningplan_training($lp_id) {
global $DB;
$training = $DB->get_records('learning_plan_training', array('lp_id' => $lp_id));
return $training;
}
function user_learningplan($u_id) {
global $DB;
$training=$DB->get_recordset_sql('SELECT lp_id as id, (select learning_plan from {learning_learningplan} where id =lp_id) as learningplan
FROM {learning_user_learningplan} where u_id = ?', array($u_id), $page*$perpage, $perpage);
// $training = $DB->get_records_sql_menu('SELECT lp_id as id, (select learning_plan from {learning_learningplan}
// where id =lp_id) as learningplan FROM {learning_user_learningplan} where u_id = ?', array($u_id), $limitfrom=0, $limitnum=0);
// $training = $DB->get_record_sql('SELECT lp_id as id, (select learning_plan
// from {learning_learningplan} where id =lp_id) as learningplan FROM {learning_user_learningplan} where u_id = ?', array($u_id));
return $training;
}
function status_value($status_id) {
$status_value;
if($status_id == '0') {
$status_value = 'In-Progress';
} else if ($status_id == '1') {
$status_value = 'Not Yet Started';
} else if ($status_id == '2') {
$status_value = 'Complete';
}
return $status_value;
}
function status_id($l_id, $u_id, $t_id) {
global $DB;
$status=$DB->get_record_sql('select lut.id as id from {learning_plan_training} lpt inner join {learning_user_trainingplan} lut
on lut.lpt_id=lpt.id where lpt.lp_id=? AND lut.u_id=? AND lpt.t_id= ?',
array($l_id, $u_id, $t_id));
$status=$status->id;
return $status;
}
// Return Learning Plan as String.
function get_learningplan_name ($id) {
global $DB;
$result = $DB->get_record_sql("SELECT learning_plan FROM {learning_learningplan} WHERE id = ?",
array($id));
return $result->learning_plan;
}
// Return User Full Name as String
function get_user_name($id) {
global $DB;
$result = $DB->get_record_sql("SELECT concat (firstname,' ', lastname) as name FROM {user} WHERE id = ?",
array($id));
return $result->name;
}
function delete_learningplan_record($table, $id,$url) {
global $DB;
// Delete Department.
if($table == 'learning_learningplan') {
$DB->delete_records('learning_learningplan', array('id'=> $id));
$DB->delete_records('learning_plan_training ', array('lp_id'=> $id));
$DB->delete_records('learning_user_learningplan ', array('lp_id'=> $id));
}
else if($table == 'learning_training') {
$DB->delete_records('learning_training', array('id'=> $id));
$DB->delete_records('learning_plan_training', array('t_id'=> $id));
}
else if($table == 'learning_plan_training') {
$DB->delete_records('learning_plan_training', array('id'=> $id));
}
else if($table == 'learning_user_learningplan') {
$DB->delete_records('learning_user_learningplan', array('id'=> $id));
}
redirect($url);
}
function display_list($lp_id, $u_id) {
// if ($lp_id && $t_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->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%';
$table->data = array();
$sql = 'select t_id, lp_id, lut.status, lut.remarks, `u_id` as id,(select training_name from {learning_training} where id =t_id)
as training,(select learning_plan from {learning_learningplan} where id =lp_id) as learning_plan, (SELECT
CONCAT(firstname," ", lastname)FROM {user} where username!="guest" AND id = u_id) as name,(select
start_date from {learning_training} where id =t_id)as date1,(select end_date from {learning_training}
where id =t_id)as date2 from {learning_plan_training} lpt inner join {learning_user_trainingplan} lut
on lut.lpt_id=lpt.id where lpt.lp_id=? AND lut.u_id=?'; //ORDER BY $orderby';
$inc= 0;
$rs = $DB->get_recordset_sql($sql, array($lp_id, $u_id));
foreach ($rs as $log) {
$row = array();
$row[] = ++$inc;
$row[] = $log->training;
$row[] = $log->name;
$row[] = date('d-m-Y', $log->date1);
$row[] = date('d-m-Y', $log->date2);
$row[] = status_value($log->status) ;
$row[] = $log->remarks;
$table->data[] = $row;
}
return $table;
}
function nav_title($viewpage) {
$array = array(
1 => get_string('learningpath', 'block_learning_plan'),
2 => get_string('add_training', 'block_learning_plan'),
4 => get_string('assign_training_learningplan', 'block_learning_plan'),
5 => get_string('assign_learningplan_user', 'block_learning_plan'),
6 => get_string('trainingstatus', 'block_learning_plan'),
7 => get_string('search', 'block_learning_plan'),
);
return $array[$viewpage];
}
module.js 0 → 100644
// JavaScript Document.
M.block_learning_plan = {};
M.block_learning_plan.init = function(Y, param1, param2) {
// Load Message on Message Body.
// End Load Message.
var lp_id = Y.one('#id_l_id');
var lp_id_value = lp_id.get('value');
if (param1 == '6' && param2 != '1') {
var u_id = Y.one('#id_u_id');
var id_u_id_value = u_id.get('value');
// If page refresh users & thier training will be selected on the base of learning plan.
// Users change.
Y.io('ajax_bridge.php?id='+lp_id_value, {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var u_id = Y.one('#id_u_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
u_id.set('innerHTML', asd);
// Trainig Change.
id_u_id_value = u_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&u_id='+id_u_id_value, {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
}
}
});
// Learning path change event.
lp_id.on('change', function() {
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value, {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var u_id = Y.one('#id_u_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
u_id.set('innerHTML', asd);
// Training Change.
id_u_id_value = u_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&u_id='+id_u_id_value, {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
}
}
});
});
u_id.on('change', function() {
// Training Change.
id_u_id_value = u_id.get('value');
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&u_id='+id_u_id_value, {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
});
} else if (param1 == '7' ) {
// Change training on the base of lp_id.
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&t=1', {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
// On change learning plan.
lp_id.on('change', function() {
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&t=1', {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
});
// Show user button click.
var showuser = Y.one('#btnajax');
showuser.on('click',function() {
var lp_id= Y.one("#id_l_id").get('value');
var t_id= Y.one("#id_t_id").get('value');
var status= Y.one("#id_status").get('value');
var userlist = Y.one("#statuslist");
// alert(showuser_empty_field.get('id'));
Y.io('ajax_bridge.php?id='+lp_id+'&t_id='+t_id+'&status='+status, {
on: {
start: function(id, args) {
//userlist.set('innerHTML','<img src="Loading.gif" id="load-users" style="margin-left:6cm;" />');
},
complete: function(id, e) {
var json = e.responseText;
console.log(json);
userlist.set('innerHTML',json);
}
}
});
});
} else if (param1 == '4')
{
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&hidetraining=1', {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
// On change learning plan event.
lp_id.on('change', function() {
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&hidetraining=1', {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var t_id = Y.one('#id_t_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
t_id.set('innerHTML', asd);
}
}
});
});
} else if (param1 == '5') {
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&hideusers=1', {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var u_id = Y.one('#id_u_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
u_id.set('innerHTML', asd);
}
}
});
// On change learning plan event.
lp_id.on('change', function() {
lp_id_value = lp_id.get('value');
Y.io('ajax_bridge.php?id='+lp_id_value+'&hideusers=1', {
on: {
start: function(id, args) {
},
complete: function(id, e) {
var u_id = Y.one('#id_u_id');
var json = e.responseText;
console.log(json);
var test = json.split("^");
var asd = "";
for(i=0; i<test.length-1; i++) {
var sep = test[i].split("~");
asd += '<option value = '+sep[0]+'>'+sep[1]+'</option>';
}
u_id.set('innerHTML', asd);
}
}
});
});
}
}
\ No newline at end of file
Learning Plan Block
Author: Azmat Ullah, Talha Noor
Plugin
1 ) Instalation extract into block folder in moodle
2 ) Login with Administrator on Moodle site
3) Install the plugin by clicking on 'update database'
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../../config.php');
require_once('../learning_plan_form.php');
require_once('../lib.php');
require_once("{$CFG->libdir}/formslib.php");
// Variable
global $DB, $USER, $OUTPUT, $PAGE, $CFG;
$PAGE->set_url('/blocks/learning_plan/view.php');
$PAGE->set_pagelayout('standard');
// $lp_id = optional_param('id',null ,PARAM_INT);
// $viewpage = required_param('viewpage', PARAM_INT);
$lp_id= required_param('id', PARAM_INT);
$PAGE->set_heading('Learning Plan');
$PAGE->set_title('Learning Plan');
// $pageurl = new moodle_url('/blocks/learning_plan/student/view.php?viewpage='.$viewpage);
$PAGE->navbar->ignore_active();
$PAGE->navbar->add(get_string("pluginname", 'block_learning_plan'));
echo $OUTPUT->header();
$student_status = display_list($lp_id, $USER->id) ;
$title = '<center><table width="100%" style="background-color:#EEE;"><tr><td><center><h2>'.get_string('status_report', 'block_learning_plan').
'</h2><h2>'.get_learningplan_name($lp_id).'</h2><p>'. get_string('report_at', 'block_learning_plan').' '.(Date("d M Y")).'</p></center></td></tr><table></center>';
// Set viewpage with form.
// $toform['viewpage'] = $viewpage;
// $form->set_data($toform);
// Display Form.
// $form->display();
// Display List.
// if($table=$form->display_list()) {
// echo '<div id="prints">';
echo $title;
echo html_writer::table($student_status);
//echo '</div>';
//}
$PAGE->requires->js_init_call('M.block_learning_plan.init', array($viewpage, $setting));
echo $OUTPUT->footer();
//End Form Display
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$plugin->version = 2011033015; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011033003; // Requires this Moodle version
$plugin->release = '2.3';
$plugin->maturity = MATURITY_BETA;
view.php 0 → 100644
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* Learning Plan Block
* This plugin serves as a database and plan for all learning activities in the organziation,
* where such activities are organized for a more structured learning program.
* @package blocks
* @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once('learning_plan_form.php');
require_once('lib.php');
require_once("{$CFG->libdir}/formslib.php");
global $DB, $USER, $OUTPUT, $PAGE, $CFG;
$viewpage = required_param('viewpage', PARAM_INT);
$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);
$PAGE->set_url('/blocks/learning_plan/view.php');
$PAGE->set_pagelayout('standard');
$PAGE->set_heading('Learning Plan');
$PAGE->set_title('Learning Plan');
$pageurl = new moodle_url('/blocks/learning_plan/view.php?viewpage='.$viewpage);
$learningplan_url = new moodle_url('/blocks/learning_plan/view.php?viewpage=1');
$nav_title = nav_title($viewpage);
$PAGE->navbar->ignore_active();
$PAGE->navbar->add(get_string("pluginname", 'block_learning_plan'), new moodle_url($learningplan_url));
$PAGE->navbar->add($nav_title);
echo $OUTPUT->header();
$table = new html_table();
$table->head = array('<a href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=1">'.get_string('learningpath', 'block_learning_plan').'</a>',
'<a href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2">'.get_string('add_training', 'block_learning_plan').'</a>',
'<a href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=4">'.get_string('assign_training_learningplan', 'block_learning_plan').'</a>',
'<a href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=5">'.get_string('assign_learningplan_user', 'block_learning_plan').'</a>',
'<a href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=6">'.get_string('trainingstatus', 'block_learning_plan').'</a>',
'<a href="'.$CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=7">'.get_string('search', 'block_learning_plan').'</a>');
$table->size = array('15%', '15%', '20%', '25%', '15%', '10%');
$table->align = array('center', 'center', 'center', 'center', 'center', 'center');
$table->width = '100%';
$table->data[] = $row;
echo html_writer::table($table);
if ($viewpage == 1) { // Add Learning Plans.
$form = new learningplan_form();
// Insert or Update data - Save button Click.
if($fromform = $form->get_data()) {
// print_object($fromform);
if($fromform->id) {
$DB->update_record('learning_learningplan', $fromform);
} else {
// Insert Record
$DB->insert_record('learning_learningplan', $fromform);
}
redirect($pageurl);
}
// Delete Record.
if($rem) {
echo $OUTPUT->confirm(get_string('plan_delete', 'block_learning_plan'),
'/blocks/learning_plan/view.php?viewpage=1&rem=rem&delete='.$id, '/blocks/learning_plan/view.php?viewpage=1');
if($delete) {
delete_learningplan_record('learning_learningplan', $delete, $pageurl);
}
}
// Edit Record.
if($edit) {
$get_learningplan = $DB->get_record('learning_learningplan', array('id'=>$id), '*');
$form = new learningplan_form(null, array('id' => $get_learningplan->id));
$form->set_data($get_learningplan);
}
} else if ($viewpage == 2) { // Add Training Types.
$form = new training_form();
if($fromform = $form->get_data()) {
// print_object($fromform);
if($fromform->id) {
// Update Record
$DB->update_record('learning_training', $fromform);
} else {
// Insert Record
$DB->insert_record('learning_training', $fromform);
}
redirect($pageurl);
}
// Delete Record.
if($rem) {
echo $OUTPUT->confirm(get_string('training_delete', 'block_learning_plan'),
'/blocks/learning_plan/view.php?viewpage=2&rem=rem&delete='.$id, '/blocks/learning_plan/view.php?viewpage=2');
if($delete) {
delete_learningplan_record('learning_training', $delete, $pageurl);
}
}
// Edit Record.
if($edit) {
$get_learningplan = $DB->get_record('learning_training', array('id'=>$id), '*');
$form = new training_form(null, array('id' => $get_learningplan->id));
$form->set_data($get_learningplan);
}
/*
// $fromform->save_file('$fromform', 'http://localhost/moodle/blocks/learning_plan/data/', null);
// echo $content;
// move_uploaded_file($fromform->attachment, "http://localhost/moodle/blocks/learning_plan/data/");
$name = $form->get_new_filename('attachment');
$importfile = "/data/{$name}";
$form->save_file('attachment', $importfile, true);
echo $importfile;
*/
} else if ($viewpage == 3) { // Add Training Method.
$form = new trainingmethod_form();
} else if ($viewpage == 4) { // Assign Training into Learning Plan.
$form = new assigntraining_learningplan__form();
if($fromform = $form->get_data()) {
// print_object($fromform);
if($fromform->id) {
// Update Record
$DB->update_record('learning_plan_training ', $fromform);
} else {
// Insert Record
$max = sizeof($fromform->t_id);
//print $max;
$record = new stdClass();
$record->lp_id = $fromform->l_id;
foreach ($fromform->t_id as $formtid) {
$record->t_id = $formtid;
$DB->insert_record('learning_plan_training', $record);
// Condtion for already assigned learning plan
// Getting lpt_id
// Get lp_id and getting user array
if(islp_assign_user( $record->lp_id)) {
$lpt_id = get_lpt_id($record->lp_id, $record->t_id);
$users = get_learningplan_user($record->lp_id);
// Insert User Training if leraning plan already assgin to user
$record2 = new stdClass();
$record2->lpt_id = $lpt_id;
foreach ($users as $userid) {
$record2->u_id = $userid->u_id;
$DB->insert_record('learning_user_trainingplan', $record2);
}
}
}
}
// redirect($pageurl);
}
// Delete Record.
if($rem) {
echo $OUTPUT->confirm(get_string('record_delete', 'block_learning_plan'), '/blocks/learning_plan/view.php?viewpage=4&rem=rem&delete='.$id,
'/blocks/learning_plan/view.php?viewpage=4');
if($delete) {
delete_learningplan_record('learning_plan_training', $delete, $pageurl);
}
}
} else if ($viewpage == 5) { // Assign Learning plan to User.
$form = new assignlerningplan_user_form();
if($fromform = $form->get_data()) {
// print_object($fromform);
if($fromform->id) {
// Update Record
$DB->update_record('learning_user_learningplan', $fromform);
} else {
// Insert Record
$record = new stdClass();
$record2 = new stdClass();
$record->lp_id = $fromform->l_id;
$record->assignee_id = $USER->id;
foreach ($fromform->u_id as $formtid) {
$record->u_id = $formtid;
$training = learningplan_training($fromform->l_id);
foreach($training as $train) {
$record2->lpt_id = $train->id;
$record2->u_id = $record->u_id;
// Insert in learning_user_trainingplan
$DB->insert_record('learning_user_trainingplan', $record2);
}
// Insert in learning_user_learningplan
$DB->insert_record('learning_user_learningplan', $record);
}
}
redirect($pageurl);
}
// Delete Record.
if($rem) {
echo $OUTPUT->confirm(get_string('record_delete', 'block_learning_plan'),
'/blocks/learning_plan/view.php?viewpage=5&rem=rem&delete='.$id, '/blocks/learning_plan/view.php?viewpage=5');
if($delete) {
delete_learningplan_record('learning_user_learningplan', $delete, $pageurl);
// echo $pageurl;
}
}
} else if ($viewpage == 6) { // Set Training Status.
$form = new trainingstatus_form();
$setting = optional_param('setting', null, PARAM_INT);
if($fromform = $form->get_data()) {
$status_id = status_id($fromform->l_id, $fromform->u_id, $fromform->t_id);
$fromform->id = $status_id;
$DB->update_record('learning_user_trainingplan', $fromform);
}
} else if ($viewpage == 7) {
$form = new search();
}
// Set viewpage with form.
$toform['viewpage'] = $viewpage;
$form->set_data($toform);
// Display Form.
$form->display();
// Form Cancel.
if($fromform = $form->is_cancelled()) {
redirect("{$CFG->wwwroot}"."/blocks/learning_plan/view.php?viewpage=".$viewpage);
}
// Display List.
if($table=$form->display_list()) {
// echo '<div id="prints">';
echo html_writer::table($table);
// echo '</div>';
}
$PAGE->requires->js_init_call('M.block_learning_plan.init', array($viewpage, $setting));
echo $OUTPUT->footer();
// End Form Display
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment