06ce11f1 by logesh

dev:changes in notes

1 parent 892007c9
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
<?php
define('AJAX_SCRIPT', true);
define('NO_DEBUG_DISPLAY', true);
require_once('../../config.php');
require_once($CFG->dirroot . '/blocks/mynotes/lib.php');
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
$action = optional_param('action', '', PARAM_ALPHA);
$PAGE->requires->js_call_amd('block_mynotes/script', 'init');
$PAGE->set_url('/blocks/mynotes/allnotes_ajax.php');
switch ($action){
case 'edit':
$noteid = required_param('noteid', PARAM_INT);
$notes = required_param('newnotes', PARAM_TEXT);
$manager = new block_mynotes_manager();
if ($manager->edit($noteid,$notes)) {
echo json_encode(array('result' => "successfully updated"));
}else{
echo json_encode(array('error' => 'Unable to update edited note'));
}
die();
break;
case 'delete':
$noteid = required_param('noteid', PARAM_INT);
$manager = new block_mynotes_manager();
// $noteid=547;
if ($manager->delete($noteid)) {
echo json_encode(array('noteid' => $noteid, 'result' => "deleted"));
}
else {
echo json_encode(array('error' => 'Unable to delete note'));
}
die();
break;
}
die();
\ No newline at end of file
......@@ -2,7 +2,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var CONFIG;
var NODES = {
DELETE_ICON: '<span class="delete">&#x274C;</span>',
EDIT_ICON: '<i class="far fa-edit" id="mynote-edit"></i>',
EDIT_ICON: '<span class="far fa-edit" id="mynote-edit"></span>',
SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>',
};
var SELECTORS = {
......@@ -31,6 +31,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var a = document.createElement('a');
a.href = baseurl;
return (a.search.length > 0) ? baseurl : baseurl + '?';
},
getWarnings: function(status) {
......@@ -175,10 +176,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var timenotes=seconds;
var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
// console.log(ta);
if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
return false;
}
var activityname=$(".breadcrumb li:last").text()
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
......@@ -186,6 +188,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
contextarea: scope.currenttabindex,
notestime:timenotes,
urllink:url,
activity:activityname,
};
......@@ -242,7 +245,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
url='';
}
var activityname=$(".breadcrumb li:last").text()
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
......@@ -250,6 +253,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
contextarea: scope.currenttabindex,
notestime:result,
urllink:url,
activity:activityname,
};
......@@ -372,7 +376,10 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab);
if (mynotescount > 0) {
noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')');
var rootPath = M.cfg.wwwroot;
// console.log(CONFIG.contextid);
// $.ajax({url: rootPath + "/blocks/Contest_scroller.php", success: function(result){
noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')'+'<a href="'+rootPath+'/blocks/mynotes/course_level_notes.php?cid='+CONFIG.contextid+'" class="float-md-right" style="text-decoration: none;">Download notes</a>');
} else {
noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes'));
}
......@@ -387,27 +394,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
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 deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id +'" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>';
var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>';
var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_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>';
notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + notes[x].notestime +'</div>';
// mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>';
}
else{
notedetail = '<div class="note-detail">' + notes[x].coursename + '</div>';
}
}
var note_html = '<div class="content">' + deletelink + editlink + updatelink + notes[x].content + '</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 +editlink+ notes[x].content + '</div>';
// var note_html = '<div class="content">' + deletelink + editlink + updatelink+ notes[x].content + '</div>';
// var note_html = '<div class="content">' + editlink + notes[x].content + '</div>';
lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>';
lists += '<li class="list-of-notes" id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail +'</li>';
lists+=''
}
return lists;
},
......@@ -420,14 +442,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var scope = this;
var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage'));
var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count'));
var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list');
var notescount = el.find('li').length;
var lastpage = Math.ceil(notescount / CONFIG.perpage);
if (notescount > 0 && lastpage <= page) {
page = lastpage - 1;
}
// var link='<a href="#" class="downloadnote">'+download+'</a>';
//parsing required for backward flow
var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage));
var lowerlimit = page * CONFIG.perpage;
......@@ -442,6 +464,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
registerActions: function() {
var scope = this;
$('body').delegate('#addmynote_cancel', 'click', function() {
panel.hide()
});
......@@ -474,9 +498,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.toggle_textarea(e);
});
$('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) {
scope.getWarnings(scope.checkInputText());
});
$('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) {
e.preventDefault();
var regex = new RegExp(/[\?&]page=(\d+)/);
......@@ -490,6 +514,61 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.getMynotes(page);
});
//
$(document).ready(function () {
var editid;
var deleteid;
$(document).on('mouseenter', '.list-of-notes', function () {
var id=this.id;
var replacedid = id.replace('mynote','');
editid="#mynote-edit"+replacedid;
deleteid="#mynote-delete"+replacedid;
$(editid+' #mynote-edit').show(500);
$(deleteid).show(500);
}).on('mouseleave', '.list-of-notes', function () {
$(deleteid).hide();
$(editid+' #mynote-edit').hide();
});
//function for notes url redirection
$(document).on('click', '.notes_button_redirect', function (e) {
var urlid=this.id;
var notestime=this.name;
var noteurl = urlid.split('&');
var noteurlone=noteurl[0];
var noteurltwo=noteurl[1];
var activityurl= $(location).attr('href');
var arr = activityurl.split('&');
var activityurlone=arr[0];
var activityurltwo=arr[1];
if(noteurlone == activityurlone){
if(notestime){
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
player.setCurrentTime(notestime).then(function(seconds) {
player.play()
})
}
}else{
location.replace(urlid);
}
});
});
$('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) {
e.preventDefault();
var nid = $(this).attr('id');
......@@ -523,9 +602,13 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
$('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option');
var vals=document.getElementById('notes_edit_option').contentEditable = true;
document.getElementById('notes_edit_option').focus();
var deleteid=mytestid.replace('edit','delete')
$('#'+editid+' #mynote-edit').hide();
$('#'+deleteid).hide();
$( "#"+editid+" #mynote-update" ).click(function() {
$('#notes_edit_option').keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $("#notes_edit_option").text();
if (nid != '' || nid != 'undefined') {
......@@ -539,6 +622,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
lastnotecounts: notescount,
newnotes:newstring,
};
$('#'+editid+' #mynote-edit').show();
$('#'+deleteid).show();
var vals=document.getElementById('notes_edit_option').contentEditable = false;
document.getElementById("notes_edit_option").removeAttribute("id");
scope.request({
......@@ -547,11 +633,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
args.scope.addToList(ret);
// $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove();
args.scope.displayMynotes();
}
});
}
}
});
// $( "#"+editid+" #mynote-update" ).click(function() {
/* var newstring= $("#notes_edit_option").text();
if (nid != '' || nid != 'undefined') {
var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length;
var id = nid.replace('mynote-edit-' + CONFIG.instanceid + '-', '');
var arg = {
contextid: CONFIG.contextid,
action: 'edit',
noteid: id,
lastnotecounts: notescount,
newnotes:newstring,
};
var vals=document.getElementById('notes_edit_option').contentEditable = false;
document.getElementById("notes_edit_option").removeAttribute("id");
scope.request({
params: arg,
callback: function(id, ret, args) {
args.scope.addToList(ret);
// $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove();
args.scope.displayMynotes();
}
});
}*/
// });
......@@ -590,6 +707,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
key: 'placeholdercontent',
component: 'block_mynotes'
}]).done(function(s) {
var el = $('<div id="tet"></div>').append($('<div id="' + CSS.MYNOTES_BASE + '" class="' + CSS.MYNOTES_BASE + '"></div>').append('<div class="inputarea"><div id="addmynote-label-' + CONFIG.instanceid + '">' + s[1] + ' ' + '' + '</div>' + '<div class="textarea"><textarea id="id_mynotecontent-' + CONFIG.instanceid + '" name="mynotecontent" rows="3">' + s[5] + '</textarea></div>' + '<p class="mdl-align"><input type="submit" id="addmynote_submit"/></p>' + '</div>').append($('<ul class="tabs-menu"></ul>')).append($('<div class="tab"></div>')));
el.find('#addmynote_submit').attr('value', s[2]);
el.find('#addmynote_cancel').attr('value', s[3]);
......@@ -608,11 +726,12 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
el.find('.tab').append($(tabcontents));
Y.use('moodle-core-notification-dialogue', function() {
panel = new M.core.dialogue({
width: '300px',
draggable: true,
modal: true,
closeButton: true,
headerContent: M.util.get_string('mynotes', 'block_mynotes'),
responsive: true,
// responsive: true,
});
panel.set('bodyContent', el.html());
if (initnotes === null) {
......@@ -638,18 +757,25 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
this.currenttabindex = args.currenttabindex;
this.api = this.getMynotesValidatedUrl(M.cfg.wwwroot + '/blocks/mynotes/mynotes_ajax.php');
var strtitle = M.util.get_string('showmynotes', 'block_mynotes');
var url= $(location).attr('href');
if (!CONFIG.editing) {
if ( url.includes('/my/') ){
}else{
var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>');
handler.addClass(CONFIG.editingicon_pos);
$('body').append(handler);
handler.html('<span class="pencil" id="mynotepencil">&#x270D;</span>');
}
} else {
if ( url.includes('/my/') ){
}else{
var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>');
handler.addClass(CONFIG.editingicon_pos);
handler.html('<span class="pencil">&#x270D;</span>');
$('.inline-' + CSS.MYNOTES_OPENER).html(handler);
$('.inline-' + CSS.MYNOTES_OPENER).append('<div class="mynotes-pos-inline-text ' + CSS.MYNOTES_OPENER + '">' + strtitle + '</div>');
}
}
var body = $('body');
body.delegate(SELECTORS.MYNOTES_OPENER, 'click', this.displayDialogue);
}
......
define(["jquery"],function(e){return{init:function(){var n=e(location).attr("href");e("document").ready(function(){if(n.includes("/mod/page/view.php")){var e=document.querySelector("iframe");new Vimeo.Player(e)}})}}});
\ No newline at end of file
define(['jquery','core/config',], function($,config) {
return {
init: function() {
var CONFIG;
$('.notes_overview').hide();
var url= $(location).attr('href');
if(url.includes('/mynotes/view.php')){
$('.page-header').css('margin-top','2em !important');
$('.page-title').css('margin-top','inherit !important');
}
$(document).ready(function(){
$(".notes_section").click(function(){
var eventId=this.id;
$('#notes_table_id'+eventId).toggle();
});
$(".notes_section").click(function(){
var eventId=this.id;
var classname=$( "div#"+eventId ).children()[0].className;
if (classname === 'notes_course fa fa-chevron-circle-right'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' );
}
else if (classname === 'notes_course fa fa-chevron-circle-down'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' );
}
});
$("#excel_download").click(function(){
var rootPath = M.cfg.wwwroot
var arg = {
action: 'download',
};
$.ajax({
url: rootPath+"/blocks/mynotes/notes_excel.php",
type: "POST",
data: arg,
success: function(response){
//do action
},
error: function(){
// do action
}
});
});
$("a.delete_note").click(function(){
var deleteId=this.id;
var arg = {
action: 'delete',
noteid: deleteId,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
var deleteid=data.noteid;
$("#notes"+deleteid).remove();
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
}
});
});
$("a.edit_note").click(function(){
var editId=this.id;
// notes_content+editId;
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
document.getElementById('notes_content'+editId).focus();
// console.log('notes_content'+editId);
$('#notes_content'+editId).keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $('#notes_content'+editId).text();
// console.log(newstring);
var vals=document.getElementById('notes_content'+editId).contentEditable = false;
var arg = {
action: 'edit',
noteid: editId,
newnotes:newstring,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
}
});
}
});
});
});
}
};
});
......
......@@ -2,7 +2,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var CONFIG;
var NODES = {
DELETE_ICON: '<span class="delete">&#x274C;</span>',
EDIT_ICON: '<i class="far fa-edit" id="mynote-edit"></i>',
EDIT_ICON: '<span class="far fa-edit" id="mynote-edit"></span>',
SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>',
};
var SELECTORS = {
......@@ -31,6 +31,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var a = document.createElement('a');
a.href = baseurl;
return (a.search.length > 0) ? baseurl : baseurl + '?';
},
getWarnings: function(status) {
......@@ -175,10 +176,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var timenotes=seconds;
var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
// console.log(ta);
if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
return false;
}
var activityname=$(".breadcrumb li:last").text()
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
......@@ -186,6 +188,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
contextarea: scope.currenttabindex,
notestime:timenotes,
urllink:url,
activity:activityname,
};
......@@ -242,7 +245,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
url='';
}
var activityname=$(".breadcrumb li:last").text()
var arg = {
contextid: CONFIG.contextid,
content: ta.val(),
......@@ -250,6 +253,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
contextarea: scope.currenttabindex,
notestime:result,
urllink:url,
activity:activityname,
};
......@@ -372,7 +376,10 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab);
if (mynotescount > 0) {
noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')');
var rootPath = M.cfg.wwwroot;
// console.log(CONFIG.contextid);
// $.ajax({url: rootPath + "/blocks/Contest_scroller.php", success: function(result){
noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')'+'<a href="'+rootPath+'/blocks/mynotes/course_level_notes.php?cid='+CONFIG.contextid+'" class="float-md-right" style="text-decoration: none;">Download notes</a>');
} else {
noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes'));
}
......@@ -387,27 +394,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
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 deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id +'" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>';
var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>';
var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_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>';
notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + notes[x].notestime +'</div>';
// mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>';
}
else{
notedetail = '<div class="note-detail">' + notes[x].coursename + '</div>';
}
}
var note_html = '<div class="content">' + deletelink + editlink + updatelink + notes[x].content + '</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 +editlink+ notes[x].content + '</div>';
// var note_html = '<div class="content">' + deletelink + editlink + updatelink+ notes[x].content + '</div>';
// var note_html = '<div class="content">' + editlink + notes[x].content + '</div>';
lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>';
lists += '<li class="list-of-notes" id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail +'</li>';
lists+=''
}
return lists;
},
......@@ -420,14 +442,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
var scope = this;
var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage'));
var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count'));
var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list');
var notescount = el.find('li').length;
var lastpage = Math.ceil(notescount / CONFIG.perpage);
if (notescount > 0 && lastpage <= page) {
page = lastpage - 1;
}
// var link='<a href="#" class="downloadnote">'+download+'</a>';
//parsing required for backward flow
var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage));
var lowerlimit = page * CONFIG.perpage;
......@@ -442,6 +464,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
registerActions: function() {
var scope = this;
$('body').delegate('#addmynote_cancel', 'click', function() {
panel.hide()
});
......@@ -474,9 +498,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.toggle_textarea(e);
});
$('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) {
scope.getWarnings(scope.checkInputText());
});
$('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) {
e.preventDefault();
var regex = new RegExp(/[\?&]page=(\d+)/);
......@@ -490,6 +514,61 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
scope.getMynotes(page);
});
//
$(document).ready(function () {
var editid;
var deleteid;
$(document).on('mouseenter', '.list-of-notes', function () {
var id=this.id;
var replacedid = id.replace('mynote','');
editid="#mynote-edit"+replacedid;
deleteid="#mynote-delete"+replacedid;
$(editid+' #mynote-edit').show(500);
$(deleteid).show(500);
}).on('mouseleave', '.list-of-notes', function () {
$(deleteid).hide();
$(editid+' #mynote-edit').hide();
});
//function for notes url redirection
$(document).on('click', '.notes_button_redirect', function (e) {
var urlid=this.id;
var notestime=this.name;
var noteurl = urlid.split('&');
var noteurlone=noteurl[0];
var noteurltwo=noteurl[1];
var activityurl= $(location).attr('href');
var arr = activityurl.split('&');
var activityurlone=arr[0];
var activityurltwo=arr[1];
if(noteurlone == activityurlone){
if(notestime){
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
player.setCurrentTime(notestime).then(function(seconds) {
player.play()
})
}
}else{
location.replace(urlid);
}
});
});
$('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) {
e.preventDefault();
var nid = $(this).attr('id');
......@@ -523,9 +602,13 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
$('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option');
var vals=document.getElementById('notes_edit_option').contentEditable = true;
document.getElementById('notes_edit_option').focus();
var deleteid=mytestid.replace('edit','delete')
$('#'+editid+' #mynote-edit').hide();
$('#'+deleteid).hide();
$( "#"+editid+" #mynote-update" ).click(function() {
$('#notes_edit_option').keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $("#notes_edit_option").text();
if (nid != '' || nid != 'undefined') {
......@@ -539,6 +622,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
lastnotecounts: notescount,
newnotes:newstring,
};
$('#'+editid+' #mynote-edit').show();
$('#'+deleteid).show();
var vals=document.getElementById('notes_edit_option').contentEditable = false;
document.getElementById("notes_edit_option").removeAttribute("id");
scope.request({
......@@ -547,11 +633,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
args.scope.addToList(ret);
// $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove();
args.scope.displayMynotes();
}
});
}
}
});
// $( "#"+editid+" #mynote-update" ).click(function() {
/* var newstring= $("#notes_edit_option").text();
if (nid != '' || nid != 'undefined') {
var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length;
var id = nid.replace('mynote-edit-' + CONFIG.instanceid + '-', '');
var arg = {
contextid: CONFIG.contextid,
action: 'edit',
noteid: id,
lastnotecounts: notescount,
newnotes:newstring,
};
var vals=document.getElementById('notes_edit_option').contentEditable = false;
document.getElementById("notes_edit_option").removeAttribute("id");
scope.request({
params: arg,
callback: function(id, ret, args) {
args.scope.addToList(ret);
// $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove();
args.scope.displayMynotes();
}
});
}*/
// });
......@@ -590,6 +707,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
key: 'placeholdercontent',
component: 'block_mynotes'
}]).done(function(s) {
var el = $('<div id="tet"></div>').append($('<div id="' + CSS.MYNOTES_BASE + '" class="' + CSS.MYNOTES_BASE + '"></div>').append('<div class="inputarea"><div id="addmynote-label-' + CONFIG.instanceid + '">' + s[1] + ' ' + '' + '</div>' + '<div class="textarea"><textarea id="id_mynotecontent-' + CONFIG.instanceid + '" name="mynotecontent" rows="3">' + s[5] + '</textarea></div>' + '<p class="mdl-align"><input type="submit" id="addmynote_submit"/></p>' + '</div>').append($('<ul class="tabs-menu"></ul>')).append($('<div class="tab"></div>')));
el.find('#addmynote_submit').attr('value', s[2]);
el.find('#addmynote_cancel').attr('value', s[3]);
......@@ -608,11 +726,12 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
el.find('.tab').append($(tabcontents));
Y.use('moodle-core-notification-dialogue', function() {
panel = new M.core.dialogue({
width: '300px',
draggable: true,
modal: true,
closeButton: true,
headerContent: M.util.get_string('mynotes', 'block_mynotes'),
responsive: true,
// responsive: true,
});
panel.set('bodyContent', el.html());
if (initnotes === null) {
......@@ -638,18 +757,25 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
this.currenttabindex = args.currenttabindex;
this.api = this.getMynotesValidatedUrl(M.cfg.wwwroot + '/blocks/mynotes/mynotes_ajax.php');
var strtitle = M.util.get_string('showmynotes', 'block_mynotes');
var url= $(location).attr('href');
if (!CONFIG.editing) {
if ( url.includes('/my/') ){
}else{
var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>');
handler.addClass(CONFIG.editingicon_pos);
$('body').append(handler);
handler.html('<span class="pencil" id="mynotepencil">&#x270D;</span>');
}
} else {
if ( url.includes('/my/') ){
}else{
var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>');
handler.addClass(CONFIG.editingicon_pos);
handler.html('<span class="pencil">&#x270D;</span>');
$('.inline-' + CSS.MYNOTES_OPENER).html(handler);
$('.inline-' + CSS.MYNOTES_OPENER).append('<div class="mynotes-pos-inline-text ' + CSS.MYNOTES_OPENER + '">' + strtitle + '</div>');
}
}
var body = $('body');
body.delegate(SELECTORS.MYNOTES_OPENER, 'click', this.displayDialogue);
}
......
define(['jquery'], function($) {
define(['jquery','core/config',], function($,config) {
return {
init: function() {
// tab-mynotes_user
// tab-mynotes_user mynotepencil
var CONFIG;
$('.notes_overview').hide();
var url= $(location).attr('href');
if(url.includes('/mynotes/view.php')){
$('.page-header').css('margin-top','2em !important');
$('.page-title').css('margin-top','inherit !important');
}
$(document).ready(function(){
$(".notes_section").click(function(){
var eventId=this.id;
$('#notes_table_id'+eventId).toggle();
});
$(".notes_section").click(function(){
var eventId=this.id;
var classname=$( "div#"+eventId ).children()[0].className;
if (classname === 'notes_course fa fa-chevron-circle-right'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' );
}
else if (classname === 'notes_course fa fa-chevron-circle-down'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' );
}
});
$("#excel_download").click(function(){
var rootPath = M.cfg.wwwroot
var arg = {
action: 'download',
};
$.ajax({
url: rootPath+"/blocks/mynotes/notes_excel.php",
type: "POST",
data: arg,
success: function(response){
//do action
},
error: function(){
// do action
}
});
});
$("a.delete_note").click(function(){
var deleteId=this.id;
var arg = {
action: 'delete',
noteid: deleteId,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
var deleteid=data.noteid;
$("#notes"+deleteid).remove();
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
}
});
});
$("a.edit_note").click(function(){
var editId=this.id;
// notes_content+editId;
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
document.getElementById('notes_content'+editId).focus();
// console.log('notes_content'+editId);
$('#notes_content'+editId).keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $('#notes_content'+editId).text();
// console.log(newstring);
var vals=document.getElementById('notes_content'+editId).contentEditable = false;
var arg = {
action: 'edit',
noteid: editId,
newnotes:newstring,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
}
});
}
});
});
console.log('init function got invoked ');
$('#mynotepencil').click(function(){
console.log('init function got invoked ');
});
// document.getElementById("panel").style.display = "none"; Nothing to display
// $("#tab-mynotes_user").removeAttr("style").hide();
}
};
});
......
<?php
require_once (dirname ( __FILE__ ) . '/../../config.php');
require_once(dirname( __FILE__ ) .'/../../lib/phpexcel/PHPExcel.php');
global $OUTPUT, $title;
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
function download_excel(){
global $DB, $CFG,$USER ,$PAGE;
$contextid;
if (isset($_GET['cid'])) {
$contextid=$_GET['cid'];
}
$parameter;
if ($contextid){
$parameter = array ($USER->id,$contextid);
}else{
$parameter = array ($USER->id);
}
$sql="select id,courseid from {block_mynotes} where userid=? and contextid=?";
$courseids = $DB->get_records_sql ( $sql, $parameter );
$courseid;
foreach ( $courseids as $value){
$courseid=$value->courseid;
}
$param=array($USER->id,$courseid);
$sql="select * from {block_mynotes} where userid=? and courseid=?";
$allNotes = $DB->get_records_sql ( $sql, $param );
$fullNotes = array ();
$i=0;
foreach ($allNotes as $notes ) {
$courseid=$notes->courseid;
$parameter = array ($courseid);
$sql="select fullname from {course} where id=?";
$coursename = $DB->get_record_sql ( $sql, $parameter );
$fullNotes [$i]['Sl.no']=$i+1;
$fullNotes [$i]['Course']=$coursename->fullname;
if($notes->activityname){
$fullNotes [$i]['activityname']=$notes->activityname;
}
$fullNotes [$i]['Content']=$notes->content;
$time=date('d M Y H:i A (T)', $notes->timecreated);
$fullNotes [$i]['Timecreated']=$time;
$fullNotes [$i]['Videotime']=$notes->notestime;
$fullNotes [$i]['Notesurl']=$notes->notesurl;
$i=$i+1;
}
if (!empty($fullNotes)){
$name = "Student_notes";
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Notes');
$default_border = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'9999ff')
);
$style_header = array(
'borders' => array(
'bottom' => $default_border,
'left' => $default_border,
'top' => $default_border,
'right' => $default_border,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'E1E0F7'),
),
'font' => array(
'bold' => true,
)
);
$default_border1 = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'ff9999')
);
$style_header1 = array(
'borders' => array(
'bottom' => $default_border1,
'left' => $default_border1,
'top' => $default_border1,
'right' => $default_border1,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'ff9999'),
),
'font' => array(
'bold' => true,
)
);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50);
$objPHPExcel->getActiveSheet()->getCell("A1")->setValue("SL.No");
$objPHPExcel->getActiveSheet()->getCell("A1")->getStyle('A1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("B1")->setValue("Course");
$objPHPExcel->getActiveSheet()->getCell("B1")->getStyle('B1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("C1")->setValue("Activity ");
$objPHPExcel->getActiveSheet()->getCell("C1")->getStyle('C1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("D1")->setValue("Note");
$objPHPExcel->getActiveSheet()->getCell("D1")->getStyle('D1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("E1")->setValue("Time Created");
$objPHPExcel->getActiveSheet()->getCell("E1")->getStyle('E1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("F1")->setValue("Time in clip");
$objPHPExcel->getActiveSheet()->getCell("F1")->getStyle('F1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("G1")->setValue("URL");
$objPHPExcel->getActiveSheet()->getCell("G1")->getStyle('G1')->applyFromArray($style_header);
for($i=1;$i<=count($fullNotes)+1;$i++){
$objPHPExcel->getActiveSheet()->getCell('A'.($i+1))->setValue($i);
$objPHPExcel->getActiveSheet()->getCell('B'.($i+1))->setValue($fullNotes[$i-1]['Course']);
$objPHPExcel->getActiveSheet()->getCell('C'.($i+1))->setValue($fullNotes[$i-1]['activityname']);
$objPHPExcel->getActiveSheet()->getCell('D'.($i+1))->setValue($fullNotes[$i-1]['Content']);
$objPHPExcel->getActiveSheet()->getCell('E'.($i+1))->setValue($fullNotes[$i-1]['Timecreated']);
$objPHPExcel->getActiveSheet()->getCell('F'.($i+1))->setValue($fullNotes[$i-1]['Videotime']);
$objPHPExcel->getActiveSheet()->getCell('G'.($i+1))->setValue($fullNotes[$i-1]['Notesurl']);
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
header("Content-Disposition: attachment; filename=$name.xlsx");
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$objWriter->save('php://output');
exit();
}
}
download_excel();
......@@ -11,6 +11,7 @@
<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="activityname" TYPE="text" 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"/>
......
......@@ -31,7 +31,7 @@ function xmldb_block_mynotes_upgrade($oldversion) {
$dbman = $DB->get_manager();
//Upgrade to add an extra column to local_qharvest_qns_count table
if( $oldversion < 2018011201 ){
if( $oldversion < 2018011203 ){
$table = new xmldb_table('block_mynotes');
......@@ -44,6 +44,7 @@ function xmldb_block_mynotes_upgrade($oldversion) {
$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('activityname', XMLDB_TYPE_TEXT, 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);
......
......@@ -63,9 +63,9 @@ class block_mynotes_manager {
$where .= ' AND m.courseid = :courseid';
$params['courseid'] = $options->courseid;
} */
if(isset($options->contextid) && $options->contextid){
$where .= ' AND m.contextid = :contextid';
$params['contextid'] = $options->contextid;
if(isset($options->courseid) && $options->courseid){
$where .= ' AND m.courseid = :courseid';
$params['courseid'] = $options->courseid;
}
$sql = "SELECT $ufields,
......@@ -86,10 +86,20 @@ 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);
if (!empty($u->notestime)){
$c->coursename='<a href="#" class="notes_button_redirect" name="'.$u->notestime.'" id="'.course_get_url(($u->courseid), $u->coursename).'">'.$u->coursename.'</a>';
}else{
$c->coursename='<a href="#" class="notes_button_redirect" id="'.course_get_url(($u->courseid), $u->coursename).'">'.$u->coursename.'</a>';
}
if (! empty ( $u->notesurl )) {
$c->coursename = html_writer::link ( $u->notesurl, $u->coursename );
// $c->coursename = html_writer::link ( $u->notesurl, $u->coursename );
if (!empty($u->notestime)){
$c->coursename='<a href="#" class="notes_button_redirect" name="'.$u->notestime.'" id="'.$u->notesurl.'">'.$u->coursename.'</a>';
}else{
$c->coursename='<a href="#" class="notes_button_redirect" id="'.$u->notesurl.'">'.$u->coursename.'</a>';
}
} else {
$c->coursename = $u->coursename;
......@@ -153,6 +163,34 @@ class block_mynotes_manager {
} */
/* public function count_notes($options) {
global $DB, $USER;
$params = array();
$userid=$USER->id;
$contextarea='';
$courseid;
if (isset($options->contextarea) && !empty($options->contextarea)) {
$contextarea=$options->contextarea;
}
if (isset($options->courseid) && !empty($options->courseid)) {
$courseid=$options->courseid;
}
$param=array($userid,$contextarea,$courseid);
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and courseid=?';
$result=$DB->get_records_sql($sql,$param);
$count;
foreach ($result as $val){
$count=$val->count;
}
return $count;
// return $DB->count_records('block_mynotes', $params);
} */
public function count_mynotes($options) {
......@@ -160,14 +198,20 @@ class block_mynotes_manager {
$params = array();
$params['userid'] = $USER->id;
// $userid=$USER->id;
// $contextarea='';
// $courseid;
if (isset($options->contextarea) && !empty($options->contextarea)) {
$params['contextarea'] = $options->contextarea;
}
if (isset($options->contextid) && !empty($options->contextid)) {
$params['contextid'] = $options->contextid;
// $contextarea=$options->contextarea;
}
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and contextid=?';
if (isset($options->courseid) && !empty($options->courseid)) {
$params['courseid'] = $options->courseid;
// $courseid=$options->courseid;
}
// $param=array($userid,$contextarea,$courseid);
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and courseid=?';
$result=$DB->get_records_sql($sql,$params);
......@@ -202,7 +246,7 @@ class block_mynotes_manager {
*
* @return object of single mynote record if insert to DB else false
*/
public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl, $format = FORMAT_MOODLE) {
public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl,$activityname, $format = FORMAT_MOODLE) {
global $CFG, $DB, $USER, $OUTPUT;
// $content=$content.$timer;
......@@ -211,6 +255,7 @@ class block_mynotes_manager {
$newnote->contextarea = $contextarea;
$newnote->content = $content;
$newnote->courseid = $course->id;
$newnote->activityname = $activityname;
$newnote->format = $format;
$newnote->userid = $USER->id;
$newnote->timecreated = time();
......@@ -361,6 +406,24 @@ class block_mynotes_manager {
}
public function all_note_edit($mynoteid,$notes){
global $DB, $USER;
if (!$mynote = $DB->get_record('block_mynotes', array('id' => $mynoteid))) {
throw new mynotes_exception('editfailed', 'block_mynotes');
}
if ($USER->id != $mynote->userid) {
throw new mynotes_exception('nopermissiontoedit', 'block_mynotes');
}
$param = array ($notes,$mynoteid );
$sql4 = 'update {block_mynotes} set content=? , timecreated=? where id=? ';
return $update_record = $DB->execute ( $sql4, $param );
}
}
/**
......
......@@ -71,10 +71,11 @@ switch ($action) {
$content = optional_param('content', '', PARAM_RAW);
$timer = optional_param('notestime', '', PARAM_TEXT);
$activityUrl = optional_param('urllink', '', PARAM_TEXT);
$activityname = optional_param('activity', '', PARAM_TEXT);
$manager = new block_mynotes_manager();
if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl)) {
if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl,$activityname)) {
$options = new stdClass();
$options->page = $page;
$options->courseid = $course->id;
......@@ -82,9 +83,10 @@ switch ($action) {
$options->context = $context;
$options->contextarea = $contextarea;
// $options->notestime=$timer;
unset($options->courseid);
// 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'));
......
<?php
require_once (dirname ( __FILE__ ) . '/../../config.php');
require_once(dirname( __FILE__ ) .'/../../lib/phpexcel/PHPExcel.php');
global $OUTPUT, $title;
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
function download_excel(){
global $DB, $CFG,$USER , $PAGE;
$parameter = array ($USER->id);
$sql="select * from {block_mynotes} where userid=?";
$allNotes = $DB->get_records_sql ( $sql, $parameter );
$fullNotes = array ();
$i=0;
foreach ($allNotes as $notes ) {
$courseid=$notes->courseid;
$parameter = array ($courseid);
$sql="select fullname from {course} where id=?";
$coursename = $DB->get_record_sql ( $sql, $parameter );
$fullNotes [$i]['Sl.no']=$i+1;
$fullNotes [$i]['Course']=$coursename->fullname;
if($notes->activityname){
$fullNotes [$i]['activityname']=$notes->activityname;
}
$fullNotes [$i]['Content']=$notes->content;
$time=date('d M Y H:i A (T)', $notes->timecreated);
$fullNotes [$i]['Timecreated']=$time;
$fullNotes [$i]['Videotime']=$notes->notestime;
$fullNotes [$i]['Notesurl']=$notes->notesurl;
$i=$i+1;
}
/* xls format
$fileName = "user_full_notes" . rand(1,100) . ".xls";
if ($fullNotesssss){
function filterData(&$str) {
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}
// headers for download
header("Content-Disposition: attachment; filename=\"$fileName\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
$i=0;
foreach($fullNotes as $row) {
if(!$flag) {
// display column names as first row
echo implode("\t", array_keys($row)) . "\n";
$i=$i+1;
$flag = true;
}
// filter data
array_walk($row, 'filterData');
echo implode("\t", array_values($row)) . "\n";
}
exit;
}
*/
$name = "Student_notes";
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Notes');
$default_border = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'9999ff')
);
$style_header = array(
'borders' => array(
'bottom' => $default_border,
'left' => $default_border,
'top' => $default_border,
'right' => $default_border,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'E1E0F7'),
),
'font' => array(
'bold' => true,
)
);
$default_border1 = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'ff9999')
);
$style_header1 = array(
'borders' => array(
'bottom' => $default_border1,
'left' => $default_border1,
'top' => $default_border1,
'right' => $default_border1,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'ff9999'),
),
'font' => array(
'bold' => true,
)
);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50);
$objPHPExcel->getActiveSheet()->getCell("A1")->setValue("SL.No");
$objPHPExcel->getActiveSheet()->getCell("A1")->getStyle('A1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("B1")->setValue("Course");
$objPHPExcel->getActiveSheet()->getCell("B1")->getStyle('B1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("C1")->setValue("Activity");
$objPHPExcel->getActiveSheet()->getCell("C1")->getStyle('C1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("D1")->setValue("Note");
$objPHPExcel->getActiveSheet()->getCell("D1")->getStyle('D1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("E1")->setValue("Time Created");
$objPHPExcel->getActiveSheet()->getCell("E1")->getStyle('E1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("F1")->setValue("Time in Clip");
$objPHPExcel->getActiveSheet()->getCell("F1")->getStyle('F1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("G1")->setValue("URL");
$objPHPExcel->getActiveSheet()->getCell("G1")->getStyle('G1')->applyFromArray($style_header);
for($i=1;$i<=count($fullNotes)+1;$i++){
$objPHPExcel->getActiveSheet()->getCell('A'.($i+1))->setValue($i);
$objPHPExcel->getActiveSheet()->getCell('B'.($i+1))->setValue($fullNotes[$i-1]['Course']);
$objPHPExcel->getActiveSheet()->getCell('C'.($i+1))->setValue($fullNotes[$i-1]['activityname']);
$objPHPExcel->getActiveSheet()->getCell('D'.($i+1))->setValue($fullNotes[$i-1]['Content']);
$objPHPExcel->getActiveSheet()->getCell('E'.($i+1))->setValue($fullNotes[$i-1]['Timecreated']);
$objPHPExcel->getActiveSheet()->getCell('F'.($i+1))->setValue($fullNotes[$i-1]['Videotime']);
$objPHPExcel->getActiveSheet()->getCell('G'.($i+1))->setValue($fullNotes[$i-1]['Notesurl']);
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
header("Content-Disposition: attachment; filename=$name.xlsx");
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$objWriter->save('php://output');
exit();
}
download_excel();
\ No newline at end of file
......@@ -26,14 +26,14 @@ defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$perpageoptions = array();
for ($i = 1; $i < 20; $i++) {
for ($i = 1; $i < 30; $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));
get_string('mynotesperpage_help', 'block_mynotes'), 20, $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));
get_string('characterlimit_help', 'block_mynotes'), 450, PARAM_INT, 3));
$positionoptions = array();
$positionoptions['mynotes-pos-rb'] = get_string('bottomright', 'block_mynotes');
......
#mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; }
div.mdl-align { min-height: 470px;}
#mynote-edit{position: absolute !important;right: 0 !important; margin: 0px 20px !important;}
#mynote-update{position: absolute !important; right: 0 !important; margin:0px 40px !important;}
#mynote-edit{display:none;position: absolute;right: 0; margin: 0 28px;}
#mynote-update{visibility: hidden;position: absolute !important; right: 0 !important; margin:0px 40px !important;}
#notes_edit_option{color: #2310c3 !important;}
.mdl-align { padding:inherit !important; }
.mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; }
......@@ -26,9 +26,9 @@ div.mdl-align { min-height: 470px;}
.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 .responsetext { color: #33b733; line-height: 15px; }
.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 { padding: 0 10px; margin-right: 1px; height: 30px; line-height: 20px; 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; }
......@@ -39,16 +39,103 @@ div.mdl-align { min-height: 470px;}
.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 { background: #ffe6a4; padding: 3px; 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 { position: absolute; right: 0;}
.mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging a { margin: 5px; background: #c1621e; padding: 1px 3px; 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 {overflow: scroll; height: 250px; margin:0; clear: both; }
.mynotes_base .tab .tab-content ul.mynotes_lists li { list-style: none; position: relative; margin: 0 0 1px 0; padding: 6px; 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 -1px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { display:none;position: absolute; right: 1px; margin:0px -1px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb;}
ul#mynotes_user-list{
padding-left: 0rem !important;
}
/* Overridden style for positioning the notes box */
.moodle-dialogue-wrap.moodle-dialogue-content.yui3-widget-stdmod{
position: fixed !important;
left: 1035px!important;
width: 300px !important;
top: 70px !important;
}
:focus{
outline: -webkit-focus-ring-color auto 0px !important;
}
#notes_edit_option{
outline: -webkit-focus-ring-color auto 2px !important;
}
.notes_overview {
/*
overflow-x: hidden;
overflow-y: scroll;
height: 270px; */
}
.notes_overview {
background-color: #f7f7f7;
width: 100%;
height: 2em;
padding: 9px 6px 0;
/*
overflow-x: hidden;
overflow-y: scroll;
height: 270px; */
}
#notes-slider {
/* left: 3px;
top: 43px; */
}
.notes_section {
padding: 4px 0px 4px 1px;
}
#course_name {
/* padding: 4px 0px 0px 8px;
font-size: 19px;
color: black; */
}
.notes_course {
background-color: #dddddd;
width: 100%;
height: 2em;
padding: 9px 6px 0;
padding: 4px 0px 0px 8px;
font-size: 19px;
color: black;
}
.notes_data {
/* background-color: #f7f7f7;
width: 100%; */
border: 2px solid #fff;
text-align: left;
padding: 8px;
}
#delete_icon.fa.fa-trash{
margin-right: 20em;
text-decoration: underline;
}
#edit_icon.far.fa-edit{
margin-right: 25em;
text-decoration: underline;
}
/* .page-header{
margin-top: 2em !important;
}
.page-title {
margin-top: inherit !important;
} */
......
<?php
require_once('/../../config.php');
// require_once($CFG->dirroot.'/user/profile/lib.php');
// require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot . '/blocks/mynotes/lib.php');
global $USER,$DB;
// if (!isloggedin()) {
// echo json_encode(array('error' => 'require_login'));
// die();
// }
$timertext = optional_param('notestime', '', PARAM_TEXT);
// $myuser=profile_user_record($USER->id);
if ($timertext){
echo $timertext;
}
else{
echo "value fromrhere";
}
......@@ -23,7 +23,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018011202; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018011203; // 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';
......
<?php
require_once (dirname ( __FILE__ ) . '/../../config.php');
// require_once (dirname ( __FILE__ ) . '/leaderboard_data.php');
// require_once ($CFG->dirroot . '/user/profile/lib.php');
global $OUTPUT, $title;
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
// $PAGE->requires->css ( '/blocks/leaders/css/style.css' );
$PAGE->set_pagelayout( 'standard' );
$PAGE->set_title ( "Notes" );
$PAGE->requires->css ( '/blocks/mynotes/style.css' );
$PAGE->set_url ( '/blocks/mynotes/view.php' );
$PAGE->set_heading ( "User Notes" );
$PAGE->navbar->add ( 'Notes', new moodle_url ( '/blocks/mynotes/view.php' ) );
$PAGE->requires->js_call_amd ( 'block_mynotes/script', 'init' );
echo $OUTPUT->header ();
class notes{
public function allnotes(){
global $DB, $CFG,$USER , $PAGE;
$parameter = array ($USER->id);
$sql = "select * from {block_mynotes} where userid=? order by courseid asc";
$allNotes = $DB->get_records_sql ( $sql, $parameter );
$sql="select distinct courseid from {block_mynotes} where userid=? order by courseid asc";
$allCourses=$DB->get_records_sql ( $sql, $parameter );
$fullNotes = array ();
foreach ( $allNotes as $notes ) {
$fullNotes [] = $notes;
}
$fullCourseIds = array ();
foreach ( $allCourses as $courseId ) {
$fullCourseIds [] = $courseId;
}
//full notes list
$noteslist = array ();
for($i = 0; $i < count ( $fullCourseIds ); $i ++) {
foreach ( $fullNotes as $notes ) {
if ($fullCourseIds [$i]->courseid == $notes->courseid) {
$noteslist [$i] [] = $notes;
}
}
}
//coursenames
$courseName = array ();
foreach ( $fullCourseIds as $courseId ) {
$param = array (
$courseId->courseid
);
$sql = "select fullname from {course} where id=?";
$name = $DB->get_record_sql ( $sql, $param );
if ($courseId->courseid == 1) {
$courseName [] = 'Dashboard Notes';
} else {
$courseName [] = $name->fullname;
}
}
return array($fullCourseIds,$noteslist,$courseName);
}
public function viewNotes(){
global $DB ,$CFG ,$USER ,$PAGE;
$getallnotes = new notes ();
$Allnotes=$getallnotes->allnotes();
$CourseIds=$Allnotes[0];
$noteslist=$Allnotes[1];
$courseNameList=$Allnotes[2];
if(!empty($noteslist)){
echo '<a href="'.$CFG->wwwroot.'/blocks/mynotes/notes_excel.php" id="excel_download" class="float-md-right" style="text-decoration: none;">Downlaod Notes</a>';
for ($i=0;$i<count($courseNameList);$i++){
echo ('<div class="notes_section" id="'.$CourseIds[$i]->courseid.'">
<a href="#" class="notes_course fa fa-chevron-circle-right" id="icon'.$CourseIds[$i]->courseid.'" style="text-decoration: none;" >
'.' '.$courseNameList[$i].'</a></div>
<table class="notes_overview" id="notes_table_id'.$CourseIds[$i]->courseid.'">');
for ($j=0;$j<count($noteslist[$i]);$j++){
echo ('<tr class="overall_notes" id="notes'.$noteslist[$i][$j]->id.'">
<td class="notes_data">
<a href="#" class=" delete_note float-right mr-1 fa fa-trash" id="'.$noteslist[$i][$j]->id.'" style="text-decoration: none;" >delete</a>
<a href="#" class=" edit_note float-right mr-5 far fa-edit" id="'.$noteslist[$i][$j]->id.'" style="text-decoration: none;">edit</a>
<p id="notes_content'.$noteslist[$i][$j]->id.'">'.$noteslist[$i][$j]->content.'</p>
</td></tr>');
}
echo '</table>';
}
/* <i class="fa fa-trash" aria-hidden="true">delete</i> */
}else{
echo '<div class="alert alert-danger">
<strong> User notes are empty!</strong> User notes are not availale to display. Please make note while working with activities to view all notes.
</div>';
}
}
}
$viewnotes = new notes ();
$viewnotes->viewNotes ();
echo $OUTPUT->footer ();
\ 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!