Ejemplo n.º 1
0
 $moodleid = $userfacebookinfo->moodleid;
 $lastvisit = $userfacebookinfo->lasttimechecked;
 // Gets the user info
 $user_info = $DB->get_record('user', array('id' => $moodleid));
 $usercourse = enrol_get_users_courses($moodleid);
 $courseidarray = array();
 // Generates an array with all the users courses
 foreach ($usercourse as $courses) {
     $courseidarray[] = $courses->id;
 }
 if (count($courseidarray) > 0) {
     echo '<div class="cuerpo"><h1>' . get_string('courses', 'local_facebook') . '</h1><ul id="cursos">';
     // Get_in_or_equal used after in the IN ('') clause of multiple querys
     list($sqlin, $param) = $DB->get_in_or_equal($courseidarray);
     // List the 3 arrays returned from the function
     list($totalresource, $totalurl, $totalpost) = get_total_notification($sqlin, $param, $lastvisit);
     $dataarray = get_data_post_resource_link($sqlin, $param);
     // Foreach that generates each course square
     foreach ($usercourse as $courses) {
         $fullname = $courses->fullname;
         $courseid = $courses->id;
         $shortname = $courses->shortname;
         $totals = 0;
         // Tests if the array has something in it
         if (isset($totalresource[$courseid])) {
             $totals += intval($totalresource[$courseid]);
         }
         // Tests if the array has something in it
         if (isset($totalurl[$courseid])) {
             $totals += intval($totalurl[$courseid]);
         }
Ejemplo n.º 2
0
$userfacebookinfo = $DB->get_record('facebook_user', array('moodleid' => $USER->id, 'status' => 1));
// if the user exist then show the app, if not tell him to connect his facebook account
if ($userfacebookinfo != false) {
    $moodleid = $userfacebookinfo->moodleid;
    $lastvisit = $userfacebookinfo->lasttimechecked;
    $user_info = $DB->get_record('user', array('id' => $moodleid));
    $usercourse = enrol_get_users_courses($moodleid);
    //generates an array with all the users courses
    $courseidarray = array();
    foreach ($usercourse as $courses) {
        $courseidarray[] = $courses->id;
    }
    // get_in_or_equal used after in the IN ('') clause of multiple querys
    list($sqlin, $param) = $DB->get_in_or_equal($courseidarray);
    // list the 3 arrays returned from the funtion
    list($totalresource, $totalurl, $totalpost, $totalemarkingperstudent) = get_total_notification($sqlin, $param, $lastvisit, $moodleid);
    $dataarray = get_data_post_resource_link($sqlin, $param, $moodleid);
    //foreach that reorganizes array
    foreach ($usercourse as $courses) {
        $courses->totalnotifications = 0;
        if (isset($totalresource[$courses->id])) {
            $courses->totalnotifications += intval($totalresource[$courses->id]);
        }
        if (isset($totalurl[$courses->id])) {
            $courses->totalnotifications += intval($totalurl[$courses->id]);
        }
        if (isset($totalpost[$courses->id])) {
            $courses->totalnotifications += intval($totalpost[$courses->id]);
        }
        if (isset($totalemarkingperstudent[$courses->id])) {
            $courses->totalnotifications += intval($totalemarkingperstudent[$courses->id]);