diff --git a/blocks/workflow_diagram/block_workflow_diagram.php b/blocks/workflow_diagram/block_workflow_diagram.php new file mode 100644 index 0000000..b47bd4b --- /dev/null +++ b/blocks/workflow_diagram/block_workflow_diagram.php @@ -0,0 +1,72 @@ +. + +/** + * Workflow Diagram Block page. + * + * @package blocks + * @subpackage workflow_diagram + * @author Ivan Latorre Negrell + * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +class block_workflow_diagram extends block_list { + function init() { + $this->title = get_string('pluginname', 'block_workflow_diagram'); + } + + public function applicable_formats() { + return array('course-view' => true); + } + + function get_content() { + global $CFG, $COURSE; + + require_once($CFG->dirroot . '/blocks/workflow_diagram/datalib.php'); + + if ($this->content !== NULL) { + return $this->content; + } + + $this->content = new stdClass; + $this->content->items = array(); + $this->content->icons = array(); + $this->content->footer = ''; + + if (!isloggedin()) { + return $this->content; + } + + $course = $this->page->course; + + $context = get_context_instance(CONTEXT_COURSE, $course->id); + if (has_capability('moodle/course:manageactivities', $context)) { + $this->content->items[] = ''.get_string('editwf', 'block_workflow_diagram').''; + } + + //Link a veure gràfic passant arguments + $url = new moodle_url('/blocks/workflow_diagram/graphview.php', array('blockid' => $this->instance->id, 'courseid' => $COURSE->id)); + $this->content->items[] = html_writer::link($url, get_string('viewgraphic', 'block_workflow_diagram')); + + $wf = new block_workflow_diagram_manager(); + $dayworkload = $wf->get_hoursperday_by_course_date($course->id, time()); + $this->content->items[] = get_string('todayworkload', 'block_workflow_diagram').$dayworkload; + + return $this->content; + } +} diff --git a/blocks/workflow_diagram/datalib.php b/blocks/workflow_diagram/datalib.php new file mode 100644 index 0000000..194dd06 --- /dev/null +++ b/blocks/workflow_diagram/datalib.php @@ -0,0 +1,243 @@ +. + +/** + * Library of functions for database manipulation. + * + * Other main libraries: + * - weblib.php - functions that produce web output + * - moodlelib.php - general-purpose Moodle functions + * + * @package core + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); + +/** + * Number of seconds to wait before updating lastaccess information in DB. + */ +define('LASTACCESS_UPDATE_SECS', 60); + +class block_workflow_diagram_manager { + + public function get_workflow_from_coursemodule($cmid, $courseid = 0, $strictness = IGNORE_MISSING) { + global $DB; + + $params = array('cmid' => $cmid); + + $courseselect = ""; + + if ($courseid) { + $courseselect = "AND cm.course = :courseid"; + $params['courseid'] = $courseid; + } + + $sql = "SELECT wd.* + FROM {block_workflow_diagram} wd + JOIN {course_modules} cm ON cm.id = wd.cmid + WHERE wd.cmid = :cmid + $courseselect"; + + return $DB->get_record_sql($sql, $params, $strictness); + } + + /** + * Get the total hours of all the workflow of a course by a given date + * @param integer $courseid + * @param integer $date + * @return float with sum of hours with name hours + */ + public function get_hoursperday_by_course_date($courseid, $date, $strictness = IGNORE_MISSING) { + global $DB; + + $midnightdate = usergetmidnight($date); //Midnight of the current day + + $params = array('date1' => $midnightdate, 'date2' => $midnightdate+(24*3600), 'course' => $courseid ); + + $sql = 'SELECT SUM(wf.hoursperday) as hours + FROM {block_workflow_diagram} wf + JOIN {course_modules} cm ON cm.id = wf.cmid + WHERE :date1 >= wf.startdate AND :date2 <= wf.finishdate AND cm.course = :course'; + + return $DB->get_record_sql($sql, $params, $strictness)->hours; + } + + /** + * Add a workflow diagram instance + * @param integer $cmid + * @param integer $startdate + * @param integer $finishdate + * @param integer $hours + * @param float $hoursperday + * @return id of workflow or false if already added + */ + public function block_workflow_diagram_add_instance($cmid, $startdate, $finishdate, $hours, $hoursperday) { + global $DB; + + $wd = $this->block_workflow_diagram_get_instance($cmid); + + if (empty($wd)) { + $wd->cmid = $cmid; + $wd->startdate = $startdate; + $wd->finishdate = $finishdate; + $wd->hours = $hours; + $wd->hoursperday = $hoursperday; + return $DB->insert_record('block_workflow_diagram', $wd); + } else { + return false; + } + } + + /** + * Add or modifies a workflow diagram instance + * @param integer $cmid + * @param integer $startdate + * @param integer $finishdate + * @param integer $hours + * @param float $hoursperday + * @return id of workflow or false if already added + */ + public function add_modify_workflow_diagram_add_or_modify_instance($cmid, $startdate, $finishdate, $hours, $hoursperday) { + global $DB; + + $existingField = $this->block_workflow_diagram_get_instance($cmid); + + $wd->cmid = $cmid; + $wd->startdate = $startdate; + $wd->finishdate = $finishdate; + $wd->hours = $hours; + $wd->hoursperday = $hoursperday; + if (empty($existingField)) { + return $DB->insert_record('block_workflow_diagram', $wd); + } else { + $wd->id = $existingField->id; + return $DB->update_record('block_workflow_diagram', $wd); + } + } + + /** + * Return a workflow diagram of a coursemodule + * @param integer $cmid + * @return array of workflow + */ + public function block_workflow_diagram_get_instance($cmid) { + global $DB; + return $DB->get_record('block_workflow_diagram', + array('cmid' => $cmid)); + } + + /** + * Delete a workflow diagram + * @param integer $cmid + * @return bool true + */ + public function block_workflow_diagram_remove_instance($cmid) { + global $DB; + return $DB->delete_records('block_workflow_diagram', + array('cmid' => $cmid)); + } + + /** + * Get activity name + * @param int $cmid + * @return activity name + * + */ + public function block_workflow_diagram_get_activity_name($cmid) { + global $DB; + + $params = array('cmid'=>$cmid); + + if (!$modulename = $DB->get_field_sql("SELECT md.name + FROM {modules} md + JOIN {course_modules} cm ON cm.module = md.id + WHERE cm.id = :cmid", $params)) { + return false; + } + + $sql = "SELECT m.name + FROM {course_modules} cm + JOIN {".$modulename."} m ON m.id = cm.instance + WHERE cm.id = :cmid"; + + return $DB->get_record_sql($sql, $params); + } + + /** + * Get array of activities + * @param int $courseid + * @param date $date + * @return array of activities (id and hoursperday) + * + */ + public function block_workflow_diagram_get_activities_array_for_day($courseid, $date) { + global $DB; + + //$midnightdate = usergetmidnight($date); + $params = array('date1' => $date, 'date2' => $date+DAYSECS, 'course' => $courseid ); + + $sql = 'SELECT cm.id, wf.hoursperday + FROM {block_workflow_diagram} wf + JOIN {course_modules} cm ON cm.id = wf.cmid + WHERE :date1 >= wf.startdate AND :date2 <= wf.finishdate AND cm.course = :course'; + + return $DB->get_records_sql($sql, $params); + } + + /** + * Get a JSON string with all the chart information + * @param integer $courseid + * @return string json representation of data array + */ + public function block_workflow_diagram_get_json_array_for_chart($courseid, $time) { + + //Get current week + $unixtime = usergetmidnight($time); //Seconds passed since... + for ($i=0; $i<7; $i++) { + $auxtime = $unixtime + ($i * DAYSECS); + $date[$i] = usergetdate($auxtime); + + $result = $this->block_workflow_diagram_get_activities_array_for_day($courseid, $auxtime); + $grapharray[$i] = array('date' => $date[$i]['mday'].'/'.$date[$i]['mon'].'/'.$date[$i]['year']); + + if($result){ + reset($result); + for($j=0; $jblock_workflow_diagram_get_activity_name(current($result)->id); + + /* See http://php.net/manual/en/function.array-push.php + * + * What the next line does is push back the hoursperday on the array + * whith de id between the brackets. + * + * Ex: $data[$key] = $value; + * The "+0" is to convert the data to a number. + */ + $grapharray[$i][current($result)->id.' - '.$name->name] = current($result)->hoursperday+0; + + next($result); + } + } + } + return json_encode($grapharray); + } + +} + +?> diff --git a/blocks/workflow_diagram/db/access.php b/blocks/workflow_diagram/db/access.php new file mode 100644 index 0000000..3aafc81 --- /dev/null +++ b/blocks/workflow_diagram/db/access.php @@ -0,0 +1,51 @@ +. + +/** + * News items block caps. + * + * @package block_news_items + * @copyright Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$capabilities = array( + + 'block/workflow_diagram:myaddinstance' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + + 'block/workflow_diagram:addinstance' => array( + 'riskbitmask' => RISK_SPAM | RISK_XSS, + + 'captype' => 'write', + 'contextlevel' => CONTEXT_BLOCK, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/site:manageblocks' + ), +); diff --git a/blocks/workflow_diagram/db/install.xml b/blocks/workflow_diagram/db/install.xml new file mode 100644 index 0000000..eed6ff5 --- /dev/null +++ b/blocks/workflow_diagram/db/install.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/blocks/workflow_diagram/db/upgrade.php b/blocks/workflow_diagram/db/upgrade.php new file mode 100644 index 0000000..f16ce8e --- /dev/null +++ b/blocks/workflow_diagram/db/upgrade.php @@ -0,0 +1,53 @@ +. + +/** + * This file keeps track of upgrades to the workflow diagram block + * + * Sometimes, changes between versions involve alterations to database structures + * and other major things that may break installations. + * + * The upgrade function in this file will attempt to perform all the necessary + * actions to upgrade your older installation to the current version. + * + * If there's something it cannot do itself, it will tell you what you need to do. + * + * The commands in here will all be database-neutral, using the methods of + * database_manager class + * + * Please do not forget to use upgrade_set_timeout() + * before any action that may take longer time to finish. + * + * @since 2.0 + * @package blocks + * @copyright 2010 Jerome Mouneyrac + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * + * @param int $oldversion + * @param object $block + */ +function xmldb_block_workflow_diagram_upgrade($oldversion) { + global $CFG, $DB; + + // Moodle v2.4.0 release upgrade line + // Put any upgrade step following this + + return true; +} diff --git a/blocks/workflow_diagram/graphview.php b/blocks/workflow_diagram/graphview.php new file mode 100644 index 0000000..fe99c79 --- /dev/null +++ b/blocks/workflow_diagram/graphview.php @@ -0,0 +1,98 @@ +. + +/** + * Shows information and the diagram + * + * @package blocks + * @subpackage workflow_diagram + * @author Sergi Rodríguez + * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require_once('../../config.php'); +require_once($CFG->dirroot . '/blocks/workflow_diagram/datalib.php'); +$wdmanager = new block_workflow_diagram_manager(); + +global $DB, $OUTPUT, $PAGE; + +// Check for all required variables. +$courseid = required_param('courseid', PARAM_INT); +$blockid = required_param('blockid', PARAM_INT); + +// Next look for optional variables. +$id = optional_param('id', 0, PARAM_INT); + +if (!$course = $DB->get_record('course', array('id' => $courseid))) { + print_error('invalidcourse', 'block_workflow_diagram', $courseid); +} + +require_login($course); +$PAGE->set_url('/blocks/workflow_diagram/graphview.php', array('id' => $courseid)); +$PAGE->set_title(get_string("pluginname", "block_workflow_diagram")); +$PAGE->set_pagelayout('incourse'); +$PAGE->set_heading($course->fullname); + +$settingsnode = $PAGE->settingsnav->add(get_string('wfsettings', 'block_workflow_diagram')); +$wfurl = new moodle_url('/blocks/workflow_diagram/graphview.php', array('id' => $id, 'courseid' => $courseid, 'blockid' => $blockid)); +$editnode = $settingsnode->add(get_string('graphview', 'block_workflow_diagram'), $wfurl); +$editnode->make_active(); + +//Printar header +echo $OUTPUT->header(); + +$i = 0; +if (optional_param('nextweek', false, PARAM_BOOL) || optional_param('lastweek', false, PARAM_BOOL) && confirm_sesskey()) { + $i = optional_param('counter', false, PARAM_INTEGER); + if (optional_param('nextweek', false, PARAM_BOOL)) + $i++; + elseif (optional_param('lastweek', false, PARAM_BOOL)) + $i--; +} + $formstart = '
+ + + + '; + $formend = '
'; + $formhiddennext = ''; + $formhiddenlast = ''; + $button1 = $formstart . $formhiddennext. '' . $formend; + $button2 = $formstart . $formhiddenlast. '' . $formend; + +//Print page +if (ajaxenabled()) { + + $result = $wdmanager->get_hoursperday_by_course_date($courseid, time()); + echo html_writer::tag('div', get_string('todayworkload', 'block_workflow_diagram').$result.'

', array('id' => 'daylyhours')); + + $time = time() + ($i * WEEKSECS); + $jsondata = $wdmanager->block_workflow_diagram_get_json_array_for_chart($courseid, $time); + echo html_writer::tag('div', get_string('weekdiagram', 'block_workflow_diagram'), array('id' => 'mychart')); //Equival a echo '
'; + $PAGE->requires->js_init_call('M.block_workflow_diagram.printgraph', array($jsondata)); +} +else { + echo html_writer::tag('div', get_string('jsdisabled', 'block_workflow_diagram'), array('id' => 'mychart')); //Div que conté la gràfica +} + + echo html_writer::tag('div', '
'.$button2.'
'.$button1, array('id' => 'buttons')); + //echo html_writer::tag('div', $button2, array('id' => 'buttons')); + + +//Print moodle elements +echo $OUTPUT->footer(); \ No newline at end of file diff --git a/blocks/workflow_diagram/index.php b/blocks/workflow_diagram/index.php new file mode 100644 index 0000000..ae06b3e --- /dev/null +++ b/blocks/workflow_diagram/index.php @@ -0,0 +1,238 @@ +. + +/** + * Edition page for the workflow block + * + * @package blocks + * @subpackage workflow_diagram + * @author Ivan Latorre Negrell + * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +require_once("../../config.php"); + +$id = required_param('id', PARAM_INT); // Course ID + +$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); +require_login($course); +$PAGE->set_url('/mod/assign/index.php', array('id' => $id)); +$PAGE->set_pagelayout('incourse'); + +// You need moodle/course:manageactivities in addition to question capabilities to access this page. +$context = get_context_instance(CONTEXT_COURSE, $course->id); +require_capability('moodle/course:manageactivities', $context); + +// Print the header +$strworkflow = get_string("pluginname", "block_workflow_diagram"); +$PAGE->navbar->add($strworkflow); +$PAGE->set_title($strworkflow); +$PAGE->set_heading($course->fullname); +echo $OUTPUT->header(); + +require_once($CFG->dirroot . '/blocks/workflow_diagram/datalib.php'); +$wdmanager = new block_workflow_diagram_manager(); + +// Look if the buttons create, update or delete have been pressed. +if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) { + $cmid = optional_param('cmid', false, PARAM_INT); + $inidateday = optional_param('initialdateday', false, PARAM_RAW); + $inidatemonth = optional_param('initialdatemonth', false, PARAM_RAW); + $inidateyear = optional_param('initialdateyear', false, PARAM_RAW); + $enddateday = optional_param('finaldateday', false, PARAM_RAW); + $enddatemonth = optional_param('finaldatemonth', false, PARAM_RAW); + $enddateyear = optional_param('finaldateyear', false, PARAM_RAW); + $hours = optional_param('hours', 0, PARAM_INT); + + $inidate = make_timestamp($inidateyear, $inidatemonth, $inidateday); + $enddate = make_timestamp($enddateyear, $enddatemonth, $enddateday); + + if ($hours === "" || ($enddate-$inidate)<0) { + echo get_string('editerror', 'block_workflow_diagram'); + } else { + $period = abs($enddate - $inidate); + if ($period = floor($period / DAYSECS)) { + $hoursperday = round($hours / $period, 2); + } else { + $hoursperday = 0; + } + $wdmanager->add_modify_workflow_diagram_add_or_modify_instance($cmid, $inidate, $enddate, $hours, $hoursperday); + } +} else if (optional_param('delete', false, PARAM_BOOL) && confirm_sesskey()) { + $cmid = optional_param('cmid', false, PARAM_INT); + $wdmanager->block_workflow_diagram_remove_instance($cmid); +} + +$formstart = '
'; +$formend = '
'; +$formhiddensave = ' + '; +$formhiddendelete = ' + '; + +//Array with all the activities +$activitiesarray = array('assign', 'chat', 'choice', 'data', 'forum', 'glossary', 'lesson', + 'lti', 'quiz', 'scorm', 'survey', 'wiki', 'workshop'); + +$noactivities = true; + +//Print a table for each activity +for ($i = 0; $i < 13; $i++) { + $stractivities = get_string("modulenameplural", $activitiesarray[$i]); + $activities = get_all_instances_in_course($activitiesarray[$i], $course); + if ($activities) { + $nodatefields = false; + $strtime1 = 'nothing'; + $strtime2 = 'nothing'; + $time1 = 'nothing'; + $time2 = 'nothing'; + if($activitiesarray[$i] === 'quiz'){ + $strtime1 = 'quizopens'; + $strtime2 = 'quizcloses'; + $time1 = 'timeopen'; + $time2 = 'timeclose'; + }else if($activitiesarray[$i] === 'assign'){ + $strtime1 = 'allowsubmissionsfromdate'; + $strtime2 = 'duedate'; + $time1 = 'allowsubmissionsfromdate'; + $time2 = 'duedate'; + }else if($activitiesarray[$i] === 'forum'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'data'){ + $strtime1 = 'availablefromdate'; + $strtime2 = 'availabletodate'; + $time1 = 'timeavailablefrom'; + $time2 = 'timeavailableto'; + }else if($activitiesarray[$i] === 'lti'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'chat'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'choice'){ + $strtime1 = 'choiceopen'; + $strtime2 = 'choiceclose'; + $time1 = 'timeopen'; + $time2 = 'timeclose'; + }else if($activitiesarray[$i] === 'survey'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'glossary'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'lesson'){ + $strtime1 = 'lessonopens'; + $strtime2 = 'lessoncloses'; + $time1 = 'available'; + $time2 = 'deadline'; + }else if($activitiesarray[$i] === 'workshop'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'wiki'){ + $nodatefields = true; + }else if($activitiesarray[$i] === 'scorm'){ + $strtime1 = 'scormopen'; + $strtime2 = 'duedate'; + $time1 = 'timeopen'; + $time2 = 'timeclose'; + } + + $table = new html_table(); + if($nodatefields){ + $table->head = array($stractivities, get_string('startdate', 'block_workflow_diagram'), + get_string('enddate', 'block_workflow_diagram'), get_string('hoursofwork', 'block_workflow_diagram'), + get_string('save', 'block_workflow_diagram') . " " . get_string('workflow', 'block_workflow_diagram'), + get_string('delete', 'block_workflow_diagram') . " " . get_string('workflow', 'block_workflow_diagram')); + $table->align = array('left', 'left', 'left', 'left', 'center', 'center'); + }else{ + $table->head = array($stractivities, get_string($strtime1, $activitiesarray[$i]), + get_string($strtime2, $activitiesarray[$i]), get_string('startdate', 'block_workflow_diagram'), + get_string('enddate', 'block_workflow_diagram'), get_string('hoursofwork', 'block_workflow_diagram'), + get_string('save', 'block_workflow_diagram') . " " . get_string('workflow', 'block_workflow_diagram'), + get_string('delete', 'block_workflow_diagram') . " " . get_string('workflow', 'block_workflow_diagram')); + $table->align = array('left', 'left', 'left', 'left', 'left', 'left', 'center', 'center'); + } + $table->data = array(); + foreach ($activities as $activity) { + $cm = get_coursemodule_from_instance($activitiesarray[$i], $activity->id, 0, false, MUST_EXIST); + $formhiddencm = ''; + + $link = $formstart . html_writer::link(new moodle_url('/mod/'.$activitiesarray[$i].'/view.php', array('id' => $cm->id)), $activity->name); + if(!$nodatefields){ + $date1 = '-'; + if ($activity->$time1) { + $date1 = userdate($activity->$time1); + } + $date2 = '-'; + if ($activity->$time2) { + $date2 = userdate($activity->$time2); + } + } + + if (!$wf = $wdmanager->block_workflow_diagram_get_instance($cm->id)) { + $inidate = html_writer::select_time('days', 'initialdateday'). + html_writer::select_time('months', 'initialdatemonth'). + html_writer::select_time('years', 'initialdateyear'); + $enddate = html_writer::select_time('days', 'finaldateday'). + html_writer::select_time('months', 'finaldatemonth'). + html_writer::select_time('years', 'finaldateyear'); + if(!$nodatefields){ + if ($activity->$time1) { + $inidate = html_writer::select_time('days', 'initialdateday', $activity->$time1). + html_writer::select_time('months', 'initialdatemonth', $activity->$time1). + html_writer::select_time('years', 'initialdateyear', $activity->$time1); + } + if ($activity->$time2) { + $enddate = html_writer::select_time('days', 'finaldateday', $activity->$time2). + html_writer::select_time('months', 'finaldatemonth', $activity->$time2). + html_writer::select_time('years', 'finaldateyear', $activity->$time2); + } + } + + $hours = ''; + + $boton = $formhiddensave . $formhiddencm . '' . $formend; + $delete = ''; + } else { + $inidate = html_writer::select_time('days', 'initialdateday', $wf->startdate). + html_writer::select_time('months', 'initialdatemonth', $wf->startdate). + html_writer::select_time('years', 'initialdateyear', $wf->startdate); + $enddate = html_writer::select_time('days', 'finaldateday', $wf->finishdate). + html_writer::select_time('months', 'finaldatemonth', $wf->finishdate). + html_writer::select_time('years', 'finaldateyear', $wf->finishdate); + $hours = ''; + $boton = $formhiddensave . $formhiddencm . '' . $formend; + $delete = $formstart . $formhiddendelete . $formhiddencm . '' . $formend; + } + + if ($nodatefields) + $row = array($link, $inidate, $enddate, $hours, $boton, $delete); + else + $row = array($link, $date1, $date2, $inidate, $enddate, $hours, $boton, $delete); + + $table->data[] = $row; + } + + echo html_writer::table($table); + + $noactivities = false; + } +} + +//If there isn't any activity +if ($noactivities) { + notice(get_string('thereareno', 'moodle', $stractivities), "../../course/view.php?id=$course->id"); + die; +} + +echo $OUTPUT->footer(); + diff --git a/blocks/workflow_diagram/lang/en/block_workflow_diagram.php b/blocks/workflow_diagram/lang/en/block_workflow_diagram.php new file mode 100644 index 0000000..5293304 --- /dev/null +++ b/blocks/workflow_diagram/lang/en/block_workflow_diagram.php @@ -0,0 +1,47 @@ +. + +/** + * Strings for component 'block_news_items', language 'en', branch 'MOODLE_20_STABLE' + * + * @package block_news_items + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['news_items:addinstance'] = 'Add a new workflow diagram block'; +$string['news_items:myaddinstance'] = 'Add a new navigation block to the My Moodle page'; +$string['pluginname'] = 'Workflow Diagram'; +$string['save'] = 'Save'; +$string['create'] = 'Create'; +$string['update'] = 'Update'; +$string['delete'] = 'Delete'; +$string['startdate'] = 'Start date'; +$string['enddate'] = 'End date'; +$string['hoursofwork'] = 'Hours of work'; +$string['workflow'] = 'workflow'; +$string['editwf'] = 'Edit workflow'; +$string['viewgraphic'] = 'View diagram'; +$string['wfsettings'] = 'WfD Settings'; +$string['graphview'] = 'WfD: Diagram view'; +$string['invalidcourse'] = 'Invalid course'; +$string['jsdisabled'] = 'Error: Javascript is disabled'; +$string['todayworkload'] = 'Today\'s workload: '; +$string['weekdiagram'] = 'Workload distribution:'; +$string['next'] = 'Next week'; +$string['last'] = 'Last week'; +$string['editerror'] = 'Hours fild empty or start date bigger than finish date.'; diff --git a/blocks/workflow_diagram/lang/es/block_workflow_diagram.php b/blocks/workflow_diagram/lang/es/block_workflow_diagram.php new file mode 100644 index 0000000..5a08928 --- /dev/null +++ b/blocks/workflow_diagram/lang/es/block_workflow_diagram.php @@ -0,0 +1,47 @@ +. + +/** + * Strings for component 'block_news_items', language 'es', branch 'MOODLE_20_STABLE' + * + * @package block_news_items + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['news_items:addinstance'] = 'Añadir un nuevo bloque de diagrama de flujo de trabajo'; +$string['news_items:myaddinstance'] = 'Add a new navigation block to the My Moodle page'; +$string['pluginname'] = 'Diagrama del flujo de trabajo'; +$string['save'] = 'Guardar'; +$string['create'] = 'Crear'; +$string['update'] = 'Actualizar'; +$string['delete'] = 'Eliminar'; +$string['startdate'] = 'Fecha de inicio'; +$string['enddate'] = 'Fecha final'; +$string['hoursofwork'] = 'Horas de trabajo'; +$string['workflow'] = 'Flujo de trabajo'; +$string['editwf'] = 'Editar carga de trabajo'; +$string['viewgraphic'] = 'Ver diagrama'; +$string['wfsettings'] = 'Ajustes de WfD'; +$string['graphview'] = 'WfD: Diagrama'; +$string['invalidcourse'] = 'Curso no adecuado'; +$string['jsdisabled'] = 'Error: Javascript está desactivado'; +$string['todayworkload'] = 'Carga de trabajo para hoy: '; +$string['weekdiagram'] = 'Distribución de carga de trabajo: '; +$string['next'] = 'Siguiente semana'; +$string['last'] = 'Anterior semana'; +$string['editerror'] = 'Campo de horas vacío o fecha de inicio mayor a la de final.'; \ No newline at end of file diff --git a/blocks/workflow_diagram/module.js b/blocks/workflow_diagram/module.js new file mode 100644 index 0000000..7f9db53 --- /dev/null +++ b/blocks/workflow_diagram/module.js @@ -0,0 +1,41 @@ + +M.block_workflow_diagram = { + + Y : null, + transaction : [], + + printgraph : function(Y, params){ + this.Y = Y; + + YUI().use('charts', function (Y) { + + //Get data from JSON string parameter + var data = eval('(' + params + ')'); + + var mychart = new Y.Chart({ + dataProvider:data, + render:"#mychart", //Indica el
on es mostrarà + type:"column", //Tipus de gràfica, es pot canviar + title: "Workflow Diagram", + stacked:true, + categoryKey:"date", + //categoryType:"time", + + horizontalGridlines: { + styles: { + line: { + color: "#dad8c9" + } + } + }, + verticalGridlines: { + styles: { + line: { + color: "#dad8c9" + } + } + } + }); + }); + } +} \ No newline at end of file diff --git a/blocks/workflow_diagram/styles.css b/blocks/workflow_diagram/styles.css new file mode 100644 index 0000000..d948cf1 --- /dev/null +++ b/blocks/workflow_diagram/styles.css @@ -0,0 +1,5 @@ + +#mychart { + width: 600px; + height: 400px; +} \ No newline at end of file diff --git a/blocks/workflow_diagram/version.php b/blocks/workflow_diagram/version.php new file mode 100644 index 0000000..1d009c3 --- /dev/null +++ b/blocks/workflow_diagram/version.php @@ -0,0 +1,30 @@ +. + +/** + * Version details + * + * @package block + * @subpackage news_items + * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2012112100; // The current plugin version (Date: YYYYMMDDXX) +$plugin->requires = 2012061700; // Requires this Moodle version +$plugin->component = 'block_workflow_diagram'; // Full name of the plugin (used for diagnostics)