chnages in notestime for vimeo player
Showing
6 changed files
with
76 additions
and
43 deletions
This diff is collapsed.
Click to expand it.
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 t=document.querySelector("iframe"),i=new Vimeo.Player(t);console.log(i),e("#mynotepencil").click(function(){setTimeout(function(){i.getCurrentTime().then(function(e){})},1e3)})}})}}}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -12,38 +12,6 @@ define(['jquery'], function($) { | ... | @@ -12,38 +12,6 @@ define(['jquery'], function($) { |
12 | 12 | ||
13 | var player = new Vimeo.Player(iframe); | 13 | var player = new Vimeo.Player(iframe); |
14 | 14 | ||
15 | console.log(player); | ||
16 | $('#mynotepencil').click(function(){ | ||
17 | |||
18 | setTimeout(function(){ | ||
19 | player.getCurrentTime().then(function(seconds) { | ||
20 | |||
21 | var str = "</br><br><div style='display: none !important;'> You have taken notes at "; | ||
22 | str +=seconds; | ||
23 | str +=" in this video.</div>" | ||
24 | // var result = str.fontcolor("green"); | ||
25 | // $("#id_mynotecontent-54").val(str); | ||
26 | |||
27 | }) | ||
28 | // console.log($mynotestime); | ||
29 | // console.log(self); | ||
30 | |||
31 | // | ||
32 | |||
33 | |||
34 | // var str = "<div> You have taken notes at "; | ||
35 | // str +=time; | ||
36 | // str +=" in this video.</div>" | ||
37 | // var result = str.fontcolor("green"); | ||
38 | // $("#id_mynotecontent-258").val(result); | ||
39 | |||
40 | }, 1000); | ||
41 | |||
42 | }); | ||
43 | |||
44 | |||
45 | |||
46 | |||
47 | } | 15 | } |
48 | }); | 16 | }); |
49 | } | 17 | } | ... | ... |
... | @@ -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, c.fullname as coursename, m.courseid | 73 | m.timecreated AS timecreated,m.notestime AS notestime, 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 |
... | @@ -94,6 +94,13 @@ class block_mynotes_manager { | ... | @@ -94,6 +94,13 @@ class block_mynotes_manager { |
94 | $c->contextarea = $u->contextarea; | 94 | $c->contextarea = $u->contextarea; |
95 | $c->format = $u->cformat; | 95 | $c->format = $u->cformat; |
96 | $c->timecreated = userdate($u->timecreated, $strftime); | 96 | $c->timecreated = userdate($u->timecreated, $strftime); |
97 | $c->userid = $u->id; | ||
98 | if (!empty($u->notestime)) { | ||
99 | $c->notestime = $u->notestime; | ||
100 | } else { | ||
101 | $c->notestime = ''; | ||
102 | } | ||
103 | // $c->notestime = $u->notestime; | ||
97 | $c->content = format_text($c->content, $c->format, $formatoptions); | 104 | $c->content = format_text($c->content, $c->format, $formatoptions); |
98 | $c->delete = true; | 105 | $c->delete = true; |
99 | $mynotes[] = $c; | 106 | $mynotes[] = $c; |
... | @@ -108,24 +115,59 @@ class block_mynotes_manager { | ... | @@ -108,24 +115,59 @@ class block_mynotes_manager { |
108 | * @param object $options | 115 | * @param object $options |
109 | * @return int The count of records | 116 | * @return int The count of records |
110 | */ | 117 | */ |
111 | public function count_mynotes($options) { | 118 | /* public function count_mynotes($options) { |
112 | global $DB, $USER; | 119 | global $DB, $USER; |
113 | $params = array(); | 120 | $params = array(); |
114 | // $params ['contextid']= $options->contextid; | 121 | $params['userid'] = $USER->id; |
115 | // $params= $options->contextid; | 122 | |
116 | $sql='select COUNT(contextarea) from {block_mynotes} where contextid= :contextid'; | 123 | $sql='select COUNT(contextarea) from {block_mynotes} where contextid= :contextid'; |
117 | $params ['contextid']= $options->contextid; | 124 | $params ['contextid']= $options->contextid; |
118 | return $DB->count_records_sql($sql,$params); | 125 | print_object($sql); |
119 | /* $params['userid'] = $USER->id; | 126 | // return $DB->count_records_sql($sql,$params); |
127 | |||
128 | |||
129 | |||
130 | |||
120 | if (isset($options->contextarea) && !empty($options->contextarea)) { | 131 | if (isset($options->contextarea) && !empty($options->contextarea)) { |
121 | $params['contextarea'] = $options->contextarea; | 132 | $params['contextarea'] = $options->contextarea; |
122 | } | 133 | } |
123 | if (isset($options->contextid) && !empty($options->contextid)) { | 134 | if (isset($options->contextid) && !empty($options->contextid)) { |
124 | $params['contextid'] = $options->contextid; | 135 | $params['contextid'] = $options->contextid; |
125 | } | 136 | } |
126 | return $DB->count_records('block_mynotes',$params); */ | 137 | |
138 | |||
139 | return $DB->count_records('block_mynotes',$params); | ||
127 | 140 | ||
141 | } */ | ||
142 | |||
143 | |||
144 | |||
145 | public function count_mynotes($options) { | ||
146 | global $DB, $USER; | ||
147 | |||
148 | $params = array(); | ||
149 | $params['userid'] = $USER->id; | ||
150 | if (isset($options->contextarea) && !empty($options->contextarea)) { | ||
151 | $params['contextarea'] = $options->contextarea; | ||
152 | } | ||
153 | if (isset($options->contextid) && !empty($options->contextid)) { | ||
154 | $params['contextid'] = $options->contextid; | ||
155 | } | ||
156 | |||
157 | $sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and contextid=?'; | ||
158 | |||
159 | $result=$DB->get_records_sql($sql,$params); | ||
160 | |||
161 | $count; | ||
162 | foreach ($result as $val){ | ||
163 | $count=$val->count; | ||
164 | |||
165 | } | ||
166 | |||
167 | return $count; | ||
168 | // return $DB->count_records('block_mynotes', $params); | ||
128 | } | 169 | } |
170 | |||
129 | 171 | ||
130 | /* | 172 | /* |
131 | * Returns paging bar for mynotes | 173 | * Returns paging bar for mynotes |
... | @@ -149,7 +191,7 @@ class block_mynotes_manager { | ... | @@ -149,7 +191,7 @@ class block_mynotes_manager { |
149 | */ | 191 | */ |
150 | public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) { | 192 | public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) { |
151 | global $CFG, $DB, $USER, $OUTPUT; | 193 | global $CFG, $DB, $USER, $OUTPUT; |
152 | $content=$content.$timer; | 194 | // $content=$content.$timer; |
153 | $newnote = new stdClass; | 195 | $newnote = new stdClass; |
154 | $newnote->contextid = $context->id; | 196 | $newnote->contextid = $context->id; |
155 | $newnote->contextarea = $contextarea; | 197 | $newnote->contextarea = $contextarea; |
... | @@ -158,12 +200,14 @@ class block_mynotes_manager { | ... | @@ -158,12 +200,14 @@ class block_mynotes_manager { |
158 | $newnote->format = $format; | 200 | $newnote->format = $format; |
159 | $newnote->userid = $USER->id; | 201 | $newnote->userid = $USER->id; |
160 | $newnote->timecreated = time(); | 202 | $newnote->timecreated = time(); |
203 | $newnote->notestime=$timer; | ||
161 | 204 | ||
162 | if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) { | 205 | if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) { |
163 | $newnote->id = $cmtid; | 206 | $newnote->id = $cmtid; |
164 | $newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true)); | 207 | $newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true)); |
165 | $newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig')); | 208 | $newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig')); |
166 | $newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname; | 209 | $newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname; |
210 | $newnote->notestime = ($newnote->notestime) ? '' : $newnote->notestime; | ||
167 | if (!empty($newnote->coursename)) { | 211 | if (!empty($newnote->coursename)) { |
168 | $newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename); | 212 | $newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename); |
169 | } | 213 | } |
... | @@ -249,4 +293,5 @@ class block_mynotes_manager { | ... | @@ -249,4 +293,5 @@ class block_mynotes_manager { |
249 | * Mynotes exception class | 293 | * Mynotes exception class |
250 | */ | 294 | */ |
251 | class mynotes_exception extends moodle_exception { | 295 | class mynotes_exception extends moodle_exception { |
252 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
296 | } | ||
297 | ... | ... |
... | @@ -62,6 +62,7 @@ $config = get_config('block_mynotes'); | ... | @@ -62,6 +62,7 @@ $config = get_config('block_mynotes'); |
62 | 62 | ||
63 | echo $OUTPUT->header(); //...send headers | 63 | echo $OUTPUT->header(); //...send headers |
64 | // process ajax request | 64 | // process ajax request |
65 | |||
65 | switch ($action) { | 66 | switch ($action) { |
66 | case 'add': | 67 | case 'add': |
67 | $content = optional_param('content', '', PARAM_RAW); | 68 | $content = optional_param('content', '', PARAM_RAW); |
... | @@ -75,8 +76,10 @@ switch ($action) { | ... | @@ -75,8 +76,10 @@ switch ($action) { |
75 | $options->contextid = $context->id; | 76 | $options->contextid = $context->id; |
76 | $options->context = $context; | 77 | $options->context = $context; |
77 | $options->contextarea = $contextarea; | 78 | $options->contextarea = $contextarea; |
79 | // $options->notestime=$timer; | ||
78 | unset($options->courseid); | 80 | unset($options->courseid); |
79 | $count = $manager->count_mynotes($options); | 81 | $count = $manager->count_mynotes($options); |
82 | |||
80 | echo json_encode(array('notes' => array($note), 'count' => $count)); | 83 | echo json_encode(array('notes' => array($note), 'count' => $count)); |
81 | } else { | 84 | } else { |
82 | echo json_encode(array('error' => 'Unable to add note')); | 85 | echo json_encode(array('error' => 'Unable to add note')); |
... | @@ -89,9 +92,21 @@ switch ($action) { | ... | @@ -89,9 +92,21 @@ switch ($action) { |
89 | $options->page = $page; | 92 | $options->page = $page; |
90 | $options->contextid = $context->id; | 93 | $options->contextid = $context->id; |
91 | $options->contextarea = $contextarea; | 94 | $options->contextarea = $contextarea; |
95 | $options->courseid = $course->id; | ||
96 | |||
92 | $count = $manager->count_mynotes($options); | 97 | $count = $manager->count_mynotes($options); |
93 | $notes = $manager->get_mynotes($options); | 98 | $notes = $manager->get_mynotes($options); |
94 | echo json_encode(array('notes' => $notes, 'count' => $count)); | 99 | |
100 | if (empty($notes)){ | ||
101 | $count=0; | ||
102 | |||
103 | echo json_encode(array('notes' => $notes, 'count' => $count)); | ||
104 | } | ||
105 | else{ | ||
106 | echo json_encode(array('notes' => $notes, 'count' => $count)); | ||
107 | |||
108 | } | ||
109 | |||
95 | die(); | 110 | die(); |
96 | break; | 111 | break; |
97 | case 'delete': | 112 | case 'delete': |
... | @@ -101,12 +116,17 @@ switch ($action) { | ... | @@ -101,12 +116,17 @@ switch ($action) { |
101 | if ($manager->delete($noteid)) { | 116 | if ($manager->delete($noteid)) { |
102 | $options = new stdClass(); | 117 | $options = new stdClass(); |
103 | $options->page = $page; | 118 | $options->page = $page; |
119 | $options->contextid = $context->id; | ||
104 | $options->contextarea = $contextarea; | 120 | $options->contextarea = $contextarea; |
121 | $options->courseid = $course->id; | ||
105 | $count = $manager->count_mynotes($options); | 122 | $count = $manager->count_mynotes($options); |
123 | |||
106 | if ($limitfrom) { | 124 | if ($limitfrom) { |
107 | $options->limitfrom = $limitfrom - 1; | 125 | $options->limitfrom = $limitfrom - 1; |
108 | } | 126 | } |
109 | $notes = $manager->get_mynotes($options); | 127 | $notes = $manager->get_mynotes($options); |
128 | |||
129 | |||
110 | echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid)); | 130 | echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid)); |
111 | } | 131 | } |
112 | die(); | 132 | die(); | ... | ... |
-
Please register or sign in to post a comment