4153cb06 by logesh

dev: final changes in notes

1 parent 89341b62
...@@ -24,11 +24,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -24,11 +24,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
24 var mynotes = { 24 var mynotes = {
25 getMynotesValidatedUrl: function(baseurl) { 25 getMynotesValidatedUrl: function(baseurl) {
26 26
27
27 var a = document.createElement('a'); 28 var a = document.createElement('a');
28 a.href = baseurl; 29 a.href = baseurl;
29 return (a.search.length > 0) ? baseurl : baseurl + '?'; 30 return (a.search.length > 0) ? baseurl : baseurl + '?';
30 }, 31 },
31 getWarnings: function(status) { 32 getWarnings: function(status) {
33
34
32 if (status == false) { 35 if (status == false) {
33 $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(CONFIG.maxallowedcharacters_warning); 36 $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(CONFIG.maxallowedcharacters_warning);
34 } else { 37 } else {
...@@ -72,6 +75,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -72,6 +75,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
72 } 75 }
73 }, 76 },
74 request: function(args) { 77 request: function(args) {
78
75 var params = {}; 79 var params = {};
76 var scope = this; 80 var scope = this;
77 81
...@@ -136,6 +140,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -136,6 +140,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
136 }, 140 },
137 saveMynotes: function(e) { 141 saveMynotes: function(e) {
138 142
143
139 var result=''; 144 var result='';
140 145
141 e.preventDefault(); 146 e.preventDefault();
...@@ -146,35 +151,40 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -146,35 +151,40 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
146 151
147 var url= $(location).attr('href'); 152 var url= $(location).attr('href');
148 153
154
155 if (url.match(/resume/)) {
156
157 var n = url.indexOf('?resume');
158 url = url.substring(0, n != -1 ? n : url.length);
159
160 }
161
149 if(url.includes('/mod/page/view.php')){ 162 if(url.includes('/mod/page/view.php')){
150 //notes player timer starts 163 //notes player timer starts
151 var iframe = document.querySelector('iframe'); 164 var iframe = document.querySelector('iframe');
152 var player = new Vimeo.Player(iframe); 165 var player = new Vimeo.Player(iframe);
153 166
154 player.pause(); 167 player.pause();
155 168
156 player.getCurrentTime().then(function(seconds) { 169 player.getCurrentTime().then(function(seconds) {
157 170
158 var str = "</br>You have taken notes at "; 171 var timenotes=seconds;
159 str +=seconds;
160 str +=" in this video."
161 result = str.fontcolor("green");
162
163 172
164 var ta = $('#id_mynotecontent-' + CONFIG.instanceid); 173 var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
165 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { 174 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
166 return false; 175 return false;
167 } 176 }
177
168 var arg = { 178 var arg = {
169 contextid: CONFIG.contextid, 179 contextid: CONFIG.contextid,
170 content: ta.val(), 180 content: ta.val(),
171 action: 'add', 181 action: 'add',
172 contextarea: scope.currenttabindex, 182 contextarea: scope.currenttabindex,
173 notestime:result, 183 notestime:timenotes,
174 184 urllink:url,
175 185
176 }; 186 };
177 187
178 ta.attr('disabled', true); 188 ta.attr('disabled', true);
179 ta.css({ 189 ta.css({
180 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', 190 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')',
...@@ -185,6 +195,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -185,6 +195,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
185 scope.request({ 195 scope.request({
186 params: arg, 196 params: arg,
187 callback: function(id, ret, args) { 197 callback: function(id, ret, args) {
198
188 if (!ret.notes) { 199 if (!ret.notes) {
189 return false; 200 return false;
190 } 201 }
...@@ -215,22 +226,22 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -215,22 +226,22 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
215 226
216 } 227 }
217 else{ 228 else{
218
219
220 var ta = $('#id_mynotecontent-' + CONFIG.instanceid); 229 var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
221 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { 230 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
222 return false; 231 return false;
223 } 232 }
233
224 var arg = { 234 var arg = {
225 contextid: CONFIG.contextid, 235 contextid: CONFIG.contextid,
226 content: ta.val(), 236 content: ta.val(),
227 action: 'add', 237 action: 'add',
228 contextarea: scope.currenttabindex, 238 contextarea: scope.currenttabindex,
229 notestime:result, 239 notestime:result,
240 urllink:url,
230 241
231 242
232 }; 243 };
233 244
234 ta.attr('disabled', true); 245 ta.attr('disabled', true);
235 ta.css({ 246 ta.css({
236 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', 247 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')',
...@@ -286,6 +297,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -286,6 +297,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
286 $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count); 297 $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count);
287 }, 298 },
288 getMynotes: function(page = 0) { 299 getMynotes: function(page = 0) {
300
289 var scope = this; 301 var scope = this;
290 page = parseInt(page); 302 page = parseInt(page);
291 303
...@@ -313,7 +325,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -313,7 +325,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
313 }); 325 });
314 }, 326 },
315 updateMynotesInfo: function(mynotescount, page) { 327 updateMynotesInfo: function(mynotescount, page) {
316 console.log(mynotescount); 328
317 page = parseInt(page); 329 page = parseInt(page);
318 mynotescount = parseInt(mynotescount); 330 mynotescount = parseInt(mynotescount);
319 var scope = this; 331 var scope = this;
...@@ -355,21 +367,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -355,21 +367,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
355 noteinfo.find('.mynotes-paging').html(paging); 367 noteinfo.find('.mynotes-paging').html(paging);
356 }, 368 },
357 renderMynotes: function(notes) { 369 renderMynotes: function(notes) {
370
358 if (notes.length < 1) { 371 if (notes.length < 1) {
359 return false; 372 return false;
360 } 373 }
361 var lists = ''; 374 var lists = '';
362 var x = ''; 375 var x = '';
363 for (x in notes) { 376 for (x in notes) {
377
378
364 $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); 379 $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove();
365 var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; 380 var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>';
366 var notedetail = ''; 381 var notedetail = '';
382
367 if (notes[x].coursename != '') { 383 if (notes[x].coursename != '') {
368 notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; 384 notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>';
369 } 385 }
386
370 var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; 387 var userdate = '<div class="time">' + notes[x].timecreated + '</div>';
388
389 var mynotestime='';
390 if (notes[x].notestime != ''){
391 mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>';
392
393 }
394
371 var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>'; 395 var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>';
372 lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + '</li>'; 396 lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>';
373 } 397 }
374 return lists; 398 return lists;
375 }, 399 },
...@@ -402,6 +426,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -402,6 +426,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
402 scope.updateMynotesInfo(mynotescount, page); 426 scope.updateMynotesInfo(mynotescount, page);
403 }, 427 },
404 registerActions: function() { 428 registerActions: function() {
429
405 var scope = this; 430 var scope = this;
406 $('body').delegate('#addmynote_cancel', 'click', function() { 431 $('body').delegate('#addmynote_cancel', 'click', function() {
407 panel.hide() 432 panel.hide()
......
...@@ -24,11 +24,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -24,11 +24,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
24 var mynotes = { 24 var mynotes = {
25 getMynotesValidatedUrl: function(baseurl) { 25 getMynotesValidatedUrl: function(baseurl) {
26 26
27
27 var a = document.createElement('a'); 28 var a = document.createElement('a');
28 a.href = baseurl; 29 a.href = baseurl;
29 return (a.search.length > 0) ? baseurl : baseurl + '?'; 30 return (a.search.length > 0) ? baseurl : baseurl + '?';
30 }, 31 },
31 getWarnings: function(status) { 32 getWarnings: function(status) {
33
34
32 if (status == false) { 35 if (status == false) {
33 $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(CONFIG.maxallowedcharacters_warning); 36 $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(CONFIG.maxallowedcharacters_warning);
34 } else { 37 } else {
...@@ -72,6 +75,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -72,6 +75,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
72 } 75 }
73 }, 76 },
74 request: function(args) { 77 request: function(args) {
78
75 var params = {}; 79 var params = {};
76 var scope = this; 80 var scope = this;
77 81
...@@ -136,6 +140,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -136,6 +140,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
136 }, 140 },
137 saveMynotes: function(e) { 141 saveMynotes: function(e) {
138 142
143
139 var result=''; 144 var result='';
140 145
141 e.preventDefault(); 146 e.preventDefault();
...@@ -146,35 +151,40 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -146,35 +151,40 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
146 151
147 var url= $(location).attr('href'); 152 var url= $(location).attr('href');
148 153
154
155 if (url.match(/resume/)) {
156
157 var n = url.indexOf('?resume');
158 url = url.substring(0, n != -1 ? n : url.length);
159
160 }
161
149 if(url.includes('/mod/page/view.php')){ 162 if(url.includes('/mod/page/view.php')){
150 //notes player timer starts 163 //notes player timer starts
151 var iframe = document.querySelector('iframe'); 164 var iframe = document.querySelector('iframe');
152 var player = new Vimeo.Player(iframe); 165 var player = new Vimeo.Player(iframe);
153 166
154 player.pause(); 167 player.pause();
155 168
156 player.getCurrentTime().then(function(seconds) { 169 player.getCurrentTime().then(function(seconds) {
157 170
158 var str = "</br>You have taken notes at "; 171 var timenotes=seconds;
159 str +=seconds;
160 str +=" in this video."
161 result = str.fontcolor("green");
162
163 172
164 var ta = $('#id_mynotecontent-' + CONFIG.instanceid); 173 var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
165 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { 174 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
166 return false; 175 return false;
167 } 176 }
177
168 var arg = { 178 var arg = {
169 contextid: CONFIG.contextid, 179 contextid: CONFIG.contextid,
170 content: ta.val(), 180 content: ta.val(),
171 action: 'add', 181 action: 'add',
172 contextarea: scope.currenttabindex, 182 contextarea: scope.currenttabindex,
173 notestime:result, 183 notestime:timenotes,
174 184 urllink:url,
175 185
176 }; 186 };
177 187
178 ta.attr('disabled', true); 188 ta.attr('disabled', true);
179 ta.css({ 189 ta.css({
180 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', 190 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')',
...@@ -185,6 +195,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -185,6 +195,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
185 scope.request({ 195 scope.request({
186 params: arg, 196 params: arg,
187 callback: function(id, ret, args) { 197 callback: function(id, ret, args) {
198
188 if (!ret.notes) { 199 if (!ret.notes) {
189 return false; 200 return false;
190 } 201 }
...@@ -215,22 +226,22 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -215,22 +226,22 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
215 226
216 } 227 }
217 else{ 228 else{
218
219
220 var ta = $('#id_mynotecontent-' + CONFIG.instanceid); 229 var ta = $('#id_mynotecontent-' + CONFIG.instanceid);
221 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { 230 if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) {
222 return false; 231 return false;
223 } 232 }
233
224 var arg = { 234 var arg = {
225 contextid: CONFIG.contextid, 235 contextid: CONFIG.contextid,
226 content: ta.val(), 236 content: ta.val(),
227 action: 'add', 237 action: 'add',
228 contextarea: scope.currenttabindex, 238 contextarea: scope.currenttabindex,
229 notestime:result, 239 notestime:result,
240 urllink:url,
230 241
231 242
232 }; 243 };
233 244
234 ta.attr('disabled', true); 245 ta.attr('disabled', true);
235 ta.css({ 246 ta.css({
236 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', 247 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')',
...@@ -286,6 +297,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -286,6 +297,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
286 $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count); 297 $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count', notesobj.count);
287 }, 298 },
288 getMynotes: function(page = 0) { 299 getMynotes: function(page = 0) {
300
289 var scope = this; 301 var scope = this;
290 page = parseInt(page); 302 page = parseInt(page);
291 303
...@@ -307,7 +319,6 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -307,7 +319,6 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
307 this.request({ 319 this.request({
308 params: arg, 320 params: arg,
309 callback: function(id, ret, args) { 321 callback: function(id, ret, args) {
310
311 scope.addToList(ret); 322 scope.addToList(ret);
312 scope.displayMynotes(); 323 scope.displayMynotes();
313 } 324 }
...@@ -356,21 +367,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -356,21 +367,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
356 noteinfo.find('.mynotes-paging').html(paging); 367 noteinfo.find('.mynotes-paging').html(paging);
357 }, 368 },
358 renderMynotes: function(notes) { 369 renderMynotes: function(notes) {
370
359 if (notes.length < 1) { 371 if (notes.length < 1) {
360 return false; 372 return false;
361 } 373 }
362 var lists = ''; 374 var lists = '';
363 var x = ''; 375 var x = '';
364 for (x in notes) { 376 for (x in notes) {
377
378
365 $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); 379 $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove();
366 var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; 380 var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>';
367 var notedetail = ''; 381 var notedetail = '';
382
368 if (notes[x].coursename != '') { 383 if (notes[x].coursename != '') {
369 notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; 384 notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>';
370 } 385 }
386
371 var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; 387 var userdate = '<div class="time">' + notes[x].timecreated + '</div>';
388
389 var mynotestime='';
390 if (notes[x].notestime != ''){
391 mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>';
392
393 }
394
372 var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>'; 395 var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>';
373 lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + '</li>'; 396 lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>';
374 } 397 }
375 return lists; 398 return lists;
376 }, 399 },
...@@ -403,6 +426,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f ...@@ -403,6 +426,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f
403 scope.updateMynotesInfo(mynotescount, page); 426 scope.updateMynotesInfo(mynotescount, page);
404 }, 427 },
405 registerActions: function() { 428 registerActions: function() {
429
406 var scope = this; 430 var scope = this;
407 $('body').delegate('#addmynote_cancel', 'click', function() { 431 $('body').delegate('#addmynote_cancel', 'click', function() {
408 panel.hide() 432 panel.hide()
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
14 <FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/> 14 <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"/> 15 <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
16 <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> 16 <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
17 <FIELD NAME="notestime" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
18 <FIELD NAME="notesurl" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
17 </FIELDS> 19 </FIELDS>
18 <KEYS> 20 <KEYS>
19 <KEY NAME="primary" TYPE="primary" FIELDS="id"/> 21 <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
1 <?php
2
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18 /**
19 * @package qharvest
20 * @author Tekstac Development Team <teknoturf.com>
21 */
22
23 //upgrade.php file for hte harvest question
24
25
26 defined( 'MOODLE_INTERNAL' ) || die();
27 function xmldb_block_mynotes_upgrade($oldversion) {
28
29 global $CFG, $DB;
30
31 $dbman = $DB->get_manager();
32
33 //Upgrade to add an extra column to local_qharvest_qns_count table
34 if( $oldversion < 2018011201 ){
35
36 $table = new xmldb_table('block_mynotes');
37
38 if ( $dbman->table_exists($table) ) {
39 $dbman->drop_table($table);
40 }
41
42 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
43 $table->add_field('contextid',XMLDB_TYPE_INTEGER,'10', 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);
46 $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
47 $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('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
50 $table->add_field('notestime', XMLDB_TYPE_CHAR, '255', null, null, null, null);
51 $table->add_field('notesurl', XMLDB_TYPE_CHAR, '255', null, null, null, null);
52
53 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
54 $dbman->create_table($table);
55 }
56
57
58 return true;
59 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -70,7 +70,7 @@ class block_mynotes_manager { ...@@ -70,7 +70,7 @@ class block_mynotes_manager {
70 } 70 }
71 $sql = "SELECT $ufields, 71 $sql = "SELECT $ufields,
72 m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat, 72 m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat,
73 m.timecreated AS timecreated,m.notestime AS notestime, c.fullname as coursename, m.courseid 73 m.timecreated AS timecreated,m.notestime AS notestime,m.notesurl AS notesurl, c.fullname as coursename, m.courseid
74 FROM {block_mynotes} m 74 FROM {block_mynotes} m
75 JOIN {user} u ON u.id = m.userid 75 JOIN {user} u ON u.id = m.userid
76 LEFT JOIN {course} c ON c.id = m.courseid 76 LEFT JOIN {course} c ON c.id = m.courseid
...@@ -86,7 +86,8 @@ class block_mynotes_manager { ...@@ -86,7 +86,8 @@ 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 $c->coursename = html_writer::link($u->notesurl, $u->coursename);
90 } else { 91 } else {
91 $c->coursename = ''; 92 $c->coursename = '';
92 } 93 }
...@@ -100,6 +101,12 @@ class block_mynotes_manager { ...@@ -100,6 +101,12 @@ class block_mynotes_manager {
100 } else { 101 } else {
101 $c->notestime = ''; 102 $c->notestime = '';
102 } 103 }
104
105 if (!empty($u->notesurl)) {
106 $c->notesurl = $u->notesurl;
107 } else {
108 $c->notesurl = '';
109 }
103 // $c->notestime = $u->notestime; 110 // $c->notestime = $u->notestime;
104 $c->content = format_text($c->content, $c->format, $formatoptions); 111 $c->content = format_text($c->content, $c->format, $formatoptions);
105 $c->delete = true; 112 $c->delete = true;
...@@ -189,9 +196,10 @@ class block_mynotes_manager { ...@@ -189,9 +196,10 @@ class block_mynotes_manager {
189 * 196 *
190 * @return object of single mynote record if insert to DB else false 197 * @return object of single mynote record if insert to DB else false
191 */ 198 */
192 public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) { 199 public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl, $format = FORMAT_MOODLE) {
193 global $CFG, $DB, $USER, $OUTPUT; 200 global $CFG, $DB, $USER, $OUTPUT;
194 // $content=$content.$timer; 201 // $content=$content.$timer;
202
195 $newnote = new stdClass; 203 $newnote = new stdClass;
196 $newnote->contextid = $context->id; 204 $newnote->contextid = $context->id;
197 $newnote->contextarea = $contextarea; 205 $newnote->contextarea = $contextarea;
...@@ -201,15 +209,25 @@ class block_mynotes_manager { ...@@ -201,15 +209,25 @@ class block_mynotes_manager {
201 $newnote->userid = $USER->id; 209 $newnote->userid = $USER->id;
202 $newnote->timecreated = time(); 210 $newnote->timecreated = time();
203 $newnote->notestime=$timer; 211 $newnote->notestime=$timer;
212 if (!empty($timer)){
213 $newnote->notesurl=$activityUrl.'?resume='.$newnote->notestime;
214 }else{
215 $newnote->notesurl=$activityUrl.'?resume=0';
216 }
204 217
205 if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) { 218 if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) {
206 $newnote->id = $cmtid; 219 $newnote->id = $cmtid;
207 $newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true)); 220 $newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true));
208 $newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig')); 221 $newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig'));
209 $newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname; 222 $newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname;
210 $newnote->notestime = ($newnote->notestime) ? '' : $newnote->notestime; 223 $newnote->notestime = $newnote->notestime;
224 $newnote->notesurl = $newnote->notesurl;
211 if (!empty($newnote->coursename)) { 225 if (!empty($newnote->coursename)) {
212 $newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename); 226
227 $newnote->coursename = html_writer::link($newnote->notesurl, $newnote->coursename);
228
229 // $newnote->coursename = html_writer::link($newnote->notesurl.'?notestime='.$timer, $newnote->coursename);
230 // $newnote->coursename=$newnote->notesurl.'?notestime='.$timer,$newnote->coursename;
213 } 231 }
214 return $newnote; 232 return $newnote;
215 } else { 233 } else {
......
...@@ -63,20 +63,23 @@ $config = get_config('block_mynotes'); ...@@ -63,20 +63,23 @@ $config = get_config('block_mynotes');
63 echo $OUTPUT->header(); //...send headers 63 echo $OUTPUT->header(); //...send headers
64 // process ajax request 64 // process ajax request
65 65
66
66 switch ($action) { 67 switch ($action) {
67 case 'add': 68 case 'add':
68 $content = optional_param('content', '', PARAM_RAW); 69 $content = optional_param('content', '', PARAM_RAW);
69 $timer = optional_param('notestime', '', PARAM_TEXT); 70 $timer = optional_param('notestime', '', PARAM_TEXT);
71 $activityUrl = optional_param('urllink', '', PARAM_TEXT);
70 72
71 $manager = new block_mynotes_manager(); 73 $manager = new block_mynotes_manager();
72 if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer)) { 74
75 if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl)) {
73 $options = new stdClass(); 76 $options = new stdClass();
74 $options->page = $page; 77 $options->page = $page;
75 $options->courseid = $course->id; 78 $options->courseid = $course->id;
76 $options->contextid = $context->id; 79 $options->contextid = $context->id;
77 $options->context = $context; 80 $options->context = $context;
78 $options->contextarea = $contextarea; 81 $options->contextarea = $contextarea;
79 // $options->notestime=$timer; 82 // $options->notestime=$timer;
80 unset($options->courseid); 83 unset($options->courseid);
81 $count = $manager->count_mynotes($options); 84 $count = $manager->count_mynotes($options);
82 85
......
...@@ -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 = 2018011200; // The current plugin version (Date: YYYYMMDDXX) 26 $plugin->version = 2018011201; // 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';
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!