39da5eb9 by logesh

notes plugin

1 parent c1ef11fc
Copyright (c) 2013-2016 GitHub, Inc. and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
Mynotes Block
--------------
A simpler mynotes system that integrates as moodle block to save user's notes
from different areas such as site, course, modules, etc.
This is a free plugin for Moodle that help to preserve uesr's notes.
Settings
--------
* Set the position for display editing icon.
* Set the number of records to be display
Appearances
----------------------
* This block display on site page, any course-* and user page.
Features
--------
Any authenticated users can:
* Save new notes
* View saved notes by him/her
* Delete own notes
Requirements
------------
* Moodle version 3.4
Installation
------------
Within the ZIP file is a folder named mynotes, copy this folder into
your Moodle blocks folder (e.g /var/moodle/htdocs/blocks/ ). Once the folder
has been copied into your blocks folder, login to Moodle as admin and it should
detect the new block and install it.
Note that if you download the ZIP from Github the mynotes folder is called
'moodle-block_mynotes' and needs to be renamed after extraction to 'mynotes'.
Once installed this block, automatically added to page while installing. There is no need to add to every page.
\ 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/>.
/**
* The mynotes block
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/blocks/mynotes/lib.php');
/**
* Mynotes block.
*
* @package block_mynotes
*
*/
class block_mynotes extends block_base {
public function init() {
$this->title = get_string('pluginname', 'block_mynotes');
}
public function has_config() {
return true;
}
public function applicable_formats() {
return array('all' => true);
}
public function instance_allow_multiple() {
return false;
}
public function hide_header() {
global $PAGE;
if (!$PAGE->user_is_editing()) {
return true;
}
}
/**
* The content object.
*
* @return stdObject
*/
public function get_content() {
global $CFG, $PAGE;
static $jscount = 0;
if ($this->content !== null) {
return $this->content;
}
if (!isloggedin() or isguestuser()) {
return ''; // Never useful unless you are logged in as real users
}
if (!in_array($PAGE->context->contextlevel, array(CONTEXT_COURSE, CONTEXT_SYSTEM, CONTEXT_MODULE, CONTEXT_USER))) {
return '';
}
$this->content = new stdClass();
$this->content->footer = '';
$this->content->text = '';
if (empty($this->instance)) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
if ($PAGE->user_is_editing()) {
$this->content->text = '<div class="inline-mynotes-opener">'.get_string('showmynotes', 'block_mynotes').'</div>';
}
$this->content->footer = '';
if ($jscount == 0) {
$this->block_mynotes_get_required_javascript();
$jscount++;
}
return $this->content;
}
/*
* load JS that requires into the page.
*/
private function block_mynotes_get_required_javascript() {
global $PAGE, $CFG;
list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
$config = get_config('block_mynotes');
$mm = new block_mynotes_manager();
$currenttabindex = $mm->get_current_tab($context, $PAGE);
$arguments = array( 'arg'=> array(
'instanceid' => $this->instance->id,
'editing' => ($PAGE->user_is_editing()),
'editingicon_pos' => ($PAGE->user_is_editing()) ? 'mynotes-pos-inline' : $config->icondisplayposition,
'maxallowedcharacters' => $config->characterlimit,
'contextid' => $context->id,
'maxallowedcharacters_warning' => get_string('notmorethan', 'block_mynotes', $config->characterlimit),
'contextareas' => $mm->get_available_contextareas(),
'currenttabindex' => ($currenttabindex == null ? 'site' : $currenttabindex),
'perpage' => $config->mynotesperpage,
),
);
// $PAGE->requires->string_for_js('charactersleft', 'block_mynotes');
$PAGE->requires->string_for_js('notmorethan', 'block_mynotes');
$PAGE->requires->string_for_js('mynotes', 'block_mynotes');
$PAGE->requires->string_for_js('showmynotes', 'block_mynotes');
$PAGE->requires->string_for_js('savedsuccess', 'block_mynotes');
$PAGE->requires->string_for_js('save', 'block_mynotes');
$PAGE->requires->string_for_js('placeholdercontent', 'block_mynotes');
$PAGE->requires->string_for_js('deletemynotes', 'block_mynotes');
$PAGE->requires->string_for_js('mynotescount', 'block_mynotes');
$PAGE->requires->string_for_js('previouspage', 'block_mynotes');
$PAGE->requires->string_for_js('nextpage', 'block_mynotes');
$PAGE->requires->string_for_js('nothingtodisplay', 'block_mynotes');
$PAGE->requires->string_for_js('mynotessavedundertab', 'block_mynotes');
$PAGE->requires->string_for_js('cancel', 'moodle');
$this->page->requires->js_call_amd('block_mynotes/mynotesblock', 'init', $arguments);
}
}
\ No newline at end of file
if (url.includes('/mod/hvp/')){
$(document).ready(function(){
var m = document.getElementsByClassName("h5p-iv-hotkey-instructions");
console.log(m);
var check=$("div.h5p-iv-hotkey-instructions").html();
var check1=$('div.h5p-iv-hotkey-instructions').text();
console.log(check);
console.log(check1);
setTimeout(function(){
$('#mynotepencil').click(function(){
var check=$('.h5p-iv-hotkey-instructions').html();
var check1=$('.h5p-iv-hotkey-instructions').text();
console.log(check);
console.log(check1);
alert(check);
// var valuetime= $(".h5p-control, .h5p-simple-time, .h5p-current, span.human-time").text();
// var newvalue= $('.h5p-control, .h5p-simple-time, .h5p-current, span.human-time').text();
var valuetime1= $(".h5p-controls-right .h5p-control .h5p-time .h5p-current .human-time").text();
var newvalue1= $('.h5p-controls-right .h5p-control .h5p-time .h5p-current .human-time').text();
// console.log(" click notes"+newvalue);
// var y =$('.human-time').html();
// console.log("first"+valuetime);console.log("second"+newvalue);
console.log("first"+valuetime1);console.log("second"+newvalue1);
// alert("hi");
});
}, 0500);
});
}
\ 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/>.
/**
* Mynotes block caps.
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/mynotes:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/mynotes:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
<?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/>.
defined('MOODLE_INTERNAL') || die();
/**
* Mynotes block installation.
*
* @package block_mynotes
*/
function xmldb_block_mynotes_install() {
global $DB;
$obj = new stdClass();
$obj->blockname = 'mynotes';
$obj->parentcontextid = SITEID;
$obj->showinsubcontexts = 1;
$obj->pagetypepattern = '*';
$obj->defaultweight = 0;
$obj->defaultregion = BLOCK_POS_LEFT;
$obj->configdata = '';
$obj->timecreated = time();
$obj->timemodified = time();
$DB->insert_record('block_instances', $obj);
}
\ No newline at end of file
<?php
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/mynotes/db" VERSION="20160404" COMMENT="XMLDB file for my notes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
<TABLES>
<TABLE NAME="block_mynotes" COMMENT="My Notes">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="contextarea" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="content" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
<?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/>.
/**
* Strings for component 'block_mynotes', language 'en', branch 'MOODLE_29_STABLE'
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
$string['mynotes:myaddinstance'] = 'Add a new mynotes block to Dashboard';
$string['mynotes:addinstance'] = 'Add a new mynotes block';
$string['mynotes:post'] = 'Add a new note';
$string['mynotes:view'] = 'View own notes';
$string['mynotes:delete'] = 'Delete own notes';
$string['pluginname'] = 'My Notes';
$string['disabledmynotes'] = 'Disabled my notes';
$string['showmynotes'] = 'Show my notes';
$string['addnotes'] = 'Add notes';
$string['mynotes'] = 'My notes';
$string['mynotescount'] = 'Total count: ';
$string['mynotesrequirelogin'] = 'You must login to add/view your notes';
$string['deletemynotes'] = 'Delete note';
$string['site'] = 'Site';
$string['course'] = 'Course';
$string['mod'] = 'Modules';
$string['user'] = 'Personal';
$string['save'] = 'Save';
$string['savedsuccess'] = 'Your note has been added successfully';
$string['mynotessavedundertab'] = 'For this page, your notes will be saved under <strong>{$a} tab</strong>.';
$string['placeholdercontent'] = 'Enter note content...';
$string['charactersleft'] = 'Characters left: ';
$string['characterlimit'] = 'Characters limit: ';
$string['characterlimit_help'] = 'This setting defines the maximum characters limit to write a note.';
$string['notmorethan'] = 'Can not enter more than {$a} characters';
$string['bottomright'] = 'Bottom-Right';
$string['bottomleft'] = 'Bottom-Left';
$string['topright'] = 'Top-Right';
$string['topleft'] = 'Top-Left';
$string['icondisplayposition'] = 'Icon position';
$string['icondisplayposition_help'] = 'Choose the position for Note-Icon which will used to open popup.';
$string['mynotesperpage'] = 'Per page';
$string['mynotesperpage_help'] = 'Limit the notes display on per page';
$string['deletefailed'] = 'Delete action failed';
$string['nopermissiontodelete'] = 'You do not have permission to delete this note';
$string['previouspage'] = '<< Previous page';
$string['nextpage'] = 'Next page >>';
$string['nothingtodisplay'] = 'Nothing to display';
$string['nocharacterlimit'] = ' ';
\ 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/>.
/**
* The mynotes block helper functions and callbacks
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
defined('MOODLE_INTERNAL') || die();
class block_mynotes_manager {
public $perpage = 5;
private $config = null;
/*
* Constructor.
*/
public function __construct() {
$this->config = get_config('block_mynotes');
$this->perpage = $this->config->mynotesperpage;
}
/**
* Returns matched mynotes
*
* @param int $page
* @return array
*/
public function get_mynotes($options) {
global $DB, $CFG, $USER, $OUTPUT;
$page = (!isset($options->page) || !$options->page) ? 0 : $options->page;
$perpage = $this->perpage;
$params = array();
$start = $page * $perpage;
$ufields = 'u.id';
$where = ' m.userid = :userid';
$params['userid'] = $USER->id;
/* if (isset($options->contextarea) && !empty($options->contextarea)) {
$where .= ' AND m.contextarea = :contextarea';
$params['contextarea'] = $options->contextarea;
}
if (isset($options->courseid) && $options->courseid) {
$where .= ' AND m.courseid = :courseid';
$params['courseid'] = $options->courseid;
} */
if(isset($options->contextid) && $options->contextid){
$where .= ' AND m.contextid = :contextid';
$params['contextid'] = $options->contextid;
}
$sql = "SELECT $ufields,
m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat,
m.timecreated AS timecreated, c.fullname as coursename, m.courseid
FROM {block_mynotes} m
JOIN {user} u ON u.id = m.userid
LEFT JOIN {course} c ON c.id = m.courseid
WHERE $where
ORDER BY m.timecreated DESC";
$strftime = get_string('strftimerecentfull', 'langconfig');
$mynotes = array();
$formatoptions = array('overflowdiv' => true);
$start = (isset($options->limitfrom)) ? $options->limitfrom : $start;
$rs = $DB->get_recordset_sql($sql, $params, $start, $perpage);
foreach ($rs as $u) {
$c = new stdClass();
$c->id = $u->mynoteid;
$c->userid = $u->id;
if ($u->courseid != SITEID) {
$c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename);
} else {
$c->coursename = '';
}
$c->content = $u->ccontent;
$c->contextarea = $u->contextarea;
$c->format = $u->cformat;
$c->timecreated = userdate($u->timecreated, $strftime);
$c->content = format_text($c->content, $c->format, $formatoptions);
$c->delete = true;
$mynotes[] = $c;
}
$rs->close();
return $mynotes;
}
/**
* Returns count of the mynotes in a table where all the given conditions met.
*
* @param object $options
* @return int The count of records
*/
public function count_mynotes($options) {
global $DB, $USER;
$params = array();
// $params ['contextid']= $options->contextid;
// $params= $options->contextid;
$sql='select COUNT(contextarea) from {block_mynotes} where contextid= :contextid';
$params ['contextid']= $options->contextid;
return $DB->count_records_sql($sql,$params);
/* $params['userid'] = $USER->id;
if (isset($options->contextarea) && !empty($options->contextarea)) {
$params['contextarea'] = $options->contextarea;
}
if (isset($options->contextid) && !empty($options->contextid)) {
$params['contextid'] = $options->contextid;
}
return $DB->count_records('block_mynotes',$params); */
}
/*
* Returns paging bar for mynotes
*
* @param object $options must contain properties(contextid, count, page, perpage)
* @return html
*/
public function get_pagination($options) {
global $OUTPUT;
$baseurl = new moodle_url('/blocks/mynotes/mynotes_ajax.php',
array(
'contextid' => $options->contextid)
);
return $OUTPUT->paging_bar($options->count, $options->page, $this->perpage, $baseurl);
}
/*
* Adding new record of mynote.
*
* @return object of single mynote record if insert to DB else false
*/
public function addmynote($context, $contextarea, $course, $content, $format = FORMAT_MOODLE) {
global $CFG, $DB, $USER, $OUTPUT;
$newnote = new stdClass;
$newnote->contextid = $context->id;
$newnote->contextarea = $contextarea;
$newnote->content = $content;
$newnote->courseid = $course->id;
$newnote->format = $format;
$newnote->userid = $USER->id;
$newnote->timecreated = time();
if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) {
$newnote->id = $cmtid;
$newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true));
$newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig'));
$newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname;
if (!empty($newnote->coursename)) {
$newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename);
}
return $newnote;
} else {
return false;
}
}
/*
* Find all available context areas which is used to store and retrieve mynotes.
*
* @return array
*/
public function get_available_contextareas() {
return array(
// 'site' => get_string('site', 'block_mynotes'),
// 'course' => get_string('course', 'block_mynotes'),
// 'mod' => get_string('mod', 'block_mynotes'),
'user' => get_string('user', 'block_mynotes'),
);
}
/*
* Find context area using context level.
*
* @param object $context
* @retrun string
*/
public function get_current_tab($context, $page) {
/* if ($page->url->compare(new moodle_url('/user/view.php'), URL_MATCH_BASE)) {
return 'user';
} else if ($page->url->compare(new moodle_url('/user/profile.php'), URL_MATCH_BASE)) {
return 'user';
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
return 'site';
} else if ($context->contextlevel == CONTEXT_COURSE) {
if ($context->instanceid == SITEID) {
return 'site';
}
return 'course';
} else if ($context->contextlevel == CONTEXT_MODULE) {
return 'mod';
} else if ($context->contextlevel == CONTEXT_USER) {
return 'user';
} else if ($context->contextlevel == CONTEXT_BLOCK) {
$parent = $context->get_parent_context();
if ($parent->contextlevel == CONTEXT_COURSE) {
return 'course';
} else if ($parent->contextlevel == CONTEXT_MODULE) {
return 'mod';
}
} */
return 'user';
}
/**
* Delete a note
*
* @param int $mynoteid
* @return bool
*/
public function delete($mynoteid) {
global $DB, $USER;
if (!$mynote = $DB->get_record('block_mynotes', array('id' => $mynoteid))) {
throw new mynotes_exception('deletefailed', 'block_mynotes');
}
if ($USER->id != $mynote->userid) {
throw new mynotes_exception('nopermissiontodelete', 'block_mynotes');
}
return $DB->delete_records('block_mynotes', array('id' => $mynoteid));
}
}
/**
* Mynotes exception class
*/
class mynotes_exception extends moodle_exception {
}
\ 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/>.
/*
* Handling all ajax request for mynotes API
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
define('AJAX_SCRIPT', true);
define('NO_DEBUG_DISPLAY', true);
require_once('../../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot . '/blocks/mynotes/lib.php');
$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
$contextarea = optional_param('contextarea', 'site', PARAM_ALPHA);
$action = optional_param('action', '', PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
list($context, $course, $cm) = get_context_info_array($contextid);
if ( $contextid == SYSCONTEXTID || $context->contextlevel == CONTEXT_USER) {
$course = get_site();
}
$PAGE->set_url('/blocks/mynotes/mynotes_ajax.php');
require_course_login($course, true, $cm);
$PAGE->set_context($context);
if (!empty($cm)) {
$PAGE->set_cm($cm, $course);
} else if (!empty($course)) {
$PAGE->set_course($course);
}
if (!confirm_sesskey()) {
$error = array('error' => get_string('invalidsesskey', 'error'));
die(json_encode($error));
}
if (!isloggedin()) {
echo json_encode(array('error' => 'require_login'));
die();
}
$config = get_config('block_mynotes');
echo $OUTPUT->header(); //...send headers
// process ajax request
switch ($action) {
case 'add':
$content = optional_param('content', '', PARAM_RAW);
$manager = new block_mynotes_manager();
if ($note = $manager->addmynote($context, $contextarea, $course, $content)) {
$options = new stdClass();
$options->page = $page;
$options->courseid = $course->id;
$options->contextid = $context->id;
$options->context = $context;
$options->contextarea = $contextarea;
unset($options->courseid);
$count = $manager->count_mynotes($options);
echo json_encode(array('notes' => array($note), 'count' => $count));
} else {
echo json_encode(array('error' => 'Unable to add note'));
}
die();
break;
case 'get':
$manager = new block_mynotes_manager();
$options = new stdClass();
$options->page = $page;
$options->contextid = $context->id;
$options->contextarea = $contextarea;
$count = $manager->count_mynotes($options);
$notes = $manager->get_mynotes($options);
echo json_encode(array('notes' => $notes, 'count' => $count));
die();
break;
case 'delete':
$noteid = required_param('noteid', PARAM_INT);
$limitfrom = optional_param('lastnotecounts', 0, PARAM_INT);
$manager = new block_mynotes_manager();
if ($manager->delete($noteid)) {
$options = new stdClass();
$options->page = $page;
$options->contextarea = $contextarea;
$count = $manager->count_mynotes($options);
if ($limitfrom) {
$options->limitfrom = $limitfrom - 1;
}
$notes = $manager->get_mynotes($options);
echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid));
}
die();
break;
}
die();
\ 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/>.
/**
* Settings for the Mynotes block
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$perpageoptions = array();
for ($i = 1; $i < 20; $i++) {
$perpageoptions[$i] = $i;
}
$settings->add(new admin_setting_configselect('block_mynotes/mynotesperpage', get_string('mynotesperpage', 'block_mynotes'),
get_string('mynotesperpage_help', 'block_mynotes'), 5, $perpageoptions));
$settings->add(new admin_setting_configtext('block_mynotes/characterlimit', get_string('characterlimit', 'block_mynotes'),
get_string('characterlimit_help', 'block_mynotes'), 180, PARAM_INT, 3));
$positionoptions = array();
$positionoptions['mynotes-pos-rb'] = get_string('bottomright', 'block_mynotes');
$positionoptions['mynotes-pos-lb'] = get_string('bottomleft', 'block_mynotes');
$positionoptions['mynotes-pos-rt'] = get_string('topright', 'block_mynotes');
$positionoptions['mynotes-pos-lt'] = get_string('topleft', 'block_mynotes');
$settings->add(new admin_setting_configselect('block_mynotes/icondisplayposition', get_string('icondisplayposition', 'block_mynotes'),
get_string('icondisplayposition_help', 'block_mynotes'), 'mynotes-pos-rb', $positionoptions));
}
\ No newline at end of file
#mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; }
div.mdl-align { min-height: 470px; }
.mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; }
.mynotes-pos-inline,
.mynotes-pos-rb,
.mynotes-pos-lb,
.mynotes-pos-rt,
.mynotes-pos-lt { width: 40px; height: 40px; position: fixed; background: #b31b1b; padding: 0; border-radius: 30px; text-align: center; }
.mynotes-pos-rb { bottom: 5px; right: 20px; }
.mynotes-pos-lb { bottom: 5px; left: 20px; }
.mynotes-pos-rt { top: 100px; right: 20px; }
.mynotes-pos-lt { top: 100px; left: 20px; }
.mynotes-pos-inline { position: relative; float: left; }
.mynotes-pos-inline >span.pencil, .mynotes-pos-rb >span.pencil, .mynotes-pos-lb>span.pencil, .mynotes-pos-rt>span.pencil, .mynotes-pos-lt>span.pencil { color: #fff; font-size: 29px; margin: 0; display: inline-block; font-weight: bold; cursor: pointer; line-height: 40px; }
.mynotes_base { display: inline-block; width: 100%; }
.mynotes_base .inputarea { background: #fff4d5; padding: 5px; margin-bottom: 10px; }
.mynotes_base .inputarea p {margin: 0; font-size: 13px; }
.mynotes_base .textarea { border: 1px solid gray; padding: 5px; background: #fff; }
.mynotes_base textArea:focus { border: none; box-shadow: none; }
.mynotes_base textArea {width:100%; max-width: 100%; margin: 0; padding: 0; max-height: 125px; border: none; box-shadow: none; }
.mynotes_base input[type="submit"], .mynotes_base input[type="submit"]:hover { margin: 0; padding: 3px 10px; border: none; background: #63ab36; color: #fff; }
.mynotes_base input[type="submit"][disabled="disabled"]:hover { background: #63ab36; cursor: not-allowed; }
.mynotes_base span.warning { color: #bd3c2f; margin-left: 15px; }
.mynotes_base .responsetext { color: #33b733; line-height: 20px; }
.mynotes_base .tabs-menu { height: 30px; float: left; clear: both; margin-bottom: 1px; }
.mynotes_base .tabs-menu li { padding: 0 10px; margin-right: 1px; height: 30px; line-height: 30px; float: left; list-style: none; background-color: #d84e36; cursor: pointer; }
.mynotes_base .tabs-menu li:first-child { border-radius: 7px 0 0 0; }
.mynotes_base .tabs-menu li:last-child { border-radius: 0 7px 0 0; }
.mynotes_base .tabs-menu li.current { position: relative; background-color: #ffe6a4; border-bottom: 1px solid #fff; z-index: 5; border-bottom: 2px solid #ffe6a4; }
.mynotes_base .tabs-menu li:first-child.current { border-left: 1px solid #d4d4d1; border-top: 1px solid #d4d4d4; }
.mynotes_base .tabs-menu li:last-child.current { border-right: 1px solid #d4d4d1; border-top: 1px solid #d4d4d4; }
.mynotes_base .tabs-menu li .menu-item { text-transform: uppercase; color: #fff; text-decoration: none; }
.mynotes_base .tabs-menu .current .menu-item { color: #000; }
.mynotes_base .tab { border: 1px solid #d4d4d1; clear: both; width: auto; background: #f7f7f4; }
.mynotes_base .tab .tab-content { display: none; }
.mynotes_base .tab .tab-content .notes-info { background: #ffe6a4; padding: 5px; position: relative; }
.mynotes_base .tab .tab-content .notes-info .count { color: #000; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging { position: absolute; right: 0; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging a { margin: 5px; background: #c1621e; padding: 4px 10px; border-radius: 15px; color: #fff; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging .separator { border-left: 1px solid gray; }
.mynotes_base .tab .tab-content ul.mynotes_lists { margin:0; clear: both; }
.mynotes_base .tab .tab-content ul.mynotes_lists li { list-style: none; position: relative; margin: 0 0 5px 0; padding: 5px; list-style: none; background-color: #fff; border-top: 1px solid #e3e4e4; }
.mynotes_base .tab .tab-content ul.mynotes_lists li .content { margin-right: 10px; word-wrap: break-word; }
.mynotes_base .tab .tab-content ul.mynotes_lists li .note-detail { display: inline-block; font-size: 11px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li .time { color: #888; font-style: italic; display: inline-block; margin-left: 5px; font-size: 11px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { position: absolute; right: 0; margin:0 4px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb; }
<?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/>.
/**
* Version details
*
* @package block_mynotes
* @author Gautam Kumar Das<gautam.arg@gmail.com>
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018011200; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2015050500; // Requires this Moodle version
$plugin->component = 'block_mynotes'; // Full name of the plugin (used for diagnostics)
$plugin->release = 'V3.4 r1';
$plugin->maturity = MATURITY_STABLE;
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!