89341b62 by logesh

chnages in notestime for vimeo player

1 parent aaddd433
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
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
......
......@@ -12,38 +12,6 @@ define(['jquery'], function($) {
var player = new Vimeo.Player(iframe);
console.log(player);
$('#mynotepencil').click(function(){
setTimeout(function(){
player.getCurrentTime().then(function(seconds) {
var str = "</br><br><div style='display: none !important;'> You have taken notes at ";
str +=seconds;
str +=" in this video.</div>"
// var result = str.fontcolor("green");
// $("#id_mynotecontent-54").val(str);
})
// console.log($mynotestime);
// console.log(self);
//
// var str = "<div> You have taken notes at ";
// str +=time;
// str +=" in this video.</div>"
// var result = str.fontcolor("green");
// $("#id_mynotecontent-258").val(result);
}, 1000);
});
}
});
}
......
......@@ -70,7 +70,7 @@ class block_mynotes_manager {
}
$sql = "SELECT $ufields,
m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat,
m.timecreated AS timecreated, c.fullname as coursename, m.courseid
m.timecreated AS timecreated,m.notestime AS notestime, c.fullname as coursename, m.courseid
FROM {block_mynotes} m
JOIN {user} u ON u.id = m.userid
LEFT JOIN {course} c ON c.id = m.courseid
......@@ -94,6 +94,13 @@ class block_mynotes_manager {
$c->contextarea = $u->contextarea;
$c->format = $u->cformat;
$c->timecreated = userdate($u->timecreated, $strftime);
$c->userid = $u->id;
if (!empty($u->notestime)) {
$c->notestime = $u->notestime;
} else {
$c->notestime = '';
}
// $c->notestime = $u->notestime;
$c->content = format_text($c->content, $c->format, $formatoptions);
$c->delete = true;
$mynotes[] = $c;
......@@ -108,24 +115,59 @@ class block_mynotes_manager {
* @param object $options
* @return int The count of records
*/
public function count_mynotes($options) {
/* public function count_mynotes($options) {
global $DB, $USER;
$params = array();
// $params ['contextid']= $options->contextid;
// $params= $options->contextid;
$params['userid'] = $USER->id;
$sql='select COUNT(contextarea) from {block_mynotes} where contextid= :contextid';
$params ['contextid']= $options->contextid;
return $DB->count_records_sql($sql,$params);
/* $params['userid'] = $USER->id;
print_object($sql);
// return $DB->count_records_sql($sql,$params);
if (isset($options->contextarea) && !empty($options->contextarea)) {
$params['contextarea'] = $options->contextarea;
}
if (isset($options->contextid) && !empty($options->contextid)) {
$params['contextid'] = $options->contextid;
}
return $DB->count_records('block_mynotes',$params); */
return $DB->count_records('block_mynotes',$params);
} */
public function count_mynotes($options) {
global $DB, $USER;
$params = array();
$params['userid'] = $USER->id;
if (isset($options->contextarea) && !empty($options->contextarea)) {
$params['contextarea'] = $options->contextarea;
}
if (isset($options->contextid) && !empty($options->contextid)) {
$params['contextid'] = $options->contextid;
}
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and contextid=?';
$result=$DB->get_records_sql($sql,$params);
$count;
foreach ($result as $val){
$count=$val->count;
}
return $count;
// return $DB->count_records('block_mynotes', $params);
}
/*
* Returns paging bar for mynotes
......@@ -149,7 +191,7 @@ class block_mynotes_manager {
*/
public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) {
global $CFG, $DB, $USER, $OUTPUT;
$content=$content.$timer;
// $content=$content.$timer;
$newnote = new stdClass;
$newnote->contextid = $context->id;
$newnote->contextarea = $contextarea;
......@@ -158,12 +200,14 @@ class block_mynotes_manager {
$newnote->format = $format;
$newnote->userid = $USER->id;
$newnote->timecreated = time();
$newnote->notestime=$timer;
if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) {
$newnote->id = $cmtid;
$newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true));
$newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig'));
$newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname;
$newnote->notestime = ($newnote->notestime) ? '' : $newnote->notestime;
if (!empty($newnote->coursename)) {
$newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename);
}
......@@ -249,4 +293,5 @@ class block_mynotes_manager {
* Mynotes exception class
*/
class mynotes_exception extends moodle_exception {
}
\ No newline at end of file
}
......
......@@ -62,6 +62,7 @@ $config = get_config('block_mynotes');
echo $OUTPUT->header(); //...send headers
// process ajax request
switch ($action) {
case 'add':
$content = optional_param('content', '', PARAM_RAW);
......@@ -75,8 +76,10 @@ switch ($action) {
$options->contextid = $context->id;
$options->context = $context;
$options->contextarea = $contextarea;
// $options->notestime=$timer;
unset($options->courseid);
$count = $manager->count_mynotes($options);
echo json_encode(array('notes' => array($note), 'count' => $count));
} else {
echo json_encode(array('error' => 'Unable to add note'));
......@@ -89,9 +92,21 @@ switch ($action) {
$options->page = $page;
$options->contextid = $context->id;
$options->contextarea = $contextarea;
$options->courseid = $course->id;
$count = $manager->count_mynotes($options);
$notes = $manager->get_mynotes($options);
echo json_encode(array('notes' => $notes, 'count' => $count));
if (empty($notes)){
$count=0;
echo json_encode(array('notes' => $notes, 'count' => $count));
}
else{
echo json_encode(array('notes' => $notes, 'count' => $count));
}
die();
break;
case 'delete':
......@@ -101,12 +116,17 @@ switch ($action) {
if ($manager->delete($noteid)) {
$options = new stdClass();
$options->page = $page;
$options->contextid = $context->id;
$options->contextarea = $contextarea;
$options->courseid = $course->id;
$count = $manager->count_mynotes($options);
if ($limitfrom) {
$options->limitfrom = $limitfrom - 1;
}
$notes = $manager->get_mynotes($options);
echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid));
}
die();
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!