Moodle is an open source lms which allows us to customize the coding and create any kind of report. Here I am making new kind of report which suppose to give an idea to you how can you write a code with logically.

Here you have to follow the below steps

Step 1.  First create folder like coursereport in your moodle root folder which should bnase level of config.php file.

Step 2. inside  coursereport folder you have to create index.php file.

Step 3. Just copy the below code and paste inside index.php file.

require_once($CFG->dirroot .’/course/lib.php’);
require_once($CFG->libdir .’/filelib.php’);
mysql_connect($hostname, $databaseuser,$databasepwd);

redirect($CFG->wwwroot .’/login/index.php’);
$context = get_context_instance(CONTEXT_SYSTEM);
$title =’Reports';

echo $OUTPUT->header();
global $DB, $CFG, $context,$USER;



echo “<table align=’center’ border=’1′ width=’500px’ style=’border:#ccc solid 1px;’>”;
echo “<tr bgcolor=’#0A8C91′ style=’color:#FFF;’>
<td width=’100′>Course name</td>
<td width=’100′>Topic name</td>
<td width=’100′>Name</td>
<td width=’100′>Email address</td>
<td width=’50’>Course completion date</td>
<td width=’50’>Total access time(HH:MM)</td></tr>”;
$coursedata=mysql_query(“select * from mgl_course where id !=1 and visible=’1′”);
/*echo “select cm.course as CourseName, as TopicName,cm.idnumber as Minutes,cmc.userid as UserId
FROM mgl_course_modules cm JOIN mgl_course_modules_completion cmc ON where cm.course='”.$allcourses[‘id’].”‘”;
$finaldata=mysql_query(“select as mname, cm.module as module,cm.instance as instance, as email,u.lastname as lastname,u.firstname as firstname,cmc.timemodified as completiondate,cm.course as CourseName, as TopicName,cm.idnumber as Minutes,cmc.userid as UserId
FROM mgl_modules m JOIN mgl_user u JOIN mgl_course_modules cm JOIN mgl_course_modules_completion cmc ON and and where cm.course='”.$allcourses[‘id’].”‘”);

echo “<tr><td width=’100′>”.$allcourses[‘fullname’].”</td><td colspan=’5′>”;

$modulenames=mysql_fetch_array(mysql_query(“select * from mgl_”.$finalrec[‘mname’].” where id='”.$finalrec[‘instance’].”‘”));
echo “<table border=1 width=’100%’><tr>
<td width=’100′>”.$modulenames[‘name’].”</td>
<td width=’100′>”.$finalrec[‘firstname’].” “.$finalrec[‘lastname’].”</td>
<td width=’100′>”.$finalrec[‘email’].”</td>
<td width=’50’>”.date(‘d-M-Y’,$finalrec[‘completiondate’]).”</td>
<td width=’50’>”.$finalrec[‘Minutes’].”</td></tr></table>”;
echo “</td></tr>”;
echo “</table>”;
echo $OUTPUT->footer();

5789 Total Views 3 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>