dev:changes in notes
Showing
17 changed files
with
1363 additions
and
141 deletions
LICENSE
deleted
100644 → 0
1 | Copyright (c) 2013-2016 GitHub, Inc. and contributors | ||
2 | |||
3 | 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: | ||
4 | |||
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
6 | |||
7 | 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 | ... | \ No newline at end of file |
allnotes_ajax.php
0 → 100644
1 | <?php | ||
2 | define('AJAX_SCRIPT', true); | ||
3 | define('NO_DEBUG_DISPLAY', true); | ||
4 | require_once('../../config.php'); | ||
5 | require_once($CFG->dirroot . '/blocks/mynotes/lib.php'); | ||
6 | |||
7 | |||
8 | require_login (); | ||
9 | |||
10 | $context = context_system::instance (); | ||
11 | $PAGE->set_context ( $context ); | ||
12 | $action = optional_param('action', '', PARAM_ALPHA); | ||
13 | |||
14 | $PAGE->requires->js_call_amd('block_mynotes/script', 'init'); | ||
15 | $PAGE->set_url('/blocks/mynotes/allnotes_ajax.php'); | ||
16 | |||
17 | switch ($action){ | ||
18 | |||
19 | case 'edit': | ||
20 | $noteid = required_param('noteid', PARAM_INT); | ||
21 | $notes = required_param('newnotes', PARAM_TEXT); | ||
22 | $manager = new block_mynotes_manager(); | ||
23 | |||
24 | if ($manager->edit($noteid,$notes)) { | ||
25 | echo json_encode(array('result' => "successfully updated")); | ||
26 | }else{ | ||
27 | echo json_encode(array('error' => 'Unable to update edited note')); | ||
28 | |||
29 | } | ||
30 | die(); | ||
31 | break; | ||
32 | |||
33 | |||
34 | |||
35 | case 'delete': | ||
36 | $noteid = required_param('noteid', PARAM_INT); | ||
37 | $manager = new block_mynotes_manager(); | ||
38 | // $noteid=547; | ||
39 | if ($manager->delete($noteid)) { | ||
40 | echo json_encode(array('noteid' => $noteid, 'result' => "deleted")); | ||
41 | } | ||
42 | else { | ||
43 | echo json_encode(array('error' => 'Unable to delete note')); | ||
44 | } | ||
45 | die(); | ||
46 | break; | ||
47 | |||
48 | } | ||
49 | die(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -2,7 +2,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -2,7 +2,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
2 | var CONFIG; | 2 | var CONFIG; |
3 | var NODES = { | 3 | var NODES = { |
4 | DELETE_ICON: '<span class="delete">❌</span>', | 4 | DELETE_ICON: '<span class="delete">❌</span>', |
5 | EDIT_ICON: '<i class="far fa-edit" id="mynote-edit"></i>', | 5 | EDIT_ICON: '<span class="far fa-edit" id="mynote-edit"></span>', |
6 | SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>', | 6 | SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>', |
7 | }; | 7 | }; |
8 | var SELECTORS = { | 8 | var SELECTORS = { |
... | @@ -31,6 +31,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -31,6 +31,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
31 | 31 | ||
32 | var a = document.createElement('a'); | 32 | var a = document.createElement('a'); |
33 | a.href = baseurl; | 33 | a.href = baseurl; |
34 | |||
34 | return (a.search.length > 0) ? baseurl : baseurl + '?'; | 35 | return (a.search.length > 0) ? baseurl : baseurl + '?'; |
35 | }, | 36 | }, |
36 | getWarnings: function(status) { | 37 | getWarnings: function(status) { |
... | @@ -175,10 +176,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -175,10 +176,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
175 | var timenotes=seconds; | 176 | var timenotes=seconds; |
176 | 177 | ||
177 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); | 178 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); |
179 | // console.log(ta); | ||
178 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { | 180 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { |
179 | return false; | 181 | return false; |
180 | } | 182 | } |
181 | 183 | var activityname=$(".breadcrumb li:last").text() | |
182 | var arg = { | 184 | var arg = { |
183 | contextid: CONFIG.contextid, | 185 | contextid: CONFIG.contextid, |
184 | content: ta.val(), | 186 | content: ta.val(), |
... | @@ -186,6 +188,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -186,6 +188,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
186 | contextarea: scope.currenttabindex, | 188 | contextarea: scope.currenttabindex, |
187 | notestime:timenotes, | 189 | notestime:timenotes, |
188 | urllink:url, | 190 | urllink:url, |
191 | activity:activityname, | ||
189 | 192 | ||
190 | }; | 193 | }; |
191 | 194 | ||
... | @@ -242,7 +245,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -242,7 +245,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
242 | url=''; | 245 | url=''; |
243 | } | 246 | } |
244 | 247 | ||
245 | 248 | var activityname=$(".breadcrumb li:last").text() | |
246 | var arg = { | 249 | var arg = { |
247 | contextid: CONFIG.contextid, | 250 | contextid: CONFIG.contextid, |
248 | content: ta.val(), | 251 | content: ta.val(), |
... | @@ -250,10 +253,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -250,10 +253,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
250 | contextarea: scope.currenttabindex, | 253 | contextarea: scope.currenttabindex, |
251 | notestime:result, | 254 | notestime:result, |
252 | urllink:url, | 255 | urllink:url, |
256 | activity:activityname, | ||
253 | 257 | ||
254 | 258 | ||
255 | }; | 259 | }; |
256 | 260 | ||
257 | ta.attr('disabled', true); | 261 | ta.attr('disabled', true); |
258 | ta.css({ | 262 | ta.css({ |
259 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', | 263 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', |
... | @@ -309,7 +313,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -309,7 +313,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
309 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count); | 313 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count); |
310 | }, | 314 | }, |
311 | getMynotes: function(page = 0) { | 315 | getMynotes: function(page = 0) { |
312 | 316 | ||
313 | var scope = this; | 317 | var scope = this; |
314 | page = parseInt(page); | 318 | page = parseInt(page); |
315 | 319 | ||
... | @@ -372,7 +376,10 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -372,7 +376,10 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
372 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); | 376 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); |
373 | 377 | ||
374 | if (mynotescount > 0) { | 378 | if (mynotescount > 0) { |
375 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')'); | 379 | var rootPath = M.cfg.wwwroot; |
380 | // console.log(CONFIG.contextid); | ||
381 | // $.ajax({url: rootPath + "/blocks/Contest_scroller.php", success: function(result){ | ||
382 | 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>'); | ||
376 | } else { | 383 | } else { |
377 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); | 384 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); |
378 | } | 385 | } |
... | @@ -387,27 +394,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -387,27 +394,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
387 | var x = ''; | 394 | var x = ''; |
388 | for (x in notes) { | 395 | for (x in notes) { |
389 | 396 | ||
390 | |||
391 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); | 397 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); |
392 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; | 398 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id +'" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; |
393 | var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>'; | 399 | var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>'; |
394 | var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_ICON + '</a>'; | 400 | var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_ICON + '</a>'; |
395 | 401 | ||
396 | var notedetail = ''; | 402 | var notedetail = ''; |
397 | if (notes[x].coursename != '') { | 403 | if (notes[x].coursename != '') { |
398 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; | ||
399 | } | ||
400 | |||
401 | var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; | ||
402 | var mynotestime=''; | ||
403 | if (notes[x].notestime != ''){ | ||
404 | mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | ||
405 | 404 | ||
405 | if (notes[x].notestime != ''){ | ||
406 | |||
407 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + notes[x].notestime +'</div>'; | ||
408 | |||
409 | // mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | ||
410 | |||
411 | } | ||
412 | else{ | ||
413 | |||
414 | notedetail = '<div class="note-detail">' + notes[x].coursename + '</div>'; | ||
415 | } | ||
406 | } | 416 | } |
407 | 417 | ||
408 | var note_html = '<div class="content">' + deletelink + editlink + updatelink + notes[x].content + '</div>'; | 418 | // var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; |
419 | // var mynotestime=''; | ||
420 | // if (notes[x].notestime != ''){ | ||
421 | // mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | ||
422 | // | ||
423 | // } | ||
424 | var note_html = '<div class="content">' + deletelink +editlink+ notes[x].content + '</div>'; | ||
425 | // var note_html = '<div class="content">' + deletelink + editlink + updatelink+ notes[x].content + '</div>'; | ||
409 | // var note_html = '<div class="content">' + editlink + notes[x].content + '</div>'; | 426 | // var note_html = '<div class="content">' + editlink + notes[x].content + '</div>'; |
410 | lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>'; | 427 | lists += '<li class="list-of-notes" id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail +'</li>'; |
428 | |||
429 | |||
430 | lists+='' | ||
431 | |||
432 | |||
411 | } | 433 | } |
412 | return lists; | 434 | return lists; |
413 | }, | 435 | }, |
... | @@ -416,18 +438,18 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -416,18 +438,18 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
416 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; | 438 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; |
417 | }, | 439 | }, |
418 | displayMynotes: function() { | 440 | displayMynotes: function() { |
419 | 441 | ||
420 | var scope = this; | 442 | var scope = this; |
421 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); | 443 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); |
422 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); | 444 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); |
423 | |||
424 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); | 445 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); |
425 | |||
426 | var notescount = el.find('li').length; | 446 | var notescount = el.find('li').length; |
427 | var lastpage = Math.ceil(notescount / CONFIG.perpage); | 447 | var lastpage = Math.ceil(notescount / CONFIG.perpage); |
428 | if (notescount > 0 && lastpage <= page) { | 448 | if (notescount > 0 && lastpage <= page) { |
429 | page = lastpage - 1; | 449 | page = lastpage - 1; |
430 | } | 450 | } |
451 | |||
452 | // var link='<a href="#" class="downloadnote">'+download+'</a>'; | ||
431 | //parsing required for backward flow | 453 | //parsing required for backward flow |
432 | var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage)); | 454 | var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage)); |
433 | var lowerlimit = page * CONFIG.perpage; | 455 | var lowerlimit = page * CONFIG.perpage; |
... | @@ -442,6 +464,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -442,6 +464,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
442 | registerActions: function() { | 464 | registerActions: function() { |
443 | 465 | ||
444 | var scope = this; | 466 | var scope = this; |
467 | |||
468 | |||
445 | $('body').delegate('#addmynote_cancel', 'click', function() { | 469 | $('body').delegate('#addmynote_cancel', 'click', function() { |
446 | panel.hide() | 470 | panel.hide() |
447 | }); | 471 | }); |
... | @@ -474,9 +498,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -474,9 +498,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
474 | scope.toggle_textarea(e); | 498 | scope.toggle_textarea(e); |
475 | }); | 499 | }); |
476 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { | 500 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { |
477 | |||
478 | scope.getWarnings(scope.checkInputText()); | 501 | scope.getWarnings(scope.checkInputText()); |
479 | }); | 502 | }); |
503 | |||
480 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { | 504 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { |
481 | e.preventDefault(); | 505 | e.preventDefault(); |
482 | var regex = new RegExp(/[\?&]page=(\d+)/); | 506 | var regex = new RegExp(/[\?&]page=(\d+)/); |
... | @@ -490,6 +514,61 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -490,6 +514,61 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
490 | scope.getMynotes(page); | 514 | scope.getMynotes(page); |
491 | 515 | ||
492 | }); | 516 | }); |
517 | |||
518 | // | ||
519 | |||
520 | $(document).ready(function () { | ||
521 | var editid; | ||
522 | var deleteid; | ||
523 | $(document).on('mouseenter', '.list-of-notes', function () { | ||
524 | var id=this.id; | ||
525 | var replacedid = id.replace('mynote',''); | ||
526 | editid="#mynote-edit"+replacedid; | ||
527 | deleteid="#mynote-delete"+replacedid; | ||
528 | |||
529 | $(editid+' #mynote-edit').show(500); | ||
530 | $(deleteid).show(500); | ||
531 | |||
532 | }).on('mouseleave', '.list-of-notes', function () { | ||
533 | $(deleteid).hide(); | ||
534 | $(editid+' #mynote-edit').hide(); | ||
535 | }); | ||
536 | //function for notes url redirection | ||
537 | $(document).on('click', '.notes_button_redirect', function (e) { | ||
538 | |||
539 | var urlid=this.id; | ||
540 | var notestime=this.name; | ||
541 | |||
542 | var noteurl = urlid.split('&'); | ||
543 | var noteurlone=noteurl[0]; | ||
544 | var noteurltwo=noteurl[1]; | ||
545 | |||
546 | var activityurl= $(location).attr('href'); | ||
547 | |||
548 | var arr = activityurl.split('&'); | ||
549 | var activityurlone=arr[0]; | ||
550 | var activityurltwo=arr[1]; | ||
551 | |||
552 | if(noteurlone == activityurlone){ | ||
553 | |||
554 | if(notestime){ | ||
555 | var iframe = document.querySelector('iframe'); | ||
556 | var player = new Vimeo.Player(iframe); | ||
557 | |||
558 | player.setCurrentTime(notestime).then(function(seconds) { | ||
559 | player.play() | ||
560 | }) | ||
561 | } | ||
562 | }else{ | ||
563 | location.replace(urlid); | ||
564 | |||
565 | } | ||
566 | }); | ||
567 | |||
568 | }); | ||
569 | |||
570 | |||
571 | |||
493 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { | 572 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { |
494 | e.preventDefault(); | 573 | e.preventDefault(); |
495 | var nid = $(this).attr('id'); | 574 | var nid = $(this).attr('id'); |
... | @@ -523,10 +602,48 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -523,10 +602,48 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
523 | $('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option'); | 602 | $('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option'); |
524 | var vals=document.getElementById('notes_edit_option').contentEditable = true; | 603 | var vals=document.getElementById('notes_edit_option').contentEditable = true; |
525 | document.getElementById('notes_edit_option').focus(); | 604 | document.getElementById('notes_edit_option').focus(); |
605 | var deleteid=mytestid.replace('edit','delete') | ||
526 | 606 | ||
607 | $('#'+editid+' #mynote-edit').hide(); | ||
608 | $('#'+deleteid).hide(); | ||
527 | 609 | ||
528 | $( "#"+editid+" #mynote-update" ).click(function() { | 610 | $('#notes_edit_option').keypress(function(event) { |
529 | var newstring= $("#notes_edit_option").text(); | 611 | if (event.keyCode == 13) { |
612 | var newstring= $("#notes_edit_option").text(); | ||
613 | |||
614 | if (nid != '' || nid != 'undefined') { | ||
615 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | ||
616 | var id = nid.replace('mynote-edit-' + CONFIG.instanceid + '-', ''); | ||
617 | |||
618 | var arg = { | ||
619 | contextid: CONFIG.contextid, | ||
620 | action: 'edit', | ||
621 | noteid: id, | ||
622 | lastnotecounts: notescount, | ||
623 | newnotes:newstring, | ||
624 | }; | ||
625 | $('#'+editid+' #mynote-edit').show(); | ||
626 | $('#'+deleteid).show(); | ||
627 | |||
628 | var vals=document.getElementById('notes_edit_option').contentEditable = false; | ||
629 | document.getElementById("notes_edit_option").removeAttribute("id"); | ||
630 | scope.request({ | ||
631 | params: arg, | ||
632 | callback: function(id, ret, args) { | ||
633 | args.scope.addToList(ret); | ||
634 | // $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove(); | ||
635 | args.scope.displayMynotes(); | ||
636 | |||
637 | } | ||
638 | }); | ||
639 | } | ||
640 | } | ||
641 | }); | ||
642 | |||
643 | |||
644 | |||
645 | // $( "#"+editid+" #mynote-update" ).click(function() { | ||
646 | /* var newstring= $("#notes_edit_option").text(); | ||
530 | 647 | ||
531 | if (nid != '' || nid != 'undefined') { | 648 | if (nid != '' || nid != 'undefined') { |
532 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | 649 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; |
... | @@ -549,9 +666,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -549,9 +666,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
549 | args.scope.displayMynotes(); | 666 | args.scope.displayMynotes(); |
550 | } | 667 | } |
551 | }); | 668 | }); |
552 | } | 669 | }*/ |
553 | 670 | ||
554 | }); | 671 | // }); |
555 | 672 | ||
556 | 673 | ||
557 | 674 | ||
... | @@ -590,6 +707,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -590,6 +707,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
590 | key: 'placeholdercontent', | 707 | key: 'placeholdercontent', |
591 | component: 'block_mynotes' | 708 | component: 'block_mynotes' |
592 | }]).done(function(s) { | 709 | }]).done(function(s) { |
710 | |||
593 | 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>'))); | 711 | 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>'))); |
594 | el.find('#addmynote_submit').attr('value', s[2]); | 712 | el.find('#addmynote_submit').attr('value', s[2]); |
595 | el.find('#addmynote_cancel').attr('value', s[3]); | 713 | el.find('#addmynote_cancel').attr('value', s[3]); |
... | @@ -608,11 +726,12 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -608,11 +726,12 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
608 | el.find('.tab').append($(tabcontents)); | 726 | el.find('.tab').append($(tabcontents)); |
609 | Y.use('moodle-core-notification-dialogue', function() { | 727 | Y.use('moodle-core-notification-dialogue', function() { |
610 | panel = new M.core.dialogue({ | 728 | panel = new M.core.dialogue({ |
729 | width: '300px', | ||
611 | draggable: true, | 730 | draggable: true, |
612 | modal: true, | 731 | modal: true, |
613 | closeButton: true, | 732 | closeButton: true, |
614 | headerContent: M.util.get_string('mynotes', 'block_mynotes'), | 733 | headerContent: M.util.get_string('mynotes', 'block_mynotes'), |
615 | responsive: true, | 734 | // responsive: true, |
616 | }); | 735 | }); |
617 | panel.set('bodyContent', el.html()); | 736 | panel.set('bodyContent', el.html()); |
618 | if (initnotes === null) { | 737 | if (initnotes === null) { |
... | @@ -638,17 +757,24 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -638,17 +757,24 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
638 | this.currenttabindex = args.currenttabindex; | 757 | this.currenttabindex = args.currenttabindex; |
639 | this.api = this.getMynotesValidatedUrl(M.cfg.wwwroot + '/blocks/mynotes/mynotes_ajax.php'); | 758 | this.api = this.getMynotesValidatedUrl(M.cfg.wwwroot + '/blocks/mynotes/mynotes_ajax.php'); |
640 | var strtitle = M.util.get_string('showmynotes', 'block_mynotes'); | 759 | var strtitle = M.util.get_string('showmynotes', 'block_mynotes'); |
760 | var url= $(location).attr('href'); | ||
641 | if (!CONFIG.editing) { | 761 | if (!CONFIG.editing) { |
642 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); | 762 | if ( url.includes('/my/') ){ |
643 | handler.addClass(CONFIG.editingicon_pos); | 763 | }else{ |
644 | $('body').append(handler); | 764 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); |
645 | handler.html('<span class="pencil" id="mynotepencil">✍</span>'); | 765 | handler.addClass(CONFIG.editingicon_pos); |
766 | $('body').append(handler); | ||
767 | handler.html('<span class="pencil" id="mynotepencil">✍</span>'); | ||
768 | } | ||
646 | } else { | 769 | } else { |
647 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); | 770 | if ( url.includes('/my/') ){ |
648 | handler.addClass(CONFIG.editingicon_pos); | 771 | }else{ |
649 | handler.html('<span class="pencil">✍</span>'); | 772 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); |
650 | $('.inline-' + CSS.MYNOTES_OPENER).html(handler); | 773 | handler.addClass(CONFIG.editingicon_pos); |
651 | $('.inline-' + CSS.MYNOTES_OPENER).append('<div class="mynotes-pos-inline-text ' + CSS.MYNOTES_OPENER + '">' + strtitle + '</div>'); | 774 | handler.html('<span class="pencil">✍</span>'); |
775 | $('.inline-' + CSS.MYNOTES_OPENER).html(handler); | ||
776 | $('.inline-' + CSS.MYNOTES_OPENER).append('<div class="mynotes-pos-inline-text ' + CSS.MYNOTES_OPENER + '">' + strtitle + '</div>'); | ||
777 | } | ||
652 | } | 778 | } |
653 | var body = $('body'); | 779 | var body = $('body'); |
654 | body.delegate(SELECTORS.MYNOTES_OPENER, 'click', this.displayDialogue); | 780 | body.delegate(SELECTORS.MYNOTES_OPENER, 'click', this.displayDialogue); | ... | ... |
1 | 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 | ... | \ No newline at end of file |
1 | define(['jquery','core/config',], function($,config) { | ||
2 | |||
3 | return { | ||
4 | init: function() { | ||
5 | |||
6 | var CONFIG; | ||
7 | |||
8 | |||
9 | $('.notes_overview').hide(); | ||
10 | |||
11 | |||
12 | var url= $(location).attr('href'); | ||
13 | |||
14 | |||
15 | if(url.includes('/mynotes/view.php')){ | ||
16 | |||
17 | $('.page-header').css('margin-top','2em !important'); | ||
18 | |||
19 | $('.page-title').css('margin-top','inherit !important'); | ||
20 | |||
21 | } | ||
22 | |||
23 | $(document).ready(function(){ | ||
24 | |||
25 | $(".notes_section").click(function(){ | ||
26 | |||
27 | var eventId=this.id; | ||
28 | $('#notes_table_id'+eventId).toggle(); | ||
29 | }); | ||
30 | |||
31 | $(".notes_section").click(function(){ | ||
32 | var eventId=this.id; | ||
33 | |||
34 | var classname=$( "div#"+eventId ).children()[0].className; | ||
35 | |||
36 | if (classname === 'notes_course fa fa-chevron-circle-right'){ | ||
37 | |||
38 | $( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' ); | ||
39 | $( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' ); | ||
40 | } | ||
41 | else if (classname === 'notes_course fa fa-chevron-circle-down'){ | ||
42 | $( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' ); | ||
43 | $( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' ); | ||
44 | } | ||
45 | |||
46 | }); | ||
47 | |||
48 | |||
49 | $("#excel_download").click(function(){ | ||
50 | var rootPath = M.cfg.wwwroot | ||
51 | |||
52 | var arg = { | ||
53 | action: 'download', | ||
54 | |||
55 | }; | ||
56 | |||
57 | $.ajax({ | ||
58 | url: rootPath+"/blocks/mynotes/notes_excel.php", | ||
59 | type: "POST", | ||
60 | data: arg, | ||
61 | success: function(response){ | ||
62 | //do action | ||
63 | }, | ||
64 | error: function(){ | ||
65 | // do action | ||
66 | } | ||
67 | |||
68 | }); | ||
69 | |||
70 | }); | ||
71 | |||
72 | |||
73 | |||
74 | $("a.delete_note").click(function(){ | ||
75 | |||
76 | var deleteId=this.id; | ||
77 | |||
78 | var arg = { | ||
79 | action: 'delete', | ||
80 | noteid: deleteId, | ||
81 | }; | ||
82 | |||
83 | var rootPath = M.cfg.wwwroot; | ||
84 | $.ajax({ | ||
85 | type: 'post', | ||
86 | url: rootPath+'/blocks/mynotes/allnotes_ajax.php', | ||
87 | data:arg, | ||
88 | success: function( data ) { | ||
89 | var deleteid=data.noteid; | ||
90 | $("#notes"+deleteid).remove(); | ||
91 | }, | ||
92 | error: function(data, errorThrown) | ||
93 | { | ||
94 | alert('request failed :'+errorThrown); | ||
95 | } | ||
96 | }); | ||
97 | |||
98 | |||
99 | }); | ||
100 | |||
101 | |||
102 | |||
103 | $("a.edit_note").click(function(){ | ||
104 | |||
105 | var editId=this.id; | ||
106 | |||
107 | // notes_content+editId; | ||
108 | var vals=document.getElementById('notes_content'+editId).contentEditable = true; | ||
109 | document.getElementById('notes_content'+editId).focus(); | ||
110 | // console.log('notes_content'+editId); | ||
111 | $('#notes_content'+editId).keypress(function(event) { | ||
112 | |||
113 | if (event.keyCode == 13) { | ||
114 | |||
115 | var newstring= $('#notes_content'+editId).text(); | ||
116 | // console.log(newstring); | ||
117 | |||
118 | var vals=document.getElementById('notes_content'+editId).contentEditable = false; | ||
119 | |||
120 | var arg = { | ||
121 | action: 'edit', | ||
122 | noteid: editId, | ||
123 | newnotes:newstring, | ||
124 | }; | ||
125 | |||
126 | var rootPath = M.cfg.wwwroot; | ||
127 | $.ajax({ | ||
128 | type: 'post', | ||
129 | url: rootPath+'/blocks/mynotes/allnotes_ajax.php', | ||
130 | data:arg, | ||
131 | success: function( data ) { | ||
132 | |||
133 | }, | ||
134 | error: function(data, errorThrown) | ||
135 | { | ||
136 | alert('request failed :'+errorThrown); | ||
137 | var vals=document.getElementById('notes_content'+editId).contentEditable = true; | ||
138 | } | ||
139 | }); | ||
140 | |||
141 | |||
142 | |||
143 | |||
144 | |||
145 | } | ||
146 | |||
147 | |||
148 | |||
149 | |||
150 | }); | ||
151 | |||
152 | |||
153 | |||
154 | }); | ||
155 | |||
156 | |||
157 | |||
158 | |||
159 | }); | ||
160 | |||
161 | |||
162 | } | ||
163 | }; | ||
164 | }); | ... | ... |
... | @@ -2,7 +2,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -2,7 +2,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
2 | var CONFIG; | 2 | var CONFIG; |
3 | var NODES = { | 3 | var NODES = { |
4 | DELETE_ICON: '<span class="delete">❌</span>', | 4 | DELETE_ICON: '<span class="delete">❌</span>', |
5 | EDIT_ICON: '<i class="far fa-edit" id="mynote-edit"></i>', | 5 | EDIT_ICON: '<span class="far fa-edit" id="mynote-edit"></span>', |
6 | SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>', | 6 | SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>', |
7 | }; | 7 | }; |
8 | var SELECTORS = { | 8 | var SELECTORS = { |
... | @@ -31,6 +31,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -31,6 +31,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
31 | 31 | ||
32 | var a = document.createElement('a'); | 32 | var a = document.createElement('a'); |
33 | a.href = baseurl; | 33 | a.href = baseurl; |
34 | |||
34 | return (a.search.length > 0) ? baseurl : baseurl + '?'; | 35 | return (a.search.length > 0) ? baseurl : baseurl + '?'; |
35 | }, | 36 | }, |
36 | getWarnings: function(status) { | 37 | getWarnings: function(status) { |
... | @@ -175,10 +176,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -175,10 +176,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
175 | var timenotes=seconds; | 176 | var timenotes=seconds; |
176 | 177 | ||
177 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); | 178 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); |
179 | // console.log(ta); | ||
178 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { | 180 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { |
179 | return false; | 181 | return false; |
180 | } | 182 | } |
181 | 183 | var activityname=$(".breadcrumb li:last").text() | |
182 | var arg = { | 184 | var arg = { |
183 | contextid: CONFIG.contextid, | 185 | contextid: CONFIG.contextid, |
184 | content: ta.val(), | 186 | content: ta.val(), |
... | @@ -186,6 +188,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -186,6 +188,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
186 | contextarea: scope.currenttabindex, | 188 | contextarea: scope.currenttabindex, |
187 | notestime:timenotes, | 189 | notestime:timenotes, |
188 | urllink:url, | 190 | urllink:url, |
191 | activity:activityname, | ||
189 | 192 | ||
190 | }; | 193 | }; |
191 | 194 | ||
... | @@ -242,7 +245,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -242,7 +245,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
242 | url=''; | 245 | url=''; |
243 | } | 246 | } |
244 | 247 | ||
245 | 248 | var activityname=$(".breadcrumb li:last").text() | |
246 | var arg = { | 249 | var arg = { |
247 | contextid: CONFIG.contextid, | 250 | contextid: CONFIG.contextid, |
248 | content: ta.val(), | 251 | content: ta.val(), |
... | @@ -250,10 +253,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -250,10 +253,11 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
250 | contextarea: scope.currenttabindex, | 253 | contextarea: scope.currenttabindex, |
251 | notestime:result, | 254 | notestime:result, |
252 | urllink:url, | 255 | urllink:url, |
256 | activity:activityname, | ||
253 | 257 | ||
254 | 258 | ||
255 | }; | 259 | }; |
256 | 260 | ||
257 | ta.attr('disabled', true); | 261 | ta.attr('disabled', true); |
258 | ta.css({ | 262 | ta.css({ |
259 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', | 263 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', |
... | @@ -309,7 +313,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -309,7 +313,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
309 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count); | 313 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count); |
310 | }, | 314 | }, |
311 | getMynotes: function(page = 0) { | 315 | getMynotes: function(page = 0) { |
312 | 316 | ||
313 | var scope = this; | 317 | var scope = this; |
314 | page = parseInt(page); | 318 | page = parseInt(page); |
315 | 319 | ||
... | @@ -372,7 +376,10 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -372,7 +376,10 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
372 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); | 376 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); |
373 | 377 | ||
374 | if (mynotescount > 0) { | 378 | if (mynotescount > 0) { |
375 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')'); | 379 | var rootPath = M.cfg.wwwroot; |
380 | // console.log(CONFIG.contextid); | ||
381 | // $.ajax({url: rootPath + "/blocks/Contest_scroller.php", success: function(result){ | ||
382 | 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>'); | ||
376 | } else { | 383 | } else { |
377 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); | 384 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); |
378 | } | 385 | } |
... | @@ -387,27 +394,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -387,27 +394,42 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
387 | var x = ''; | 394 | var x = ''; |
388 | for (x in notes) { | 395 | for (x in notes) { |
389 | 396 | ||
390 | |||
391 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); | 397 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); |
392 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; | 398 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id +'" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; |
393 | var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>'; | 399 | var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>'; |
394 | var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_ICON + '</a>'; | 400 | var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_ICON + '</a>'; |
395 | 401 | ||
396 | var notedetail = ''; | 402 | var notedetail = ''; |
397 | if (notes[x].coursename != '') { | 403 | if (notes[x].coursename != '') { |
398 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; | ||
399 | } | ||
400 | |||
401 | var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; | ||
402 | var mynotestime=''; | ||
403 | if (notes[x].notestime != ''){ | ||
404 | mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | ||
405 | 404 | ||
405 | if (notes[x].notestime != ''){ | ||
406 | |||
407 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + notes[x].notestime +'</div>'; | ||
408 | |||
409 | // mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | ||
410 | |||
411 | } | ||
412 | else{ | ||
413 | |||
414 | notedetail = '<div class="note-detail">' + notes[x].coursename + '</div>'; | ||
415 | } | ||
406 | } | 416 | } |
407 | 417 | ||
408 | var note_html = '<div class="content">' + deletelink + editlink + updatelink + notes[x].content + '</div>'; | 418 | // var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; |
419 | // var mynotestime=''; | ||
420 | // if (notes[x].notestime != ''){ | ||
421 | // mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | ||
422 | // | ||
423 | // } | ||
424 | var note_html = '<div class="content">' + deletelink +editlink+ notes[x].content + '</div>'; | ||
425 | // var note_html = '<div class="content">' + deletelink + editlink + updatelink+ notes[x].content + '</div>'; | ||
409 | // var note_html = '<div class="content">' + editlink + notes[x].content + '</div>'; | 426 | // var note_html = '<div class="content">' + editlink + notes[x].content + '</div>'; |
410 | lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>'; | 427 | lists += '<li class="list-of-notes" id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail +'</li>'; |
428 | |||
429 | |||
430 | lists+='' | ||
431 | |||
432 | |||
411 | } | 433 | } |
412 | return lists; | 434 | return lists; |
413 | }, | 435 | }, |
... | @@ -416,18 +438,18 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -416,18 +438,18 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
416 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; | 438 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; |
417 | }, | 439 | }, |
418 | displayMynotes: function() { | 440 | displayMynotes: function() { |
419 | 441 | ||
420 | var scope = this; | 442 | var scope = this; |
421 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); | 443 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); |
422 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); | 444 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); |
423 | |||
424 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); | 445 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); |
425 | |||
426 | var notescount = el.find('li').length; | 446 | var notescount = el.find('li').length; |
427 | var lastpage = Math.ceil(notescount / CONFIG.perpage); | 447 | var lastpage = Math.ceil(notescount / CONFIG.perpage); |
428 | if (notescount > 0 && lastpage <= page) { | 448 | if (notescount > 0 && lastpage <= page) { |
429 | page = lastpage - 1; | 449 | page = lastpage - 1; |
430 | } | 450 | } |
451 | |||
452 | // var link='<a href="#" class="downloadnote">'+download+'</a>'; | ||
431 | //parsing required for backward flow | 453 | //parsing required for backward flow |
432 | var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage)); | 454 | var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage)); |
433 | var lowerlimit = page * CONFIG.perpage; | 455 | var lowerlimit = page * CONFIG.perpage; |
... | @@ -442,6 +464,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -442,6 +464,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
442 | registerActions: function() { | 464 | registerActions: function() { |
443 | 465 | ||
444 | var scope = this; | 466 | var scope = this; |
467 | |||
468 | |||
445 | $('body').delegate('#addmynote_cancel', 'click', function() { | 469 | $('body').delegate('#addmynote_cancel', 'click', function() { |
446 | panel.hide() | 470 | panel.hide() |
447 | }); | 471 | }); |
... | @@ -474,9 +498,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -474,9 +498,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
474 | scope.toggle_textarea(e); | 498 | scope.toggle_textarea(e); |
475 | }); | 499 | }); |
476 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { | 500 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { |
477 | |||
478 | scope.getWarnings(scope.checkInputText()); | 501 | scope.getWarnings(scope.checkInputText()); |
479 | }); | 502 | }); |
503 | |||
480 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { | 504 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { |
481 | e.preventDefault(); | 505 | e.preventDefault(); |
482 | var regex = new RegExp(/[\?&]page=(\d+)/); | 506 | var regex = new RegExp(/[\?&]page=(\d+)/); |
... | @@ -490,6 +514,61 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -490,6 +514,61 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
490 | scope.getMynotes(page); | 514 | scope.getMynotes(page); |
491 | 515 | ||
492 | }); | 516 | }); |
517 | |||
518 | // | ||
519 | |||
520 | $(document).ready(function () { | ||
521 | var editid; | ||
522 | var deleteid; | ||
523 | $(document).on('mouseenter', '.list-of-notes', function () { | ||
524 | var id=this.id; | ||
525 | var replacedid = id.replace('mynote',''); | ||
526 | editid="#mynote-edit"+replacedid; | ||
527 | deleteid="#mynote-delete"+replacedid; | ||
528 | |||
529 | $(editid+' #mynote-edit').show(500); | ||
530 | $(deleteid).show(500); | ||
531 | |||
532 | }).on('mouseleave', '.list-of-notes', function () { | ||
533 | $(deleteid).hide(); | ||
534 | $(editid+' #mynote-edit').hide(); | ||
535 | }); | ||
536 | //function for notes url redirection | ||
537 | $(document).on('click', '.notes_button_redirect', function (e) { | ||
538 | |||
539 | var urlid=this.id; | ||
540 | var notestime=this.name; | ||
541 | |||
542 | var noteurl = urlid.split('&'); | ||
543 | var noteurlone=noteurl[0]; | ||
544 | var noteurltwo=noteurl[1]; | ||
545 | |||
546 | var activityurl= $(location).attr('href'); | ||
547 | |||
548 | var arr = activityurl.split('&'); | ||
549 | var activityurlone=arr[0]; | ||
550 | var activityurltwo=arr[1]; | ||
551 | |||
552 | if(noteurlone == activityurlone){ | ||
553 | |||
554 | if(notestime){ | ||
555 | var iframe = document.querySelector('iframe'); | ||
556 | var player = new Vimeo.Player(iframe); | ||
557 | |||
558 | player.setCurrentTime(notestime).then(function(seconds) { | ||
559 | player.play() | ||
560 | }) | ||
561 | } | ||
562 | }else{ | ||
563 | location.replace(urlid); | ||
564 | |||
565 | } | ||
566 | }); | ||
567 | |||
568 | }); | ||
569 | |||
570 | |||
571 | |||
493 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { | 572 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { |
494 | e.preventDefault(); | 573 | e.preventDefault(); |
495 | var nid = $(this).attr('id'); | 574 | var nid = $(this).attr('id'); |
... | @@ -523,10 +602,48 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -523,10 +602,48 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
523 | $('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option'); | 602 | $('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option'); |
524 | var vals=document.getElementById('notes_edit_option').contentEditable = true; | 603 | var vals=document.getElementById('notes_edit_option').contentEditable = true; |
525 | document.getElementById('notes_edit_option').focus(); | 604 | document.getElementById('notes_edit_option').focus(); |
605 | var deleteid=mytestid.replace('edit','delete') | ||
526 | 606 | ||
607 | $('#'+editid+' #mynote-edit').hide(); | ||
608 | $('#'+deleteid).hide(); | ||
527 | 609 | ||
528 | $( "#"+editid+" #mynote-update" ).click(function() { | 610 | $('#notes_edit_option').keypress(function(event) { |
529 | var newstring= $("#notes_edit_option").text(); | 611 | if (event.keyCode == 13) { |
612 | var newstring= $("#notes_edit_option").text(); | ||
613 | |||
614 | if (nid != '' || nid != 'undefined') { | ||
615 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | ||
616 | var id = nid.replace('mynote-edit-' + CONFIG.instanceid + '-', ''); | ||
617 | |||
618 | var arg = { | ||
619 | contextid: CONFIG.contextid, | ||
620 | action: 'edit', | ||
621 | noteid: id, | ||
622 | lastnotecounts: notescount, | ||
623 | newnotes:newstring, | ||
624 | }; | ||
625 | $('#'+editid+' #mynote-edit').show(); | ||
626 | $('#'+deleteid).show(); | ||
627 | |||
628 | var vals=document.getElementById('notes_edit_option').contentEditable = false; | ||
629 | document.getElementById("notes_edit_option").removeAttribute("id"); | ||
630 | scope.request({ | ||
631 | params: arg, | ||
632 | callback: function(id, ret, args) { | ||
633 | args.scope.addToList(ret); | ||
634 | // $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove(); | ||
635 | args.scope.displayMynotes(); | ||
636 | |||
637 | } | ||
638 | }); | ||
639 | } | ||
640 | } | ||
641 | }); | ||
642 | |||
643 | |||
644 | |||
645 | // $( "#"+editid+" #mynote-update" ).click(function() { | ||
646 | /* var newstring= $("#notes_edit_option").text(); | ||
530 | 647 | ||
531 | if (nid != '' || nid != 'undefined') { | 648 | if (nid != '' || nid != 'undefined') { |
532 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | 649 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; |
... | @@ -549,9 +666,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -549,9 +666,9 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
549 | args.scope.displayMynotes(); | 666 | args.scope.displayMynotes(); |
550 | } | 667 | } |
551 | }); | 668 | }); |
552 | } | 669 | }*/ |
553 | 670 | ||
554 | }); | 671 | // }); |
555 | 672 | ||
556 | 673 | ||
557 | 674 | ||
... | @@ -590,6 +707,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -590,6 +707,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
590 | key: 'placeholdercontent', | 707 | key: 'placeholdercontent', |
591 | component: 'block_mynotes' | 708 | component: 'block_mynotes' |
592 | }]).done(function(s) { | 709 | }]).done(function(s) { |
710 | |||
593 | 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>'))); | 711 | 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>'))); |
594 | el.find('#addmynote_submit').attr('value', s[2]); | 712 | el.find('#addmynote_submit').attr('value', s[2]); |
595 | el.find('#addmynote_cancel').attr('value', s[3]); | 713 | el.find('#addmynote_cancel').attr('value', s[3]); |
... | @@ -608,11 +726,12 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -608,11 +726,12 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
608 | el.find('.tab').append($(tabcontents)); | 726 | el.find('.tab').append($(tabcontents)); |
609 | Y.use('moodle-core-notification-dialogue', function() { | 727 | Y.use('moodle-core-notification-dialogue', function() { |
610 | panel = new M.core.dialogue({ | 728 | panel = new M.core.dialogue({ |
729 | width: '300px', | ||
611 | draggable: true, | 730 | draggable: true, |
612 | modal: true, | 731 | modal: true, |
613 | closeButton: true, | 732 | closeButton: true, |
614 | headerContent: M.util.get_string('mynotes', 'block_mynotes'), | 733 | headerContent: M.util.get_string('mynotes', 'block_mynotes'), |
615 | responsive: true, | 734 | // responsive: true, |
616 | }); | 735 | }); |
617 | panel.set('bodyContent', el.html()); | 736 | panel.set('bodyContent', el.html()); |
618 | if (initnotes === null) { | 737 | if (initnotes === null) { |
... | @@ -638,17 +757,24 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -638,17 +757,24 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
638 | this.currenttabindex = args.currenttabindex; | 757 | this.currenttabindex = args.currenttabindex; |
639 | this.api = this.getMynotesValidatedUrl(M.cfg.wwwroot + '/blocks/mynotes/mynotes_ajax.php'); | 758 | this.api = this.getMynotesValidatedUrl(M.cfg.wwwroot + '/blocks/mynotes/mynotes_ajax.php'); |
640 | var strtitle = M.util.get_string('showmynotes', 'block_mynotes'); | 759 | var strtitle = M.util.get_string('showmynotes', 'block_mynotes'); |
760 | var url= $(location).attr('href'); | ||
641 | if (!CONFIG.editing) { | 761 | if (!CONFIG.editing) { |
642 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); | 762 | if ( url.includes('/my/') ){ |
643 | handler.addClass(CONFIG.editingicon_pos); | 763 | }else{ |
644 | $('body').append(handler); | 764 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); |
645 | handler.html('<span class="pencil" id="mynotepencil">✍</span>'); | 765 | handler.addClass(CONFIG.editingicon_pos); |
766 | $('body').append(handler); | ||
767 | handler.html('<span class="pencil" id="mynotepencil">✍</span>'); | ||
768 | } | ||
646 | } else { | 769 | } else { |
647 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); | 770 | if ( url.includes('/my/') ){ |
648 | handler.addClass(CONFIG.editingicon_pos); | 771 | }else{ |
649 | handler.html('<span class="pencil">✍</span>'); | 772 | var handler = $('<div class="' + CSS.MYNOTES_OPENER + '" title="' + strtitle + '" alt="' + strtitle + '">' + M.util.get_string('mynotes', 'block_mynotes') + '</div>'); |
650 | $('.inline-' + CSS.MYNOTES_OPENER).html(handler); | 773 | handler.addClass(CONFIG.editingicon_pos); |
651 | $('.inline-' + CSS.MYNOTES_OPENER).append('<div class="mynotes-pos-inline-text ' + CSS.MYNOTES_OPENER + '">' + strtitle + '</div>'); | 774 | handler.html('<span class="pencil">✍</span>'); |
775 | $('.inline-' + CSS.MYNOTES_OPENER).html(handler); | ||
776 | $('.inline-' + CSS.MYNOTES_OPENER).append('<div class="mynotes-pos-inline-text ' + CSS.MYNOTES_OPENER + '">' + strtitle + '</div>'); | ||
777 | } | ||
652 | } | 778 | } |
653 | var body = $('body'); | 779 | var body = $('body'); |
654 | body.delegate(SELECTORS.MYNOTES_OPENER, 'click', this.displayDialogue); | 780 | body.delegate(SELECTORS.MYNOTES_OPENER, 'click', this.displayDialogue); | ... | ... |
1 | define(['jquery'], function($) { | 1 | define(['jquery','core/config',], function($,config) { |
2 | 2 | ||
3 | return { | 3 | return { |
4 | init: function() { | 4 | init: function() { |
5 | // tab-mynotes_user | ||
6 | 5 | ||
7 | // tab-mynotes_user mynotepencil | 6 | var CONFIG; |
8 | 7 | ||
9 | console.log('init function got invoked '); | ||
10 | 8 | ||
11 | $('#mynotepencil').click(function(){ | 9 | $('.notes_overview').hide(); |
12 | console.log('init function got invoked '); | 10 | |
11 | |||
12 | var url= $(location).attr('href'); | ||
13 | |||
14 | |||
15 | if(url.includes('/mynotes/view.php')){ | ||
16 | |||
17 | $('.page-header').css('margin-top','2em !important'); | ||
18 | |||
19 | $('.page-title').css('margin-top','inherit !important'); | ||
20 | |||
21 | } | ||
22 | |||
23 | $(document).ready(function(){ | ||
24 | |||
25 | $(".notes_section").click(function(){ | ||
26 | |||
27 | var eventId=this.id; | ||
28 | $('#notes_table_id'+eventId).toggle(); | ||
29 | }); | ||
13 | 30 | ||
31 | $(".notes_section").click(function(){ | ||
32 | var eventId=this.id; | ||
33 | |||
34 | var classname=$( "div#"+eventId ).children()[0].className; | ||
35 | |||
36 | if (classname === 'notes_course fa fa-chevron-circle-right'){ | ||
37 | |||
38 | $( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' ); | ||
39 | $( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' ); | ||
40 | } | ||
41 | else if (classname === 'notes_course fa fa-chevron-circle-down'){ | ||
42 | $( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' ); | ||
43 | $( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' ); | ||
44 | } | ||
45 | |||
46 | }); | ||
47 | |||
48 | |||
49 | $("#excel_download").click(function(){ | ||
50 | var rootPath = M.cfg.wwwroot | ||
51 | |||
52 | var arg = { | ||
53 | action: 'download', | ||
54 | |||
55 | }; | ||
56 | |||
57 | $.ajax({ | ||
58 | url: rootPath+"/blocks/mynotes/notes_excel.php", | ||
59 | type: "POST", | ||
60 | data: arg, | ||
61 | success: function(response){ | ||
62 | //do action | ||
63 | }, | ||
64 | error: function(){ | ||
65 | // do action | ||
66 | } | ||
67 | |||
68 | }); | ||
69 | |||
70 | }); | ||
71 | |||
72 | |||
73 | |||
74 | $("a.delete_note").click(function(){ | ||
75 | |||
76 | var deleteId=this.id; | ||
77 | |||
78 | var arg = { | ||
79 | action: 'delete', | ||
80 | noteid: deleteId, | ||
81 | }; | ||
82 | |||
83 | var rootPath = M.cfg.wwwroot; | ||
84 | $.ajax({ | ||
85 | type: 'post', | ||
86 | url: rootPath+'/blocks/mynotes/allnotes_ajax.php', | ||
87 | data:arg, | ||
88 | success: function( data ) { | ||
89 | var deleteid=data.noteid; | ||
90 | $("#notes"+deleteid).remove(); | ||
91 | }, | ||
92 | error: function(data, errorThrown) | ||
93 | { | ||
94 | alert('request failed :'+errorThrown); | ||
95 | } | ||
96 | }); | ||
97 | |||
98 | |||
99 | }); | ||
100 | |||
101 | |||
102 | |||
103 | $("a.edit_note").click(function(){ | ||
104 | |||
105 | var editId=this.id; | ||
106 | |||
107 | // notes_content+editId; | ||
108 | var vals=document.getElementById('notes_content'+editId).contentEditable = true; | ||
109 | document.getElementById('notes_content'+editId).focus(); | ||
110 | // console.log('notes_content'+editId); | ||
111 | $('#notes_content'+editId).keypress(function(event) { | ||
112 | |||
113 | if (event.keyCode == 13) { | ||
114 | |||
115 | var newstring= $('#notes_content'+editId).text(); | ||
116 | // console.log(newstring); | ||
117 | |||
118 | var vals=document.getElementById('notes_content'+editId).contentEditable = false; | ||
119 | |||
120 | var arg = { | ||
121 | action: 'edit', | ||
122 | noteid: editId, | ||
123 | newnotes:newstring, | ||
124 | }; | ||
125 | |||
126 | var rootPath = M.cfg.wwwroot; | ||
127 | $.ajax({ | ||
128 | type: 'post', | ||
129 | url: rootPath+'/blocks/mynotes/allnotes_ajax.php', | ||
130 | data:arg, | ||
131 | success: function( data ) { | ||
132 | |||
133 | }, | ||
134 | error: function(data, errorThrown) | ||
135 | { | ||
136 | alert('request failed :'+errorThrown); | ||
137 | var vals=document.getElementById('notes_content'+editId).contentEditable = true; | ||
138 | } | ||
139 | }); | ||
140 | |||
141 | |||
142 | |||
143 | |||
144 | |||
145 | } | ||
146 | |||
147 | |||
148 | |||
149 | |||
150 | }); | ||
151 | |||
152 | |||
153 | |||
154 | }); | ||
155 | |||
156 | |||
157 | |||
158 | |||
14 | }); | 159 | }); |
15 | 160 | ||
16 | // document.getElementById("panel").style.display = "none"; Nothing to display | 161 | |
17 | |||
18 | // $("#tab-mynotes_user").removeAttr("style").hide(); | ||
19 | } | 162 | } |
20 | }; | 163 | }; |
21 | }); | 164 | }); | ... | ... |
course_level_notes.php
0 → 100644
1 | <?php | ||
2 | require_once (dirname ( __FILE__ ) . '/../../config.php'); | ||
3 | require_once(dirname( __FILE__ ) .'/../../lib/phpexcel/PHPExcel.php'); | ||
4 | global $OUTPUT, $title; | ||
5 | |||
6 | require_login (); | ||
7 | $context = context_system::instance (); | ||
8 | $PAGE->set_context ( $context ); | ||
9 | |||
10 | function download_excel(){ | ||
11 | global $DB, $CFG,$USER ,$PAGE; | ||
12 | |||
13 | $contextid; | ||
14 | if (isset($_GET['cid'])) { | ||
15 | $contextid=$_GET['cid']; | ||
16 | } | ||
17 | |||
18 | $parameter; | ||
19 | if ($contextid){ | ||
20 | $parameter = array ($USER->id,$contextid); | ||
21 | }else{ | ||
22 | $parameter = array ($USER->id); | ||
23 | } | ||
24 | |||
25 | $sql="select id,courseid from {block_mynotes} where userid=? and contextid=?"; | ||
26 | $courseids = $DB->get_records_sql ( $sql, $parameter ); | ||
27 | |||
28 | $courseid; | ||
29 | |||
30 | foreach ( $courseids as $value){ | ||
31 | $courseid=$value->courseid; | ||
32 | } | ||
33 | |||
34 | |||
35 | $param=array($USER->id,$courseid); | ||
36 | $sql="select * from {block_mynotes} where userid=? and courseid=?"; | ||
37 | $allNotes = $DB->get_records_sql ( $sql, $param ); | ||
38 | |||
39 | $fullNotes = array (); | ||
40 | |||
41 | $i=0; | ||
42 | foreach ($allNotes as $notes ) { | ||
43 | $courseid=$notes->courseid; | ||
44 | |||
45 | $parameter = array ($courseid); | ||
46 | $sql="select fullname from {course} where id=?"; | ||
47 | $coursename = $DB->get_record_sql ( $sql, $parameter ); | ||
48 | |||
49 | |||
50 | |||
51 | $fullNotes [$i]['Sl.no']=$i+1; | ||
52 | $fullNotes [$i]['Course']=$coursename->fullname; | ||
53 | if($notes->activityname){ | ||
54 | $fullNotes [$i]['activityname']=$notes->activityname; | ||
55 | } | ||
56 | $fullNotes [$i]['Content']=$notes->content; | ||
57 | |||
58 | $time=date('d M Y H:i A (T)', $notes->timecreated); | ||
59 | $fullNotes [$i]['Timecreated']=$time; | ||
60 | $fullNotes [$i]['Videotime']=$notes->notestime; | ||
61 | $fullNotes [$i]['Notesurl']=$notes->notesurl; | ||
62 | |||
63 | $i=$i+1; | ||
64 | } | ||
65 | |||
66 | if (!empty($fullNotes)){ | ||
67 | |||
68 | $name = "Student_notes"; | ||
69 | |||
70 | $objPHPExcel = new PHPExcel(); | ||
71 | $objPHPExcel->setActiveSheetIndex(0); | ||
72 | $objPHPExcel->getActiveSheet()->setTitle('Notes'); | ||
73 | |||
74 | $default_border = array( | ||
75 | 'style' => PHPExcel_Style_Border::BORDER_THIN, | ||
76 | 'color' => array('rgb'=>'9999ff') | ||
77 | ); | ||
78 | |||
79 | $style_header = array( | ||
80 | 'borders' => array( | ||
81 | 'bottom' => $default_border, | ||
82 | 'left' => $default_border, | ||
83 | 'top' => $default_border, | ||
84 | 'right' => $default_border, | ||
85 | ), | ||
86 | 'fill' => array( | ||
87 | 'type' => PHPExcel_Style_Fill::FILL_SOLID, | ||
88 | 'color' => array('rgb'=>'E1E0F7'), | ||
89 | ), | ||
90 | 'font' => array( | ||
91 | 'bold' => true, | ||
92 | ) | ||
93 | ); | ||
94 | |||
95 | |||
96 | $default_border1 = array( | ||
97 | 'style' => PHPExcel_Style_Border::BORDER_THIN, | ||
98 | 'color' => array('rgb'=>'ff9999') | ||
99 | ); | ||
100 | |||
101 | $style_header1 = array( | ||
102 | 'borders' => array( | ||
103 | 'bottom' => $default_border1, | ||
104 | 'left' => $default_border1, | ||
105 | 'top' => $default_border1, | ||
106 | 'right' => $default_border1, | ||
107 | ), | ||
108 | 'fill' => array( | ||
109 | 'type' => PHPExcel_Style_Fill::FILL_SOLID, | ||
110 | 'color' => array('rgb'=>'ff9999'), | ||
111 | ), | ||
112 | 'font' => array( | ||
113 | 'bold' => true, | ||
114 | ) | ||
115 | ); | ||
116 | |||
117 | $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8); | ||
118 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | ||
119 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30); | ||
120 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25); | ||
121 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20); | ||
122 | $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25); | ||
123 | $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50); | ||
124 | |||
125 | $objPHPExcel->getActiveSheet()->getCell("A1")->setValue("SL.No"); | ||
126 | $objPHPExcel->getActiveSheet()->getCell("A1")->getStyle('A1')->applyFromArray($style_header); | ||
127 | $objPHPExcel->getActiveSheet()->getCell("B1")->setValue("Course"); | ||
128 | $objPHPExcel->getActiveSheet()->getCell("B1")->getStyle('B1')->applyFromArray($style_header); | ||
129 | $objPHPExcel->getActiveSheet()->getCell("C1")->setValue("Activity "); | ||
130 | $objPHPExcel->getActiveSheet()->getCell("C1")->getStyle('C1')->applyFromArray($style_header); | ||
131 | $objPHPExcel->getActiveSheet()->getCell("D1")->setValue("Note"); | ||
132 | $objPHPExcel->getActiveSheet()->getCell("D1")->getStyle('D1')->applyFromArray($style_header); | ||
133 | $objPHPExcel->getActiveSheet()->getCell("E1")->setValue("Time Created"); | ||
134 | $objPHPExcel->getActiveSheet()->getCell("E1")->getStyle('E1')->applyFromArray($style_header); | ||
135 | $objPHPExcel->getActiveSheet()->getCell("F1")->setValue("Time in clip"); | ||
136 | $objPHPExcel->getActiveSheet()->getCell("F1")->getStyle('F1')->applyFromArray($style_header); | ||
137 | $objPHPExcel->getActiveSheet()->getCell("G1")->setValue("URL"); | ||
138 | $objPHPExcel->getActiveSheet()->getCell("G1")->getStyle('G1')->applyFromArray($style_header); | ||
139 | |||
140 | |||
141 | for($i=1;$i<=count($fullNotes)+1;$i++){ | ||
142 | |||
143 | $objPHPExcel->getActiveSheet()->getCell('A'.($i+1))->setValue($i); | ||
144 | $objPHPExcel->getActiveSheet()->getCell('B'.($i+1))->setValue($fullNotes[$i-1]['Course']); | ||
145 | $objPHPExcel->getActiveSheet()->getCell('C'.($i+1))->setValue($fullNotes[$i-1]['activityname']); | ||
146 | $objPHPExcel->getActiveSheet()->getCell('D'.($i+1))->setValue($fullNotes[$i-1]['Content']); | ||
147 | $objPHPExcel->getActiveSheet()->getCell('E'.($i+1))->setValue($fullNotes[$i-1]['Timecreated']); | ||
148 | $objPHPExcel->getActiveSheet()->getCell('F'.($i+1))->setValue($fullNotes[$i-1]['Videotime']); | ||
149 | $objPHPExcel->getActiveSheet()->getCell('G'.($i+1))->setValue($fullNotes[$i-1]['Notesurl']); | ||
150 | |||
151 | |||
152 | } | ||
153 | |||
154 | $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); | ||
155 | $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); | ||
156 | ob_end_clean(); | ||
157 | |||
158 | header("Content-Disposition: attachment; filename=$name.xlsx"); | ||
159 | header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | ||
160 | $objWriter->save('php://output'); | ||
161 | exit(); | ||
162 | |||
163 | |||
164 | } | ||
165 | |||
166 | |||
167 | } | ||
168 | |||
169 | download_excel(); | ||
170 | |||
171 | |||
172 | |||
173 | |||
174 | |||
175 |
... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
11 | <FIELD NAME="contextarea" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/> | 11 | <FIELD NAME="contextarea" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/> |
12 | <FIELD NAME="content" TYPE="text" NOTNULL="true" SEQUENCE="false"/> | 12 | <FIELD NAME="content" TYPE="text" NOTNULL="true" SEQUENCE="false"/> |
13 | <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | 13 | <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> |
14 | <FIELD NAME="activityname" TYPE="text" NOTNULL="true" SEQUENCE="false"/> | ||
14 | <FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> | 15 | <FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> |
15 | <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | 16 | <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> |
16 | <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | 17 | <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | ... | ... |
... | @@ -31,7 +31,7 @@ function xmldb_block_mynotes_upgrade($oldversion) { | ... | @@ -31,7 +31,7 @@ function xmldb_block_mynotes_upgrade($oldversion) { |
31 | $dbman = $DB->get_manager(); | 31 | $dbman = $DB->get_manager(); |
32 | 32 | ||
33 | //Upgrade to add an extra column to local_qharvest_qns_count table | 33 | //Upgrade to add an extra column to local_qharvest_qns_count table |
34 | if( $oldversion < 2018011201 ){ | 34 | if( $oldversion < 2018011203 ){ |
35 | 35 | ||
36 | $table = new xmldb_table('block_mynotes'); | 36 | $table = new xmldb_table('block_mynotes'); |
37 | 37 | ||
... | @@ -44,6 +44,7 @@ function xmldb_block_mynotes_upgrade($oldversion) { | ... | @@ -44,6 +44,7 @@ function xmldb_block_mynotes_upgrade($oldversion) { |
44 | $table->add_field('contextarea', XMLDB_TYPE_CHAR,'255', null, null, null,null); | 44 | $table->add_field('contextarea', XMLDB_TYPE_CHAR,'255', null, null, null,null); |
45 | $table->add_field('content', XMLDB_TYPE_TEXT, null, null, null,null); | 45 | $table->add_field('content', XMLDB_TYPE_TEXT, null, null, null,null); |
46 | $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); | 46 | $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); |
47 | $table->add_field('activityname', XMLDB_TYPE_TEXT, null, null, null,null); | ||
47 | $table->add_field('format', XMLDB_TYPE_INTEGER, '10', null, null, null, null); | 48 | $table->add_field('format', XMLDB_TYPE_INTEGER, '10', null, null, null, null); |
48 | $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); | 49 | $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); |
49 | $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null); | 50 | $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null); | ... | ... |
... | @@ -63,9 +63,9 @@ class block_mynotes_manager { | ... | @@ -63,9 +63,9 @@ class block_mynotes_manager { |
63 | $where .= ' AND m.courseid = :courseid'; | 63 | $where .= ' AND m.courseid = :courseid'; |
64 | $params['courseid'] = $options->courseid; | 64 | $params['courseid'] = $options->courseid; |
65 | } */ | 65 | } */ |
66 | if(isset($options->contextid) && $options->contextid){ | 66 | if(isset($options->courseid) && $options->courseid){ |
67 | $where .= ' AND m.contextid = :contextid'; | 67 | $where .= ' AND m.courseid = :courseid'; |
68 | $params['contextid'] = $options->contextid; | 68 | $params['courseid'] = $options->courseid; |
69 | 69 | ||
70 | } | 70 | } |
71 | $sql = "SELECT $ufields, | 71 | $sql = "SELECT $ufields, |
... | @@ -86,10 +86,20 @@ class block_mynotes_manager { | ... | @@ -86,10 +86,20 @@ class block_mynotes_manager { |
86 | $c->id = $u->mynoteid; | 86 | $c->id = $u->mynoteid; |
87 | $c->userid = $u->id; | 87 | $c->userid = $u->id; |
88 | if ($u->courseid != SITEID) { | 88 | if ($u->courseid != SITEID) { |
89 | // $c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename); | 89 | // $c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename); |
90 | 90 | if (!empty($u->notestime)){ | |
91 | $c->coursename='<a href="#" class="notes_button_redirect" name="'.$u->notestime.'" id="'.course_get_url(($u->courseid), $u->coursename).'">'.$u->coursename.'</a>'; | ||
92 | }else{ | ||
93 | $c->coursename='<a href="#" class="notes_button_redirect" id="'.course_get_url(($u->courseid), $u->coursename).'">'.$u->coursename.'</a>'; | ||
94 | |||
95 | } | ||
91 | if (! empty ( $u->notesurl )) { | 96 | if (! empty ( $u->notesurl )) { |
92 | $c->coursename = html_writer::link ( $u->notesurl, $u->coursename ); | 97 | // $c->coursename = html_writer::link ( $u->notesurl, $u->coursename ); |
98 | if (!empty($u->notestime)){ | ||
99 | $c->coursename='<a href="#" class="notes_button_redirect" name="'.$u->notestime.'" id="'.$u->notesurl.'">'.$u->coursename.'</a>'; | ||
100 | }else{ | ||
101 | $c->coursename='<a href="#" class="notes_button_redirect" id="'.$u->notesurl.'">'.$u->coursename.'</a>'; | ||
102 | } | ||
93 | } else { | 103 | } else { |
94 | 104 | ||
95 | $c->coursename = $u->coursename; | 105 | $c->coursename = $u->coursename; |
... | @@ -153,6 +163,34 @@ class block_mynotes_manager { | ... | @@ -153,6 +163,34 @@ class block_mynotes_manager { |
153 | 163 | ||
154 | } */ | 164 | } */ |
155 | 165 | ||
166 | /* public function count_notes($options) { | ||
167 | global $DB, $USER; | ||
168 | |||
169 | $params = array(); | ||
170 | |||
171 | $userid=$USER->id; | ||
172 | $contextarea=''; | ||
173 | $courseid; | ||
174 | if (isset($options->contextarea) && !empty($options->contextarea)) { | ||
175 | $contextarea=$options->contextarea; | ||
176 | } | ||
177 | if (isset($options->courseid) && !empty($options->courseid)) { | ||
178 | $courseid=$options->courseid; | ||
179 | } | ||
180 | $param=array($userid,$contextarea,$courseid); | ||
181 | $sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and courseid=?'; | ||
182 | |||
183 | $result=$DB->get_records_sql($sql,$param); | ||
184 | |||
185 | $count; | ||
186 | foreach ($result as $val){ | ||
187 | $count=$val->count; | ||
188 | |||
189 | } | ||
190 | |||
191 | return $count; | ||
192 | // return $DB->count_records('block_mynotes', $params); | ||
193 | } */ | ||
156 | 194 | ||
157 | 195 | ||
158 | public function count_mynotes($options) { | 196 | public function count_mynotes($options) { |
... | @@ -160,14 +198,20 @@ class block_mynotes_manager { | ... | @@ -160,14 +198,20 @@ class block_mynotes_manager { |
160 | 198 | ||
161 | $params = array(); | 199 | $params = array(); |
162 | $params['userid'] = $USER->id; | 200 | $params['userid'] = $USER->id; |
201 | // $userid=$USER->id; | ||
202 | // $contextarea=''; | ||
203 | // $courseid; | ||
163 | if (isset($options->contextarea) && !empty($options->contextarea)) { | 204 | if (isset($options->contextarea) && !empty($options->contextarea)) { |
164 | $params['contextarea'] = $options->contextarea; | 205 | $params['contextarea'] = $options->contextarea; |
165 | } | 206 | // $contextarea=$options->contextarea; |
166 | if (isset($options->contextid) && !empty($options->contextid)) { | ||
167 | $params['contextid'] = $options->contextid; | ||
168 | } | 207 | } |
169 | 208 | ||
170 | $sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and contextid=?'; | 209 | if (isset($options->courseid) && !empty($options->courseid)) { |
210 | $params['courseid'] = $options->courseid; | ||
211 | // $courseid=$options->courseid; | ||
212 | } | ||
213 | // $param=array($userid,$contextarea,$courseid); | ||
214 | $sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and courseid=?'; | ||
171 | 215 | ||
172 | $result=$DB->get_records_sql($sql,$params); | 216 | $result=$DB->get_records_sql($sql,$params); |
173 | 217 | ||
... | @@ -202,7 +246,7 @@ class block_mynotes_manager { | ... | @@ -202,7 +246,7 @@ class block_mynotes_manager { |
202 | * | 246 | * |
203 | * @return object of single mynote record if insert to DB else false | 247 | * @return object of single mynote record if insert to DB else false |
204 | */ | 248 | */ |
205 | public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl, $format = FORMAT_MOODLE) { | 249 | public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl,$activityname, $format = FORMAT_MOODLE) { |
206 | global $CFG, $DB, $USER, $OUTPUT; | 250 | global $CFG, $DB, $USER, $OUTPUT; |
207 | // $content=$content.$timer; | 251 | // $content=$content.$timer; |
208 | 252 | ||
... | @@ -211,6 +255,7 @@ class block_mynotes_manager { | ... | @@ -211,6 +255,7 @@ class block_mynotes_manager { |
211 | $newnote->contextarea = $contextarea; | 255 | $newnote->contextarea = $contextarea; |
212 | $newnote->content = $content; | 256 | $newnote->content = $content; |
213 | $newnote->courseid = $course->id; | 257 | $newnote->courseid = $course->id; |
258 | $newnote->activityname = $activityname; | ||
214 | $newnote->format = $format; | 259 | $newnote->format = $format; |
215 | $newnote->userid = $USER->id; | 260 | $newnote->userid = $USER->id; |
216 | $newnote->timecreated = time(); | 261 | $newnote->timecreated = time(); |
... | @@ -361,6 +406,24 @@ class block_mynotes_manager { | ... | @@ -361,6 +406,24 @@ class block_mynotes_manager { |
361 | 406 | ||
362 | } | 407 | } |
363 | 408 | ||
409 | public function all_note_edit($mynoteid,$notes){ | ||
410 | global $DB, $USER; | ||
411 | |||
412 | if (!$mynote = $DB->get_record('block_mynotes', array('id' => $mynoteid))) { | ||
413 | throw new mynotes_exception('editfailed', 'block_mynotes'); | ||
414 | } | ||
415 | |||
416 | if ($USER->id != $mynote->userid) { | ||
417 | throw new mynotes_exception('nopermissiontoedit', 'block_mynotes'); | ||
418 | } | ||
419 | |||
420 | $param = array ($notes,$mynoteid ); | ||
421 | $sql4 = 'update {block_mynotes} set content=? , timecreated=? where id=? '; | ||
422 | return $update_record = $DB->execute ( $sql4, $param ); | ||
423 | |||
424 | } | ||
425 | |||
426 | |||
364 | } | 427 | } |
365 | 428 | ||
366 | /** | 429 | /** | ... | ... |
... | @@ -71,10 +71,11 @@ switch ($action) { | ... | @@ -71,10 +71,11 @@ switch ($action) { |
71 | $content = optional_param('content', '', PARAM_RAW); | 71 | $content = optional_param('content', '', PARAM_RAW); |
72 | $timer = optional_param('notestime', '', PARAM_TEXT); | 72 | $timer = optional_param('notestime', '', PARAM_TEXT); |
73 | $activityUrl = optional_param('urllink', '', PARAM_TEXT); | 73 | $activityUrl = optional_param('urllink', '', PARAM_TEXT); |
74 | $activityname = optional_param('activity', '', PARAM_TEXT); | ||
74 | 75 | ||
75 | $manager = new block_mynotes_manager(); | 76 | $manager = new block_mynotes_manager(); |
76 | 77 | ||
77 | if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl)) { | 78 | if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl,$activityname)) { |
78 | $options = new stdClass(); | 79 | $options = new stdClass(); |
79 | $options->page = $page; | 80 | $options->page = $page; |
80 | $options->courseid = $course->id; | 81 | $options->courseid = $course->id; |
... | @@ -82,9 +83,10 @@ switch ($action) { | ... | @@ -82,9 +83,10 @@ switch ($action) { |
82 | $options->context = $context; | 83 | $options->context = $context; |
83 | $options->contextarea = $contextarea; | 84 | $options->contextarea = $contextarea; |
84 | // $options->notestime=$timer; | 85 | // $options->notestime=$timer; |
85 | unset($options->courseid); | 86 | // unset($options->courseid); |
86 | $count = $manager->count_mynotes($options); | 87 | $count = $manager->count_mynotes($options); |
87 | 88 | ||
89 | |||
88 | echo json_encode(array('notes' => array($note), 'count' => $count)); | 90 | echo json_encode(array('notes' => array($note), 'count' => $count)); |
89 | } else { | 91 | } else { |
90 | echo json_encode(array('error' => 'Unable to add note')); | 92 | echo json_encode(array('error' => 'Unable to add note')); | ... | ... |
notes_excel.php
0 → 100644
1 | <?php | ||
2 | require_once (dirname ( __FILE__ ) . '/../../config.php'); | ||
3 | require_once(dirname( __FILE__ ) .'/../../lib/phpexcel/PHPExcel.php'); | ||
4 | global $OUTPUT, $title; | ||
5 | |||
6 | require_login (); | ||
7 | $context = context_system::instance (); | ||
8 | $PAGE->set_context ( $context ); | ||
9 | |||
10 | function download_excel(){ | ||
11 | |||
12 | global $DB, $CFG,$USER , $PAGE; | ||
13 | |||
14 | $parameter = array ($USER->id); | ||
15 | $sql="select * from {block_mynotes} where userid=?"; | ||
16 | $allNotes = $DB->get_records_sql ( $sql, $parameter ); | ||
17 | |||
18 | $fullNotes = array (); | ||
19 | |||
20 | $i=0; | ||
21 | foreach ($allNotes as $notes ) { | ||
22 | $courseid=$notes->courseid; | ||
23 | |||
24 | $parameter = array ($courseid); | ||
25 | $sql="select fullname from {course} where id=?"; | ||
26 | $coursename = $DB->get_record_sql ( $sql, $parameter ); | ||
27 | |||
28 | |||
29 | |||
30 | $fullNotes [$i]['Sl.no']=$i+1; | ||
31 | $fullNotes [$i]['Course']=$coursename->fullname; | ||
32 | if($notes->activityname){ | ||
33 | $fullNotes [$i]['activityname']=$notes->activityname; | ||
34 | } | ||
35 | $fullNotes [$i]['Content']=$notes->content; | ||
36 | |||
37 | $time=date('d M Y H:i A (T)', $notes->timecreated); | ||
38 | $fullNotes [$i]['Timecreated']=$time; | ||
39 | $fullNotes [$i]['Videotime']=$notes->notestime; | ||
40 | $fullNotes [$i]['Notesurl']=$notes->notesurl; | ||
41 | |||
42 | $i=$i+1; | ||
43 | } | ||
44 | |||
45 | /* xls format | ||
46 | $fileName = "user_full_notes" . rand(1,100) . ".xls"; | ||
47 | |||
48 | if ($fullNotesssss){ | ||
49 | |||
50 | function filterData(&$str) { | ||
51 | $str = preg_replace("/\t/", "\\t", $str); | ||
52 | $str = preg_replace("/\r?\n/", "\\n", $str); | ||
53 | if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; | ||
54 | } | ||
55 | |||
56 | // headers for download | ||
57 | header("Content-Disposition: attachment; filename=\"$fileName\""); | ||
58 | header("Content-Type: application/vnd.ms-excel"); | ||
59 | |||
60 | $flag = false; | ||
61 | $i=0; | ||
62 | foreach($fullNotes as $row) { | ||
63 | |||
64 | if(!$flag) { | ||
65 | // display column names as first row | ||
66 | echo implode("\t", array_keys($row)) . "\n"; | ||
67 | |||
68 | $i=$i+1; | ||
69 | $flag = true; | ||
70 | } | ||
71 | // filter data | ||
72 | array_walk($row, 'filterData'); | ||
73 | echo implode("\t", array_values($row)) . "\n"; | ||
74 | } | ||
75 | exit; | ||
76 | } | ||
77 | */ | ||
78 | |||
79 | $name = "Student_notes"; | ||
80 | |||
81 | $objPHPExcel = new PHPExcel(); | ||
82 | $objPHPExcel->setActiveSheetIndex(0); | ||
83 | $objPHPExcel->getActiveSheet()->setTitle('Notes'); | ||
84 | |||
85 | $default_border = array( | ||
86 | 'style' => PHPExcel_Style_Border::BORDER_THIN, | ||
87 | 'color' => array('rgb'=>'9999ff') | ||
88 | ); | ||
89 | |||
90 | $style_header = array( | ||
91 | 'borders' => array( | ||
92 | 'bottom' => $default_border, | ||
93 | 'left' => $default_border, | ||
94 | 'top' => $default_border, | ||
95 | 'right' => $default_border, | ||
96 | ), | ||
97 | 'fill' => array( | ||
98 | 'type' => PHPExcel_Style_Fill::FILL_SOLID, | ||
99 | 'color' => array('rgb'=>'E1E0F7'), | ||
100 | ), | ||
101 | 'font' => array( | ||
102 | 'bold' => true, | ||
103 | ) | ||
104 | ); | ||
105 | |||
106 | |||
107 | $default_border1 = array( | ||
108 | 'style' => PHPExcel_Style_Border::BORDER_THIN, | ||
109 | 'color' => array('rgb'=>'ff9999') | ||
110 | ); | ||
111 | |||
112 | $style_header1 = array( | ||
113 | 'borders' => array( | ||
114 | 'bottom' => $default_border1, | ||
115 | 'left' => $default_border1, | ||
116 | 'top' => $default_border1, | ||
117 | 'right' => $default_border1, | ||
118 | ), | ||
119 | 'fill' => array( | ||
120 | 'type' => PHPExcel_Style_Fill::FILL_SOLID, | ||
121 | 'color' => array('rgb'=>'ff9999'), | ||
122 | ), | ||
123 | 'font' => array( | ||
124 | 'bold' => true, | ||
125 | ) | ||
126 | ); | ||
127 | |||
128 | $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5); | ||
129 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | ||
130 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30); | ||
131 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25); | ||
132 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25); | ||
133 | $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20); | ||
134 | $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50); | ||
135 | |||
136 | $objPHPExcel->getActiveSheet()->getCell("A1")->setValue("SL.No"); | ||
137 | $objPHPExcel->getActiveSheet()->getCell("A1")->getStyle('A1')->applyFromArray($style_header); | ||
138 | $objPHPExcel->getActiveSheet()->getCell("B1")->setValue("Course"); | ||
139 | $objPHPExcel->getActiveSheet()->getCell("B1")->getStyle('B1')->applyFromArray($style_header); | ||
140 | $objPHPExcel->getActiveSheet()->getCell("C1")->setValue("Activity"); | ||
141 | $objPHPExcel->getActiveSheet()->getCell("C1")->getStyle('C1')->applyFromArray($style_header); | ||
142 | $objPHPExcel->getActiveSheet()->getCell("D1")->setValue("Note"); | ||
143 | $objPHPExcel->getActiveSheet()->getCell("D1")->getStyle('D1')->applyFromArray($style_header); | ||
144 | $objPHPExcel->getActiveSheet()->getCell("E1")->setValue("Time Created"); | ||
145 | $objPHPExcel->getActiveSheet()->getCell("E1")->getStyle('E1')->applyFromArray($style_header); | ||
146 | $objPHPExcel->getActiveSheet()->getCell("F1")->setValue("Time in Clip"); | ||
147 | $objPHPExcel->getActiveSheet()->getCell("F1")->getStyle('F1')->applyFromArray($style_header); | ||
148 | $objPHPExcel->getActiveSheet()->getCell("G1")->setValue("URL"); | ||
149 | $objPHPExcel->getActiveSheet()->getCell("G1")->getStyle('G1')->applyFromArray($style_header); | ||
150 | |||
151 | |||
152 | for($i=1;$i<=count($fullNotes)+1;$i++){ | ||
153 | |||
154 | $objPHPExcel->getActiveSheet()->getCell('A'.($i+1))->setValue($i); | ||
155 | $objPHPExcel->getActiveSheet()->getCell('B'.($i+1))->setValue($fullNotes[$i-1]['Course']); | ||
156 | $objPHPExcel->getActiveSheet()->getCell('C'.($i+1))->setValue($fullNotes[$i-1]['activityname']); | ||
157 | $objPHPExcel->getActiveSheet()->getCell('D'.($i+1))->setValue($fullNotes[$i-1]['Content']); | ||
158 | $objPHPExcel->getActiveSheet()->getCell('E'.($i+1))->setValue($fullNotes[$i-1]['Timecreated']); | ||
159 | $objPHPExcel->getActiveSheet()->getCell('F'.($i+1))->setValue($fullNotes[$i-1]['Videotime']); | ||
160 | $objPHPExcel->getActiveSheet()->getCell('G'.($i+1))->setValue($fullNotes[$i-1]['Notesurl']); | ||
161 | |||
162 | } | ||
163 | |||
164 | $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); | ||
165 | $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); | ||
166 | ob_end_clean(); | ||
167 | |||
168 | header("Content-Disposition: attachment; filename=$name.xlsx"); | ||
169 | header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | ||
170 | $objWriter->save('php://output'); | ||
171 | exit(); | ||
172 | |||
173 | } | ||
174 | download_excel(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -26,14 +26,14 @@ defined('MOODLE_INTERNAL') || die; | ... | @@ -26,14 +26,14 @@ defined('MOODLE_INTERNAL') || die; |
26 | if ($ADMIN->fulltree) { | 26 | if ($ADMIN->fulltree) { |
27 | 27 | ||
28 | $perpageoptions = array(); | 28 | $perpageoptions = array(); |
29 | for ($i = 1; $i < 20; $i++) { | 29 | for ($i = 1; $i < 30; $i++) { |
30 | $perpageoptions[$i] = $i; | 30 | $perpageoptions[$i] = $i; |
31 | } | 31 | } |
32 | $settings->add(new admin_setting_configselect('block_mynotes/mynotesperpage', get_string('mynotesperpage', 'block_mynotes'), | 32 | $settings->add(new admin_setting_configselect('block_mynotes/mynotesperpage', get_string('mynotesperpage', 'block_mynotes'), |
33 | get_string('mynotesperpage_help', 'block_mynotes'), 5, $perpageoptions)); | 33 | get_string('mynotesperpage_help', 'block_mynotes'), 20, $perpageoptions)); |
34 | 34 | ||
35 | $settings->add(new admin_setting_configtext('block_mynotes/characterlimit', get_string('characterlimit', 'block_mynotes'), | 35 | $settings->add(new admin_setting_configtext('block_mynotes/characterlimit', get_string('characterlimit', 'block_mynotes'), |
36 | get_string('characterlimit_help', 'block_mynotes'), 180, PARAM_INT, 3)); | 36 | get_string('characterlimit_help', 'block_mynotes'), 450, PARAM_INT, 3)); |
37 | 37 | ||
38 | $positionoptions = array(); | 38 | $positionoptions = array(); |
39 | $positionoptions['mynotes-pos-rb'] = get_string('bottomright', 'block_mynotes'); | 39 | $positionoptions['mynotes-pos-rb'] = get_string('bottomright', 'block_mynotes'); | ... | ... |
1 | #mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; } | 1 | #mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; } |
2 | div.mdl-align { min-height: 470px;} | 2 | div.mdl-align { min-height: 470px;} |
3 | #mynote-edit{position: absolute !important;right: 0 !important; margin: 0px 20px !important;} | 3 | #mynote-edit{display:none;position: absolute;right: 0; margin: 0 28px;} |
4 | #mynote-update{position: absolute !important; right: 0 !important; margin:0px 40px !important;} | 4 | #mynote-update{visibility: hidden;position: absolute !important; right: 0 !important; margin:0px 40px !important;} |
5 | #notes_edit_option{color: #2310c3 !important;} | 5 | #notes_edit_option{color: #2310c3 !important;} |
6 | .mdl-align { padding:inherit !important; } | 6 | .mdl-align { padding:inherit !important; } |
7 | .mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; } | 7 | .mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; } |
... | @@ -26,9 +26,9 @@ div.mdl-align { min-height: 470px;} | ... | @@ -26,9 +26,9 @@ div.mdl-align { min-height: 470px;} |
26 | .mynotes_base input[type="submit"], .mynotes_base input[type="submit"]:hover { margin: 0; padding: 3px 10px; border: none; background: #63ab36; color: #fff; } | 26 | .mynotes_base input[type="submit"], .mynotes_base input[type="submit"]:hover { margin: 0; padding: 3px 10px; border: none; background: #63ab36; color: #fff; } |
27 | .mynotes_base input[type="submit"][disabled="disabled"]:hover { background: #63ab36; cursor: not-allowed; } | 27 | .mynotes_base input[type="submit"][disabled="disabled"]:hover { background: #63ab36; cursor: not-allowed; } |
28 | .mynotes_base span.warning { color: #bd3c2f; margin-left: 15px; } | 28 | .mynotes_base span.warning { color: #bd3c2f; margin-left: 15px; } |
29 | .mynotes_base .responsetext { color: #33b733; line-height: 20px; } | 29 | .mynotes_base .responsetext { color: #33b733; line-height: 15px; } |
30 | .mynotes_base .tabs-menu { height: 30px; float: left; clear: both; margin-bottom: 1px; } | 30 | .mynotes_base .tabs-menu { height: 30px; float: left; clear: both; margin-bottom: 1px; } |
31 | .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; } | 31 | .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; } |
32 | .mynotes_base .tabs-menu li:first-child { border-radius: 7px 0 0 0; } | 32 | .mynotes_base .tabs-menu li:first-child { border-radius: 7px 0 0 0; } |
33 | .mynotes_base .tabs-menu li:last-child { border-radius: 0 7px 0 0; } | 33 | .mynotes_base .tabs-menu li:last-child { border-radius: 0 7px 0 0; } |
34 | .mynotes_base .tabs-menu li.current { position: relative; background-color: #ffe6a4; border-bottom: 1px solid #fff; z-index: 5; border-bottom: 2px solid #ffe6a4; } | 34 | .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;} | ... | @@ -39,16 +39,103 @@ div.mdl-align { min-height: 470px;} |
39 | 39 | ||
40 | .mynotes_base .tab { border: 1px solid #d4d4d1; clear: both; width: auto; background: #f7f7f4; } | 40 | .mynotes_base .tab { border: 1px solid #d4d4d1; clear: both; width: auto; background: #f7f7f4; } |
41 | .mynotes_base .tab .tab-content { display: none; } | 41 | .mynotes_base .tab .tab-content { display: none; } |
42 | .mynotes_base .tab .tab-content .notes-info { background: #ffe6a4; padding: 5px; position: relative; } | 42 | .mynotes_base .tab .tab-content .notes-info { background: #ffe6a4; padding: 3px; position: relative; } |
43 | .mynotes_base .tab .tab-content .notes-info .count { color: #000; } | 43 | .mynotes_base .tab .tab-content .notes-info .count { color: #000; } |
44 | .mynotes_base .tab .tab-content .notes-info .mynotes-paging { position: absolute; right: 0; } | 44 | .mynotes_base .tab .tab-content .notes-info .mynotes-paging { position: absolute; right: 0;} |
45 | .mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging a { margin: 5px; background: #c1621e; padding: 4px 10px; border-radius: 15px; color: #fff; } | 45 | .mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging a { margin: 5px; background: #c1621e; padding: 1px 3px; border-radius: 15px; color: #fff; } |
46 | .mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging .separator { border-left: 1px solid gray; } | 46 | .mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging .separator { border-left: 1px solid gray; } |
47 | .mynotes_base .tab .tab-content ul.mynotes_lists { margin:0; clear: both; } | 47 | .mynotes_base .tab .tab-content ul.mynotes_lists {overflow: scroll; height: 250px; margin:0; clear: both; } |
48 | .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; } | 48 | .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; } |
49 | .mynotes_base .tab .tab-content ul.mynotes_lists li .content { margin-right: 10px; word-wrap: break-word; } | 49 | .mynotes_base .tab .tab-content ul.mynotes_lists li .content { margin-right: 10px; word-wrap: break-word; } |
50 | .mynotes_base .tab .tab-content ul.mynotes_lists li .note-detail { display: inline-block; font-size: 11px; } | 50 | .mynotes_base .tab .tab-content ul.mynotes_lists li .note-detail { display: inline-block; font-size: 11px; } |
51 | .mynotes_base .tab .tab-content ul.mynotes_lists li .time { color: #888; font-style: italic; display: inline-block; margin-left: 5px; font-size: 11px; } | 51 | .mynotes_base .tab .tab-content ul.mynotes_lists li .time { color: #888; font-style: italic; display: inline-block; margin-left: 5px; font-size: 11px; } |
52 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { position: absolute; right: 0; margin:0 -1px; } | 52 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { display:none;position: absolute; right: 1px; margin:0px -1px; } |
53 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb; } | 53 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb;} |
54 | 54 | ||
55 | ul#mynotes_user-list{ | ||
56 | padding-left: 0rem !important; | ||
57 | } | ||
58 | /* Overridden style for positioning the notes box */ | ||
59 | .moodle-dialogue-wrap.moodle-dialogue-content.yui3-widget-stdmod{ | ||
60 | position: fixed !important; | ||
61 | left: 1035px!important; | ||
62 | width: 300px !important; | ||
63 | top: 70px !important; | ||
64 | } | ||
65 | :focus{ | ||
66 | outline: -webkit-focus-ring-color auto 0px !important; | ||
67 | } | ||
68 | #notes_edit_option{ | ||
69 | |||
70 | outline: -webkit-focus-ring-color auto 2px !important; | ||
71 | |||
72 | } | ||
73 | |||
74 | |||
75 | |||
76 | .notes_overview { | ||
77 | /* | ||
78 | overflow-x: hidden; | ||
79 | overflow-y: scroll; | ||
80 | height: 270px; */ | ||
81 | } | ||
82 | .notes_overview { | ||
83 | background-color: #f7f7f7; | ||
84 | width: 100%; | ||
85 | height: 2em; | ||
86 | padding: 9px 6px 0; | ||
87 | |||
88 | /* | ||
89 | overflow-x: hidden; | ||
90 | overflow-y: scroll; | ||
91 | height: 270px; */ | ||
92 | } | ||
93 | |||
94 | #notes-slider { | ||
95 | /* left: 3px; | ||
96 | top: 43px; */ | ||
97 | } | ||
98 | |||
99 | .notes_section { | ||
100 | padding: 4px 0px 4px 1px; | ||
101 | } | ||
102 | |||
103 | #course_name { | ||
104 | /* padding: 4px 0px 0px 8px; | ||
105 | font-size: 19px; | ||
106 | color: black; */ | ||
107 | } | ||
108 | |||
109 | .notes_course { | ||
110 | background-color: #dddddd; | ||
111 | width: 100%; | ||
112 | height: 2em; | ||
113 | padding: 9px 6px 0; | ||
114 | padding: 4px 0px 0px 8px; | ||
115 | font-size: 19px; | ||
116 | color: black; | ||
117 | } | ||
118 | |||
119 | .notes_data { | ||
120 | /* background-color: #f7f7f7; | ||
121 | width: 100%; */ | ||
122 | border: 2px solid #fff; | ||
123 | text-align: left; | ||
124 | padding: 8px; | ||
125 | } | ||
126 | |||
127 | #delete_icon.fa.fa-trash{ | ||
128 | margin-right: 20em; | ||
129 | text-decoration: underline; | ||
130 | |||
131 | } | ||
132 | #edit_icon.far.fa-edit{ | ||
133 | margin-right: 25em; | ||
134 | text-decoration: underline; | ||
135 | } | ||
136 | /* .page-header{ | ||
137 | margin-top: 2em !important; | ||
138 | } | ||
139 | .page-title { | ||
140 | margin-top: inherit !important; | ||
141 | } */ | ... | ... |
timerajax.php
deleted
100644 → 0
1 | <?php | ||
2 | require_once('/../../config.php'); | ||
3 | // require_once($CFG->dirroot.'/user/profile/lib.php'); | ||
4 | // require_once($CFG->dirroot.'/course/lib.php'); | ||
5 | require_once($CFG->dirroot . '/blocks/mynotes/lib.php'); | ||
6 | global $USER,$DB; | ||
7 | |||
8 | // if (!isloggedin()) { | ||
9 | // echo json_encode(array('error' => 'require_login')); | ||
10 | // die(); | ||
11 | // } | ||
12 | |||
13 | $timertext = optional_param('notestime', '', PARAM_TEXT); | ||
14 | |||
15 | // $myuser=profile_user_record($USER->id); | ||
16 | |||
17 | if ($timertext){ | ||
18 | |||
19 | echo $timertext; | ||
20 | |||
21 | } | ||
22 | else{ | ||
23 | |||
24 | echo "value fromrhere"; | ||
25 | } |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | 23 | ||
24 | defined('MOODLE_INTERNAL') || die(); | 24 | defined('MOODLE_INTERNAL') || die(); |
25 | 25 | ||
26 | $plugin->version = 2018011202; // The current plugin version (Date: YYYYMMDDXX) | 26 | $plugin->version = 2018011203; // The current plugin version (Date: YYYYMMDDXX) |
27 | $plugin->requires = 2015050500; // Requires this Moodle version | 27 | $plugin->requires = 2015050500; // Requires this Moodle version |
28 | $plugin->component = 'block_mynotes'; // Full name of the plugin (used for diagnostics) | 28 | $plugin->component = 'block_mynotes'; // Full name of the plugin (used for diagnostics) |
29 | $plugin->release = 'V3.4 r1'; | 29 | $plugin->release = 'V3.4 r1'; | ... | ... |
view.php
0 → 100644
1 | <?php | ||
2 | require_once (dirname ( __FILE__ ) . '/../../config.php'); | ||
3 | // require_once (dirname ( __FILE__ ) . '/leaderboard_data.php'); | ||
4 | // require_once ($CFG->dirroot . '/user/profile/lib.php'); | ||
5 | global $OUTPUT, $title; | ||
6 | |||
7 | require_login (); | ||
8 | $context = context_system::instance (); | ||
9 | $PAGE->set_context ( $context ); | ||
10 | |||
11 | |||
12 | |||
13 | // $PAGE->requires->css ( '/blocks/leaders/css/style.css' ); | ||
14 | |||
15 | $PAGE->set_pagelayout( 'standard' ); | ||
16 | $PAGE->set_title ( "Notes" ); | ||
17 | $PAGE->requires->css ( '/blocks/mynotes/style.css' ); | ||
18 | $PAGE->set_url ( '/blocks/mynotes/view.php' ); | ||
19 | $PAGE->set_heading ( "User Notes" ); | ||
20 | $PAGE->navbar->add ( 'Notes', new moodle_url ( '/blocks/mynotes/view.php' ) ); | ||
21 | $PAGE->requires->js_call_amd ( 'block_mynotes/script', 'init' ); | ||
22 | echo $OUTPUT->header (); | ||
23 | |||
24 | class notes{ | ||
25 | |||
26 | public function allnotes(){ | ||
27 | global $DB, $CFG,$USER , $PAGE; | ||
28 | |||
29 | $parameter = array ($USER->id); | ||
30 | $sql = "select * from {block_mynotes} where userid=? order by courseid asc"; | ||
31 | $allNotes = $DB->get_records_sql ( $sql, $parameter ); | ||
32 | |||
33 | $sql="select distinct courseid from {block_mynotes} where userid=? order by courseid asc"; | ||
34 | $allCourses=$DB->get_records_sql ( $sql, $parameter ); | ||
35 | |||
36 | $fullNotes = array (); | ||
37 | |||
38 | foreach ( $allNotes as $notes ) { | ||
39 | |||
40 | $fullNotes [] = $notes; | ||
41 | } | ||
42 | |||
43 | $fullCourseIds = array (); | ||
44 | foreach ( $allCourses as $courseId ) { | ||
45 | |||
46 | $fullCourseIds [] = $courseId; | ||
47 | } | ||
48 | //full notes list | ||
49 | $noteslist = array (); | ||
50 | for($i = 0; $i < count ( $fullCourseIds ); $i ++) { | ||
51 | |||
52 | foreach ( $fullNotes as $notes ) { | ||
53 | if ($fullCourseIds [$i]->courseid == $notes->courseid) { | ||
54 | |||
55 | $noteslist [$i] [] = $notes; | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | //coursenames | ||
60 | $courseName = array (); | ||
61 | |||
62 | foreach ( $fullCourseIds as $courseId ) { | ||
63 | $param = array ( | ||
64 | $courseId->courseid | ||
65 | ); | ||
66 | $sql = "select fullname from {course} where id=?"; | ||
67 | $name = $DB->get_record_sql ( $sql, $param ); | ||
68 | if ($courseId->courseid == 1) { | ||
69 | |||
70 | $courseName [] = 'Dashboard Notes'; | ||
71 | } else { | ||
72 | |||
73 | $courseName [] = $name->fullname; | ||
74 | } | ||
75 | } | ||
76 | return array($fullCourseIds,$noteslist,$courseName); | ||
77 | |||
78 | |||
79 | } | ||
80 | |||
81 | |||
82 | public function viewNotes(){ | ||
83 | global $DB ,$CFG ,$USER ,$PAGE; | ||
84 | |||
85 | |||
86 | $getallnotes = new notes (); | ||
87 | $Allnotes=$getallnotes->allnotes(); | ||
88 | |||
89 | $CourseIds=$Allnotes[0]; | ||
90 | $noteslist=$Allnotes[1]; | ||
91 | $courseNameList=$Allnotes[2]; | ||
92 | |||
93 | if(!empty($noteslist)){ | ||
94 | |||
95 | |||
96 | echo '<a href="'.$CFG->wwwroot.'/blocks/mynotes/notes_excel.php" id="excel_download" class="float-md-right" style="text-decoration: none;">Downlaod Notes</a>'; | ||
97 | |||
98 | |||
99 | for ($i=0;$i<count($courseNameList);$i++){ | ||
100 | echo ('<div class="notes_section" id="'.$CourseIds[$i]->courseid.'"> | ||
101 | <a href="#" class="notes_course fa fa-chevron-circle-right" id="icon'.$CourseIds[$i]->courseid.'" style="text-decoration: none;" > | ||
102 | '.' '.$courseNameList[$i].'</a></div> | ||
103 | <table class="notes_overview" id="notes_table_id'.$CourseIds[$i]->courseid.'">'); | ||
104 | |||
105 | for ($j=0;$j<count($noteslist[$i]);$j++){ | ||
106 | |||
107 | echo ('<tr class="overall_notes" id="notes'.$noteslist[$i][$j]->id.'"> | ||
108 | <td class="notes_data"> | ||
109 | <a href="#" class=" delete_note float-right mr-1 fa fa-trash" id="'.$noteslist[$i][$j]->id.'" style="text-decoration: none;" >delete</a> | ||
110 | <a href="#" class=" edit_note float-right mr-5 far fa-edit" id="'.$noteslist[$i][$j]->id.'" style="text-decoration: none;">edit</a> | ||
111 | <p id="notes_content'.$noteslist[$i][$j]->id.'">'.$noteslist[$i][$j]->content.'</p> | ||
112 | |||
113 | </td></tr>'); | ||
114 | |||
115 | } | ||
116 | echo '</table>'; | ||
117 | |||
118 | } | ||
119 | /* <i class="fa fa-trash" aria-hidden="true">delete</i> */ | ||
120 | |||
121 | }else{ | ||
122 | echo '<div class="alert alert-danger"> | ||
123 | <strong> User notes are empty!</strong> User notes are not availale to display. Please make note while working with activities to view all notes. | ||
124 | </div>'; | ||
125 | |||
126 | |||
127 | |||
128 | } | ||
129 | |||
130 | } | ||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | |||
138 | } | ||
139 | |||
140 | $viewnotes = new notes (); | ||
141 | $viewnotes->viewNotes (); | ||
142 | |||
143 | |||
144 | echo $OUTPUT->footer (); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment