Hello All,
I m new in moodle, as per my requirement i made a activity module mod_lessonvideo under mod directory.
The concept behind this module is post vimeo & youtube video as resource activity in course.
When user click on activity link it opens video in jquery UI and start tracking progress of the video and save one of table with user id.
But i think because of course cache i can not display correct progress data to correct user.
This is my code in module lib.php
function lessonvideo_get_coursemodule_info($coursemodule) {
global $CFG, $DB,$USER;
require_once("$CFG->dirroot/mod/lessonvideo/locallib.php");
if (!$lessonvideo = $DB->get_record('lessonvideo', array('id'=>$coursemodule->instance),
'id, name,vurl,vtype,vid')) {
return NULL;
}
$info = new cached_cm_info();
$info->name = $lessonvideo->name;
$info->vurl = $lessonvideo->vurl;
$info->vtype = $lessonvideo->vtype;
$info->vid = $lessonvideo->vid;
$id = $lessonvideo->id;
$vid = $info->vid;
// this is the video tracking table from where we are getting the record for current user and video activity
$trackData = $DB->get_record('lessonvideo_track', array('vid'=>$id,'uid'=>$USER->id));
/*$trackData = lesson_get_track_record( $vid );
print_r($trackData);die;*/
if ($info->vtype) {
$info->extraclasses = "myyoutube";
$info->onclick = "pickYoutube('$vid','$id'); return false;";
}else {
$info->extraclasses = "myvimeo";
$info->onclick = "pickVimeo('$vid','$id'); return false;";
}
// here we are setting the progress bar that should be different for different user according to the track table
if($trackData) {
$info->progress = $trackData->watch_percent;
$info->content = '<div class="progress"><div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: '.$info->progress.'%;">'.$info->progress.'%</div></div>';
}else {
$info->content = '<div class="progress"><div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">0%</div></div>';
}
return $info;
}
Please advice how i can resolve this.
Thanks,
Nik