4153cb06 by logesh

dev: final changes in notes

1 parent 89341b62
......@@ -24,11 +24,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var mynotes = {
getMynotesValidatedUrl: function(baseurl) {
var a = document.createElement('a');
a.href = baseurl;
return (a.search.length > 0) ? baseurl : baseurl + '?';
},
getWarnings: function(status) {
if (status == false) {
$('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(CONFIG.maxallowedcharacters_warning);
} else {
......@@ -72,6 +75,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
}
},
request: function(args) {
var params = {};
var scope = this;
......@@ -136,6 +140,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
},
saveMynotes: function(e) {
var result='';
e.preventDefault();
......@@ -146,6 +151,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var url= $(location).attr('href');
if (url.match(/resume/)) {
var n = url.indexOf('?resume');
url = url.substring(0, n != -1 ? n : url.length);
}
if(url.includes('/mod/page/view.php')){
//notes player timer starts
var iframe = document.querySelector('iframe');
......@@ -155,23 +168,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
player.getCurrentTime().then(function(seconds) {
var str = "</br>You have taken notes at ";
str +=seconds;
str +=" in this video."
result = str.fontcolor("green");
var timenotes=seconds;
var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
return false;
}
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
action: 'add',
contextarea: scope.currenttabindex,
notestime:result,
notestime:timenotes,
urllink:url,
};
......@@ -185,6 +195,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.request({
params: arg,
callback: function(id, ret, args) {
if (!ret.notes) {
return false;
}
......@@ -215,18 +226,18 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
}
else{
var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
return false;
}
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
action: 'add',
contextarea: scope.currenttabindex,
notestime:result,
urllink:url,
};
......@@ -286,6 +297,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
$(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count);
},
getMynotes: function(page = 0) {
var scope = this;
page = parseInt(page);
......@@ -313,7 +325,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
});
},
updateMynotesInfo: function(mynotescount, page) {
console.log(mynotescount);
page = parseInt(page);
mynotescount = parseInt(mynotescount);
var scope = this;
......@@ -355,21 +367,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
noteinfo.find('.mynotes-paging').html(paging);
},
renderMynotes: function(notes) {
if (notes.length < 1) {
return false;
}
var lists = '';
var x = '';
for (x in notes) {
$('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove();
var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>';
var notedetail = '';
if (notes[x].coursename != '') {
notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>';
}
var userdate = '<div class="time">' + notes[x].timecreated + '</div>';
var mynotestime='';
if (notes[x].notestime != ''){
mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>';
}
var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>';
lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + '</li>';
lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>';
}
return lists;
},
......@@ -402,6 +426,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.updateMynotesInfo(mynotescount, page);
},
registerActions: function() {
var scope = this;
$('body').delegate('#addmynote_cancel', 'click', function() {
panel.hide()
......
......@@ -24,11 +24,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var mynotes = {
getMynotesValidatedUrl: function(baseurl) {
var a = document.createElement('a');
a.href = baseurl;
return (a.search.length > 0) ? baseurl : baseurl + '?';
},
getWarnings: function(status) {
if (status == false) {
$('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(CONFIG.maxallowedcharacters_warning);
} else {
......@@ -72,6 +75,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
}
},
request: function(args) {
var params = {};
var scope = this;
......@@ -136,6 +140,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
},
saveMynotes: function(e) {
var result='';
e.preventDefault();
......@@ -146,6 +151,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var url= $(location).attr('href');
if (url.match(/resume/)) {
var n = url.indexOf('?resume');
url = url.substring(0, n != -1 ? n : url.length);
}
if(url.includes('/mod/page/view.php')){
//notes player timer starts
var iframe = document.querySelector('iframe');
......@@ -155,23 +168,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
player.getCurrentTime().then(function(seconds) {
var str = "</br>You have taken notes at ";
str +=seconds;
str +=" in this video."
result = str.fontcolor("green");
var timenotes=seconds;
var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
return false;
}
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
action: 'add',
contextarea: scope.currenttabindex,
notestime:result,
notestime:timenotes,
urllink:url,
};
......@@ -185,6 +195,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.request({
params: arg,
callback: function(id, ret, args) {
if (!ret.notes) {
return false;
}
......@@ -215,18 +226,18 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
}
else{
var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
return false;
}
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
action: 'add',
contextarea: scope.currenttabindex,
notestime:result,
urllink:url,
};
......@@ -286,6 +297,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
$(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count);
},
getMynotes: function(page = 0) {
var scope = this;
page = parseInt(page);
......@@ -307,7 +319,6 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
this.request({
params: arg,
callback: function(id, ret, args) {
scope.addToList(ret);
scope.displayMynotes();
}
......@@ -356,21 +367,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
noteinfo.find('.mynotes-paging').html(paging);
},
renderMynotes: function(notes) {
if (notes.length < 1) {
return false;
}
var lists = '';
var x = '';
for (x in notes) {
$('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove();
var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>';
var notedetail = '';
if (notes[x].coursename != '') {
notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>';
}
var userdate = '<div class="time">' + notes[x].timecreated + '</div>';
var mynotestime='';
if (notes[x].notestime != ''){
mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>';
}
var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>';
lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + '</li>';
lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>';
}
return lists;
},
......@@ -403,6 +426,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.updateMynotesInfo(mynotescount, page);
},
registerActions: function() {
var scope = this;
$('body').delegate('#addmynote_cancel', 'click', function() {
panel.hide()
......
......@@ -14,6 +14,8 @@
<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"/>
<FIELD NAME="notestime" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="notesurl" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
<?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/>.
/**
* @package qharvest
* @author Tekstac Development Team <teknoturf.com>
*/
//upgrade.php file for hte harvest question
defined( 'MOODLE_INTERNAL' ) || die();
function xmldb_block_mynotes_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
//Upgrade to add an extra column to local_qharvest_qns_count table
if( $oldversion < 2018011201 ){
$table = new xmldb_table('block_mynotes');
if ( $dbman->table_exists($table) ) {
$dbman->drop_table($table);
}
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('contextid',XMLDB_TYPE_INTEGER,'10', null, null, null,null);
$table->add_field('contextarea', XMLDB_TYPE_CHAR,'255', null, null, null,null);
$table->add_field('content', XMLDB_TYPE_TEXT, null, null, null,null);
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('format', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('notestime', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('notesurl', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$dbman->create_table($table);
}
return true;
}
\ No newline at end of file
......@@ -70,7 +70,7 @@ class block_mynotes_manager {
}
$sql = "SELECT $ufields,
m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat,
m.timecreated AS timecreated,m.notestime AS notestime, c.fullname as coursename, m.courseid
m.timecreated AS timecreated,m.notestime AS notestime,m.notesurl AS notesurl, 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
......@@ -86,7 +86,8 @@ class block_mynotes_manager {
$c->id = $u->mynoteid;
$c->userid = $u->id;
if ($u->courseid != SITEID) {
$c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename);
// $c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename);
$c->coursename = html_writer::link($u->notesurl, $u->coursename);
} else {
$c->coursename = '';
}
......@@ -100,6 +101,12 @@ class block_mynotes_manager {
} else {
$c->notestime = '';
}
if (!empty($u->notesurl)) {
$c->notesurl = $u->notesurl;
} else {
$c->notesurl = '';
}
// $c->notestime = $u->notestime;
$c->content = format_text($c->content, $c->format, $formatoptions);
$c->delete = true;
......@@ -189,9 +196,10 @@ class block_mynotes_manager {
*
* @return object of single mynote record if insert to DB else false
*/
public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) {
public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl, $format = FORMAT_MOODLE) {
global $CFG, $DB, $USER, $OUTPUT;
// $content=$content.$timer;
$newnote = new stdClass;
$newnote->contextid = $context->id;
$newnote->contextarea = $contextarea;
......@@ -201,15 +209,25 @@ class block_mynotes_manager {
$newnote->userid = $USER->id;
$newnote->timecreated = time();
$newnote->notestime=$timer;
if (!empty($timer)){
$newnote->notesurl=$activityUrl.'?resume='.$newnote->notestime;
}else{
$newnote->notesurl=$activityUrl.'?resume=0';
}
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;
$newnote->notestime = ($newnote->notestime) ? '' : $newnote->notestime;
$newnote->notestime = $newnote->notestime;
$newnote->notesurl = $newnote->notesurl;
if (!empty($newnote->coursename)) {
$newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename);
$newnote->coursename = html_writer::link($newnote->notesurl, $newnote->coursename);
// $newnote->coursename = html_writer::link($newnote->notesurl.'?notestime='.$timer, $newnote->coursename);
// $newnote->coursename=$newnote->notesurl.'?notestime='.$timer,$newnote->coursename;
}
return $newnote;
} else {
......
......@@ -63,13 +63,16 @@ $config = get_config('block_mynotes');
echo $OUTPUT->header(); //...send headers
// process ajax request
switch ($action) {
case 'add':
$content = optional_param('content', '', PARAM_RAW);
$timer = optional_param('notestime', '', PARAM_TEXT);
$activityUrl = optional_param('urllink', '', PARAM_TEXT);
$manager = new block_mynotes_manager();
if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer)) {
if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl)) {
$options = new stdClass();
$options->page = $page;
$options->courseid = $course->id;
......
......@@ -23,7 +23,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018011200; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018011201; // 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';
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!