protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
 {
     global $CFG;
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     // Display course overview files.
     $contentimages = $contentfiles = '';
     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) {
             $contentimages .= html_writer::start_tag('div', array('class' => 'imagebox'));
             $images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage'));
             $contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images);
             $contentimages .= html_writer::end_tag('div');
         } else {
             $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
             $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
             $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
         }
     }
     $content .= $contentimages . $contentfiles;
     // Display course summary.
     if ($course->has_summary()) {
         $content .= $chelper->get_course_formatted_summary($course);
     }
     // Display course contacts. See course_in_list::get_course_contacts().
     if ($course->has_course_contacts()) {
         $content .= html_writer::start_tag('ul', array('class' => 'teachers'));
         foreach ($course->get_course_contacts() as $userid => $coursecontact) {
             $name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']);
             $content .= html_writer::tag('li', $name);
         }
         $content .= html_writer::end_tag('ul');
         // ...Teachers!.
     }
     return $content;
 }
 public function get_content()
 {
     global $CFG;
     if ($this->content !== null) {
         return $this->content;
     }
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     $this->content->text = '';
     // The user/index.php expect course context, so get one if page has module context.
     $currentcontext = $this->page->context->get_course_context(false);
     if (empty($currentcontext)) {
         return $this->content;
     }
     if ($this->page->course->id == SITEID) {
         $courses = self::get_featured_courses();
         require_once $CFG->libdir . '/coursecatlib.php';
         $chelper = new coursecat_helper();
         foreach ($courses as $course) {
             $course = new course_in_list($course);
             $this->content->text .= '<div class="container-fluid coursebox">';
             $content = '';
             $coursename = $chelper->get_course_formatted_name($course);
             $coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
             $content .= html_writer::tag('div', $coursenamelink, array('class' => 'coursename'));
             if ($course->has_summary()) {
                 $content .= html_writer::start_tag('div', array('class' => 'summary'));
                 $content .= $chelper->get_course_formatted_summary($course, array('overflowdiv' => true, 'noclean' => true, 'para' => false));
                 $content .= html_writer::end_tag('div');
             }
             // Display course overview files.
             $contentimages = $contentfiles = '';
             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) {
                     $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url, 'style' => 'max-height: 150px')), array('class' => 'courseimage'));
                 } else {
                     $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
                     $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
                     $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
                 }
             }
             $content .= $contentimages . $contentfiles;
             $this->content->text .= $content . '</div>';
         }
     }
     return $this->content;
 }
 public function frontpage_available_courses()
 {
     /* available courses */
     global $CFG, $OUTPUT, $PAGE;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
     $chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
     $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
     $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
     $rcourseids = array_keys($courses);
     $acourseids = array_chunk($rcourseids, 5);
     $newcourse = get_string('availablecourses');
     $header = '<div id="frontpage-course-list">
     <h2>' . $newcourse . '</h2>
     <div class="courses frontpage-course-list-all">';
     $footer = '
     </div>
     </div>';
     $content = '';
     if (count($rcourseids) > 0) {
         foreach ($acourseids as $courseids) {
             $content .= '<div class="row-fluid">';
             $rowcontent = '';
             foreach ($courseids as $courseid) {
                 $course = get_course($courseid);
                 $no = get_config('theme_pioneer', 'patternselect');
                 $nimgp = empty($no) || $no == "default" ? 'no-image' : 'cs0' . $no . '/no-image';
                 $summary = theme_pioneer_strip_html_tags($course->summary);
                 $summary = theme_pioneer_course_trim_char($summary, 20);
                 $trimtitle = theme_pioneer_course_trim_char($course->fullname, 25);
                 $noimgurl = $OUTPUT->pix_url($nimgp, 'theme');
                 $courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
                 if ($course instanceof stdClass) {
                     require_once $CFG->libdir . '/coursecatlib.php';
                     $course = new course_in_list($course);
                 }
                 $imgurl = '';
                 $context = context_course::instance($course->id);
                 foreach ($course->get_course_overviewfiles() as $file) {
                     $isimage = $file->is_valid_image();
                     $imgurl = 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) {
                         $imgurl = $noimgurl;
                     }
                 }
                 if (empty($imgurl)) {
                     $imgurl = $PAGE->theme->setting_file_url('headerbackgroundimage', 'headerbackgroundimage', true);
                     if (!$imgurl) {
                         $imgurl = $noimgurl;
                     }
                 }
                 $rowcontent .= '
                     <div style="background-image: url(' . $imgurl . ');background-repeat: no-repeat;background-size:cover; background-position:center;" class="fp-avail-courses">
                     <div class="fp-coursebox">
                     <div class="fp-courseinfo">
                     <p><a href="' . $courseurl . '" id="button" data-toggle="tooltip" data-placement="top" title="' . $course->fullname . '" >' . $trimtitle . '</a></p>
                     </div>
                     </div>
                     </div>
                     ';
             }
             $content .= $rowcontent;
             $content .= '</div>';
         }
     }
     $coursehtml = $header . $content . $footer;
     echo $coursehtml;
     if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
         // Print link to create a new course, for the 1st available category.
         echo $this->add_new_course_button();
     }
 }
