function course_image($courseid) {
global $DB, $CFG;
require_once($CFG->libdir. ‘/coursecatlib.php’);

$courserecord = $DB->get_record(‘course’, array(‘id’ => $courseid));
$course = new course_in_list($courserecord);
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url(“$CFG->wwwroot/pluginfile.php”,
‘/’. $file->get_contextid(). ‘/’. $file->get_component(). ‘/’.
$file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
if($isimage) {
return html_writer::empty_tag(‘img’, array(‘src’ => $url, ‘alt’ => ‘Course Image ‘. $course->fullname, ‘class’ => ‘courseimage’));
}
}
}

 

 

<?php
///Get course category list///
function get_categorieslist() {
global $DB, $CFG;

require_once($CFG->libdir. ‘/coursecatlib.php’);
$categorylist = coursecat::make_categories_list();
echo ‘<ul class=”thumbnail-list”>';
foreach($categorylist as $categoryid => $category) {
$categoryinfo = $DB->get_record(‘course_categories’, array(‘id’=>$categoryid));
if(isset($categoryinfo->visible) && ($categoryinfo->visible == 1) && ($categoryinfo->id != 3 )) {
//echo ‘<div class=”span3″>';
echo ‘<li><div><a href=”‘.$CFG->wwwroot.’/mylearning/#cat_’.$categoryid.'” style=”color:#3C3A3B;”><div align=”center”><img src=’.$CFG->wwwroot.”/pix/cat_”.$categoryid.”.png”.’ /></div><div align=”center”>';
echo $categoryinfo->name;
//echo ” ” . $categoryinfo->id;
echo ‘</div></a></div><div class=”catpoints”>’.$categoryinfo->idnumber.’ points</div></li>';
}

}
echo ‘</ul>';
}
//get Course Progress///

function courseProgress($courseID){
global $USER,$CFG;
$course_modules_completion_count=0;
$course_modules_total_count=0;
$coursedata=mysql_query(“select * from “.$CFG->prefix.”course_modules where course='”.$courseID.”‘”);
while($coursenotyetcompleted=mysql_fetch_array($coursedata)){
$course_modules_total_count=$course_modules_total_count+1;
$user_course_viewdata=mysql_query(“select * from “.$CFG->prefix.”course_modules_completion where coursemoduleid='”.$coursenotyetcompleted[‘id’].”‘ and userid='”.$USER->id.”‘”);
$checkmodule_completion=mysql_fetch_array($user_course_viewdata);
if($checkmodule_completion[‘completionstate’]==1){
$course_modules_completion_count=$course_modules_completion_count+1;
}
}

$coursePerc=round(($course_modules_completion_count/$course_modules_total_count)*100);
return $coursePerc;

}
//get Course Status///

function courseStatus($courseID){
global $USER,$CFG;
$course_modules_completion_count=0;
$course_modules_total_count=0;
$coursedata=mysql_query(“select * from “.$CFG->prefix.”course_modules where course='”.$courseID.”‘”);
while($coursenotyetcompleted=mysql_fetch_array($coursedata)){
$course_modules_total_count=$course_modules_total_count+1;
$user_course_viewdata=mysql_query(“select * from “.$CFG->prefix.”course_modules_completion where coursemoduleid='”.$coursenotyetcompleted[‘id’].”‘ and userid='”.$USER->id.”‘”);
$checkmodule_completion=mysql_fetch_array($user_course_viewdata);
if($checkmodule_completion[‘completionstate’]==1){
$course_modules_completion_count=$course_modules_completion_count+1;
}
}
if($course_modules_completion_count==0){
$course_status=’yettostart';
}elseif($course_modules_completion_count==$course_modules_total_count and $course_modules_completion_count>0)
{
$course_status=’completed';
}else{
$course_status=’inprogress';
}
return $course_status;
}
///Get Course course total points///
function courseTotalPoints($courseID){
global $USER,$CFG;
$course_modules_points=0;
$coursedata=mysql_query(“select * from “.$CFG->prefix.”course_modules where course='”.$courseID.”‘”);
while($coursenotyetcompleted=mysql_fetch_array($coursedata)){
$course_modules_points=$course_modules_points+$coursenotyetcompleted[‘idnumber’];
}
return $course_modules_points;

}

583 Total Views 2 Views Today

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>