Beispiel #4
0
 /**
  * Returns HTML to print tree of course categories (with number of courses) for the frontpage
  *
  * @return string
  */
 public function frontpage_categories_list()
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_subcat_depth($CFG->maxcategorydepth)->set_show_courses(self::COURSECAT_SHOW_COURSES_COUNT)->set_categories_display_options(array('limit' => $CFG->coursesperpage, 'viewmoreurl' => new moodle_url('/course/index.php', array('browse' => 'categories', 'page' => 1))))->set_attributes(array('class' => 'frontpage-category-names'));
     return $this->coursecat_tree($chelper, coursecat::get(0));
 }
Beispiel #5
0
 public function frontpage_my_courses()
 {
     global $USER, $CFG, $DB;
     $output = '';
     if (!isloggedin() or isguestuser()) {
         return '';
     }
     $courses = block_course_overview_get_sorted_courses();
     list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses();
     if (!empty($sortedcourses) || !empty($rcourses) || !empty($rhosts)) {
         $chelper = new coursecat_helper();
         if (count($courses) > $CFG->frontpagecourselimit) {
             // There are more enrolled courses than we can display, display link to 'My courses'.
             $totalcount = count($sortedcourses);
             $courses = array_slice($sortedcourses, 0, $CFG->frontpagecourselimit, true);
             $chelper->set_courses_display_options(array('viewmoreurl' => new moodle_url('/my/'), 'viewmoretext' => new lang_string('mycourses')));
         } else {
             // All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
             $chelper->set_courses_display_options(array('viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
             $totalcount = $DB->count_records('course') - 1;
         }
         $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_attributes(array('class' => 'frontpage-course-list-enrolled'));
         $output .= $this->coursecat_courses($chelper, $sortedcourses, $totalcount);
         if (!empty($rcourses)) {
             $output .= html_writer::start_tag('div', array('class' => 'courses'));
             foreach ($rcourses as $course) {
                 $output .= $this->frontpage_remote_course($course);
             }
             $output .= html_writer::end_tag('div');
         } else {
             if (!empty($rhosts)) {
                 $output .= html_writer::start_tag('div', array('class' => 'courses'));
                 foreach ($rhosts as $host) {
                     $output .= $this->frontpage_remote_host($host);
                 }
                 $output .= html_writer::end_tag('div');
             }
         }
     }
     return $output;
 }
 protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
 {
     /*
      * We had to override this renderer to output the full category list for
      * a course : cat 1 / cat 2 / subcat / etc
      */
     global $CFG;
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     // Display course overview files.
     $contentimages = $contentfiles = '';
     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) {
             $contentimages .= html_writer::start_tag('div', array('class' => 'imagebox'));
             $images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage'));
             $contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images);
             $contentimages .= html_writer::end_tag('div');
         } else {
             $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
             $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
             $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
         }
     }
     $content .= $contentimages . $contentfiles;
     // Display course summary.
     if ($course->has_summary()) {
         $content .= $chelper->get_course_formatted_summary($course);
     }
     // Display course contacts. See course_in_list::get_course_contacts().
     if ($course->has_course_contacts()) {
         $content .= html_writer::start_tag('ul', array('class' => 'teachers'));
         foreach ($course->get_course_contacts() as $userid => $coursecontact) {
             $name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']);
             $content .= html_writer::tag('li', $name);
         }
         $content .= html_writer::end_tag('ul');
         // .teachers
     }
     // Display course category if necessary (for example in search results).
     if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
         require_once $CFG->libdir . '/coursecatlib.php';
         if ($cat = coursecat::get($course->category, IGNORE_MISSING)) {
             $content .= html_writer::start_tag('div', array('class' => 'coursecat'));
             // $content .= get_string('category').': '.
             //         html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
             //                 $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
             $parents = coursecat::get_many($cat->get_parents());
             $linkydink = [];
             foreach ($parents as $parent) {
                 $linkydink[] = $parent->get_formatted_name();
             }
             $linkydink[] = $cat->get_formatted_name();
             $content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), implode(" / ", $linkydink), array('class' => $cat->visible ? '' : 'dimmed'));
             $content .= html_writer::end_tag('div');
             // .coursecat
         }
     }
     return $content;
 }
 /**
  * Returns HTML to display course content (summary, course contacts and optionally category name)
  *
  * This method is called from coursecat_coursebox() and may be re-used in AJAX
  *
  * @param coursecat_helper $chelper various display options
  * @param stdClass|course_in_list $course
  * @return string
  */
 protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
 {
     global $CFG;
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     $coursehascontacts = $course->has_course_contacts();
     // Display course summary.
     if ($course->has_summary()) {
         $summaryclass = 'summary';
         if ($coursehascontacts == false) {
             $summaryclass .= ' noteachers';
         }
         $content .= html_writer::start_tag('div', array('class' => $summaryclass));
         $content .= $chelper->get_course_formatted_summary($course, array('overflowdiv' => true, 'noclean' => true, 'para' => false));
         $content .= html_writer::end_tag('div');
         // .summary
     }
     // display course overview files
     $contentimages = $contentfiles = '';
     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) {
             $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url)), array('class' => 'courseimage'));
         } else {
             $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
             $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
             $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
         }
     }
     $content .= $contentimages . $contentfiles;
     // display course contacts. See course_in_list::get_course_contacts()
     if ($coursehascontacts) {
         $content .= html_writer::start_tag('ul', array('class' => 'teachers'));
         foreach ($course->get_course_contacts() as $userid => $coursecontact) {
             $faiconsetting = $this->output->get_setting('courselistteachericon');
             $faiconsettinghtml = empty($faiconsetting) ? '' : '<i class="fa fa-' . $faiconsetting . '"></i> ';
             $name = $faiconsettinghtml . $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']);
             $content .= html_writer::tag('li', $name);
         }
         $content .= html_writer::end_tag('ul');
         // .teachers
     }
     // display course category if necessary (for example in search results)
     if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
         require_once $CFG->libdir . '/coursecatlib.php';
         if ($cat = coursecat::get($course->category, IGNORE_MISSING)) {
             $content .= html_writer::start_tag('div', array('class' => 'coursecat'));
             $content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
             $content .= html_writer::end_tag('div');
             // .coursecat
         }
     }
     return $content;
 }
    protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) {
        global $CFG;
        // if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
        //     return '';
        // }
        if ($course instanceof stdClass) {
            require_once($CFG->libdir. '/coursecatlib.php');
            $course = new course_in_list($course);
        }
        $content = '';

        // display course overview files
        $contentimages = $contentfiles = '';
        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) {
                $contentimages .= html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image '. $course->fullname,
                    'class' => 'courseimage'));
            } else {
                $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
                $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
                    html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
                $contentfiles .= html_writer::tag('span',
                    html_writer::link($url, $filename),
                    array('class' => 'coursefile fp-filename-icon'));
            }
        }
        /**
         * @updateDate  25/09/2014
         * @author      eFaktor     (fbv)
         *
         * Description
         * Check if there is any image connected with the course.
         * Not Image --> Add an empty place
         */
        if (!$contentimages) {
            $contentimages .= html_writer::start_tag('div', array('class' => 'not_courseimage'));
            $contentimages .= html_writer::end_div();//courseimage
        }
        $content .= $contentimages. $contentfiles;

        // display course summary
        if ($course->has_summary()) {

            $content .= html_writer::start_tag('div', array('class' => 'course-summary'));
            $content .= $course->summary;

            $content .= html_writer::end_div();//courseimage
        }

        // display course contacts. See course_in_list::get_course_contacts()
        if ($course->has_course_contacts()) {
            $content .= html_writer::start_tag('ul', array('class' => 'teachers'));
            foreach ($course->get_course_contacts() as $userid => $coursecontact) {
                $name = $coursecontact['rolename'].': '.
                    html_writer::link(new moodle_url('/user/view.php',
                            array('id' => $userid, 'course' => SITEID)),
                        $coursecontact['username']);
                $content .= html_writer::tag('li', $name);
            }
            $content .= html_writer::end_tag('ul'); // .teachers
        }

        // display course category if necessary (for example in search results)
        if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
            require_once($CFG->libdir. '/coursecatlib.php');
            if ($cat = coursecat::get($course->category, IGNORE_MISSING)) {
                $content .= html_writer::start_tag('div', array('class' => 'coursecat'));
                $content .= get_string('category').': '.
                    html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
                        $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
                $content .= html_writer::end_tag('div'); // .coursecat
            }
        }

        $content .= html_writer::tag('div', '', array('class' => 'boxfooter')); // .coursecat

        return $content;
    }
 public function frontpage_available_courses()
 {
     /* available courses */
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
     $chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
     $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
     $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
     $rcourseids = array_keys($courses);
     $acourseids = array_chunk($rcourseids, 4);
     $newcourse = get_string('availablecourses');
     $header = '<div id="frontpage-course-list">
     <h2>' . $newcourse . '</h2>
     <div class="courses frontpage-course-list-all">';
     $footer = '
     </div>
     </div>';
     $content = '';
     if (count($rcourseids) > 0) {
         foreach ($acourseids as $courseids) {
             $content .= '<div class="row-fluid">';
             $rowcontent = '';
             foreach ($courseids as $courseid) {
                 $course = get_course($courseid);
                 $no = get_config('theme_eguru', 'patternselect');
                 $nimgp = empty($no) || $no == "default" ? 'cs00/no-image' : 'cs0' . $no . '/no-image';
                 $noimgurl = $OUTPUT->pix_url($nimgp, 'theme');
                 $courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
                 if ($course instanceof stdClass) {
                     require_once $CFG->libdir . '/coursecatlib.php';
                     $course = new course_in_list($course);
                 }
                 $imgurl = '';
                 $context = context_course::instance($course->id);
                 foreach ($course->get_course_overviewfiles() as $file) {
                     $isimage = $file->is_valid_image();
                     $imgurl = 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) {
                         $imgurl = $noimgurl;
                     }
                 }
                 if (empty($imgurl)) {
                     $imgurl = $noimgurl;
                 }
                 $rowcontent .= '<div class="span3">
                     <div class="fp-coursebox">
                     <div class="fp-coursethumb">
                     <a href="' . $courseurl . '">
                     <img src="' . $imgurl . '" width="243" height="165" alt="' . $course->fullname . '">
                     </a>
                     </div>
                     <div class="fp-courseinfo">
                     <h5><a href="' . $courseurl . '">' . $course->fullname . '</a></h5>
                     </div>
                     </div>
                     </div>';
             }
             $content .= $rowcontent;
             $content .= '</div>';
         }
     }
     $coursehtml = $header . $content . $footer;
     echo $coursehtml;
     if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
         // Print link to create a new course, for the 1st available category.
         echo $this->add_new_course_button();
     }
 }
//print_object($f2f_records);

$coursecount = 0;
$i=0;
$out='';
$data=array();
foreach($courses as $course){
    $row=array();
  $course_statistics = $DB->get_record_sql("SELECT count(ue.userid) as enrolled,count(cc.course) as completed
                                              FROM {user_enrolments} as ue 
                                              JOIN {enrol} as e ON e.id=ue.enrolid
                                        RIGHT JOIN {course} as c ON c.id =e.courseid
                                         LEFT JOIN {course_completions} cc ON cc.course=e.courseid and ue.userid=cc.userid
                                             WHERE c.id=$course->id
                                          group by e.courseid");
    $chelper = new coursecat_helper;
        // .coursebox
                   $coursecount ++;
            $classes = ($coursecount%2) ? 'odd' : 'even';
            if ($coursecount == 1) {
                $classes .= ' first';
            }
            if ($coursecount >= count($courses)) {
                $classes .= ' last';
            }
            
          $classes = trim('coursebox clearfix ');
        if ($chelper->get_show_courses() >= 30) {
            $nametag = 'h3';
        } else {
            $classes .= ' collapsed';