Пример #1
0
 /**
  * Construct contents of course_overview block
  *
  * @param array $courses list of courses in sorted order
  * @param array $overviews list of course overviews
  * @return string html to be displayed in course_overview block
  */
 public function course_overview($courses, $overviews)
 {
     $html = '';
     $config = get_config('block_course_overview');
     $ismovingcourse = false;
     $courseordernumber = 0;
     $maxcourses = count($courses);
     $userediting = false;
     // Intialise string/icon etc if user is editing and courses > 1
     if ($this->page->user_is_editing() && count($courses) > 1) {
         $userediting = true;
         // If ajaxenabled then include DND JS and replace link with move image.
         if (ajaxenabled()) {
             $this->page->requires->js_init_call('M.block_course_overview.add_handles');
         }
         // Check if course is moving
         $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
         $movingcourseid = optional_param('courseid', 0, PARAM_INT);
     }
     // Render first movehere icon.
     if ($ismovingcourse) {
         // Remove movecourse param from url.
         $this->page->ensure_param_not_in_url('movecourse');
         // Show moving course notice, so user knows what is being moved.
         $html .= $this->output->box_start('notice');
         $a = new stdClass();
         $a->fullname = $courses[$movingcourseid]->fullname;
         $a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
         $html .= get_string('movingcourse', 'block_course_overview', $a);
         $html .= $this->output->box_end();
         $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
         // Create move icon, so it can be used.
         $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere')));
         $moveurl = html_writer::link($moveurl, $movetofirsticon);
         $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
     }
     foreach ($courses as $key => $course) {
         // If moving course, then don't show course which needs to be moved.
         if ($ismovingcourse && $course->id == $movingcourseid) {
             continue;
         }
         $html .= $this->output->box_start('coursebox', "course-{$course->id}");
         $html .= html_writer::start_tag('div', array('class' => 'course_title'));
         // If user is editing, then add move icons.
         if ($userediting && !$ismovingcourse) {
             $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move')));
             $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
             $moveurl = html_writer::link($moveurl, $moveicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
         }
         // No need to pass title through s() here as it will be done automatically by html_writer.
         $attributes = array('title' => $course->fullname);
         if ($course->id > 0) {
             if (empty($course->visible)) {
                 $attributes['class'] = 'dimmed';
             }
             $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
             $coursefullname = format_string($course->fullname, true, $course->id);
             $link = html_writer::link($courseurl, $coursefullname, $attributes);
             $html .= $this->output->heading($link, 2, 'title');
         } else {
             $html .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
         }
         $html .= $this->output->box('', 'flush');
         $html .= html_writer::end_tag('div');
         if (!empty($config->showchildren) && $course->id > 0) {
             // List children here.
             if ($children = block_course_overview_get_child_shortnames($course->id)) {
                 $html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
             }
         }
         // If user is moving courses, then down't show overview.
         if (isset($overviews[$course->id]) && !$ismovingcourse) {
             $html .= $this->activity_display($course->id, $overviews[$course->id]);
         }
         $html .= $this->output->box('', 'flush');
         $html .= $this->output->box_end();
         $courseordernumber++;
         if ($ismovingcourse) {
             $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
             $a = new stdClass();
             $a->movingcoursename = $courses[$movingcourseid]->fullname;
             $a->currentcoursename = $course->fullname;
             $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere')));
             $moveurl = html_writer::link($moveurl, $movehereicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
         }
     }
     // Wrap course list in a div and return.
     return html_writer::tag('div', $html, array('class' => 'course_list'));
 }
Пример #2
0
 /**
  * Construct contents of course_overview block
  *
  * @param array $courses list of courses in sorted order
  * @param array $overviews list of course overviews
  * @return string html to be displayed in course_overview block
  */
 public function course_overview($courses, $overviews)
 {
     $html = '';
     $config = get_config('block_course_overview');
     $html .= html_writer::start_tag('div', array('id' => 'course_list'));
     $courseordernumber = 0;
     $maxcourses = count($courses);
     // Intialize string/icon etc if user is editing.
     $url = null;
     $moveicon = null;
     $moveup[] = null;
     $movedown[] = null;
     if ($this->page->user_is_editing()) {
         if (ajaxenabled()) {
             $moveicon = html_writer::tag('div', html_writer::empty_tag('img', array('src' => $this->pix_url('i/move_2d')->out(false), 'alt' => get_string('move'), 'class' => 'cursor', 'title' => get_string('move'))), array('class' => 'move'));
         } else {
             $url = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey()));
             $moveup['str'] = get_string('moveup');
             $moveup['icon'] = $this->pix_url('t/up');
             $movedown['str'] = get_string('movedown');
             $movedown['icon'] = $this->pix_url('t/down');
         }
     }
     foreach ($courses as $key => $course) {
         $html .= $this->output->box_start('coursebox', "course-{$course->id}");
         $html .= html_writer::start_tag('div', array('class' => 'course_title'));
         // Ajax enabled then add moveicon html
         if (!is_null($moveicon)) {
             $html .= $moveicon;
         } else {
             if (!is_null($url)) {
                 // Add course id to move link
                 $url->param('source', $course->id);
                 $html .= html_writer::start_tag('div', array('class' => 'moveicons'));
                 // Add an arrow to move course up.
                 if ($courseordernumber > 0) {
                     $url->param('move', -1);
                     $html .= html_writer::link($url, html_writer::empty_tag('img', array('src' => $moveup['icon'], 'class' => 'up', 'alt' => $moveup['str'])), array('title' => $moveup['str'], 'class' => 'moveup'));
                 } else {
                     // Add a spacer to keep keep down arrow icons at right position.
                     $html .= html_writer::empty_tag('img', array('src' => $this->pix_url('spacer'), 'class' => 'movedownspacer'));
                 }
                 // Add an arrow to move course down.
                 if ($courseordernumber <= $maxcourses - 2) {
                     $url->param('move', 1);
                     $html .= html_writer::link($url, html_writer::empty_tag('img', array('src' => $movedown['icon'], 'class' => 'down', 'alt' => $movedown['str'])), array('title' => $movedown['str'], 'class' => 'movedown'));
                 } else {
                     // Add a spacer to keep keep up arrow icons at right position.
                     $html .= html_writer::empty_tag('img', array('src' => $this->pix_url('spacer'), 'class' => 'moveupspacer'));
                 }
                 $html .= html_writer::end_tag('div');
             }
         }
         $attributes = array('title' => s($course->fullname));
         if ($course->id > 0) {
             $link = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), format_string($course->shortname, true, $course->id), $attributes);
             $html .= $this->output->heading($link, 2, 'title');
         } else {
             $html .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
         }
         $html .= $this->output->box('', 'flush');
         $html .= html_writer::end_tag('div');
         if (!empty($config->showchildren) && $course->id > 0) {
             // List children here.
             if ($children = block_course_overview_get_child_shortnames($course->id)) {
                 $html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
             }
         }
         if (isset($overviews[$course->id])) {
             $html .= $this->activity_display($course->id, $overviews[$course->id]);
         }
         $html .= $this->output->box('', 'flush');
         $html .= $this->output->box_end();
         $courseordernumber++;
     }
     $html .= html_writer::end_tag('div');
     return $html;
 }
Пример #3
0
 public function course_overview($courses, $overviews)
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $html = '';
     $config = get_config('block_course_overview');
     $ismovingcourse = false;
     $courseordernumber = 0;
     $maxcourses = count($courses);
     $userediting = false;
     // Intialise string/icon etc if user is editing and courses > 1
     if ($this->page->user_is_editing() && count($courses) > 1) {
         $userediting = true;
         $this->page->requires->js_init_call('M.block_course_overview.add_handles');
         // Check if course is moving
         $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
         $movingcourseid = optional_param('courseid', 0, PARAM_INT);
     }
     // Render first movehere icon.
     if ($ismovingcourse) {
         // Remove movecourse param from url.
         $this->page->ensure_param_not_in_url('movecourse');
         // Show moving course notice, so user knows what is being moved.
         $html .= $this->output->box_start('notice');
         $a = new stdClass();
         $a->fullname = $courses[$movingcourseid]->fullname;
         $a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
         $html .= get_string('movingcourse', 'block_course_overview', $a);
         $html .= $this->output->box_end();
         $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
         // Create move icon, so it can be used.
         $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere')));
         $moveurl = html_writer::link($moveurl, $movetofirsticon);
         $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
     }
     foreach ($courses as $key => $course) {
         // If moving course, then don't show course which needs to be moved.
         if ($ismovingcourse && $course->id == $movingcourseid) {
             continue;
         }
         $html .= $this->output->box_start('coursebox span6', "course-{$course->id}");
         $html .= html_writer::start_tag('div', array('class' => 'course_title'));
         // If user is editing, then add move icons.
         if ($userediting && !$ismovingcourse) {
             $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move')));
             $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
             $moveurl = html_writer::link($moveurl, $moveicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
         }
         // No need to pass title through s() here as it will be done automatically by html_writer.
         $attributes = array('title' => $course->fullname);
         if ($course->id > 0) {
             if (empty($course->visible)) {
                 $attributes['class'] = 'dimmed';
             }
             $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
             $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
             $link = html_writer::link($courseurl, $coursefullname, $attributes);
             $html .= $this->output->heading($link, 2, 'title');
         } else {
             $html .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
         }
         $html .= $this->output->box('', 'flush');
         $html .= html_writer::end_tag('div');
         if (!empty($config->showchildren) && $course->id > 0) {
             // List children here.
             if ($children = block_course_overview_get_child_shortnames($course->id)) {
                 $html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
             }
         }
         // show summary
         //if (!empty($course->summary)){
         $coursesummary = format_string($course->summary);
         $html .= html_writer::tag('p', $course->id, array('class' => 'summary'));
         //}
         // display course overview files
         $contentimages = $contentfiles = '';
         //			get_course_overviewfiles($course-id);
         //			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'));
         //				}
         //			}
         $html .= $contentimages . $contentfiles;
         // If user is moving courses, then down't show overview.
         if (isset($overviews[$course->id]) && !$ismovingcourse) {
             $html .= $this->activity_display($course->id, $overviews[$course->id]);
         }
         $html .= $this->output->box('', 'flush');
         $html .= $this->output->box_end();
         $courseordernumber++;
         if ($ismovingcourse) {
             $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
             $a = new stdClass();
             $a->movingcoursename = $courses[$movingcourseid]->fullname;
             $a->currentcoursename = $course->fullname;
             $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere')));
             $moveurl = html_writer::link($moveurl, $movehereicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
         }
     }
     // Wrap course list in a div and return.
     return html_writer::tag('div', $html, array('class' => 'course_list'));
 }
Пример #4
0
 /**
  * Construct contents of course_overview block
  *
  * @param array $courses list of courses in sorted order
  * @param array $overviews list of course overviews
  * @return string html to be displayed in course_overview block
  */
 public function course_overview($courses, $overviews)
 {
     global $DB;
     $html = '';
     $config = get_config('block_course_overview');
     if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) {
         global $CFG;
         require_once $CFG->libdir . '/coursecatlib.php';
     }
     /*echo '<pre>';
       print_r($courses);*/
     $ismovingcourse = false;
     $courseordernumber = 0;
     $maxcourses = count($courses);
     $userediting = false;
     // Intialise string/icon etc if user is editing and courses > 1
     if ($this->page->user_is_editing() && count($courses) > 1) {
         $userediting = true;
         $this->page->requires->js_init_call('M.block_course_overview.add_handles');
         // Check if course is moving
         $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
         $movingcourseid = optional_param('courseid', 0, PARAM_INT);
     }
     /**
      * Indexador das categorias dos cursos
      * @author Cássio Queiroz <Cruzz>
      * @date 2015/12/26
      */
     $catids = array();
     foreach ($courses as $key => $course) {
         $value = $DB->get_record_sql('SELECT id,name FROM {course_categories} WHERE id = ? ', array($course->category));
         $catids[] = $value->id . '@' . $value->name;
     }
     $firstCat = explode("@", $catids[0]);
     $catids = array_unique($catids);
     // Render first movehere icon.
     if ($ismovingcourse) {
         // Remove movecourse param from url.
         $this->page->ensure_param_not_in_url('movecourse');
         // Show moving course notice, so user knows what is being moved.
         $html .= $this->output->box_start('notice');
         $a = new stdClass();
         $a->fullname = $courses[$movingcourseid]->fullname;
         $a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
         $html .= get_string('movingcourse', 'block_course_overview', $a);
         $html .= $this->output->box_end();
         $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
         // Create move icon, so it can be used.
         $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere')));
         $moveurl = html_writer::link($moveurl, $movetofirsticon);
         $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
     }
     // @autor Cássio Queiroz <Cruzz>
     $html .= html_writer::start_tag('div', array('class' => 'cat_navigation'));
     $html .= html_writer::start_span('top-level') . 'Meus Cursos' . html_writer::end_span();
     $html .= html_writer::start_tag('div', array('class' => 'cat_navs'));
     $piper = '';
     foreach ($catids as $cor) {
         $name = explode('@', $cor);
         $html .= $piper . html_writer::start_span('allcat category-' . $name[0]) . $name[1] . html_writer::end_span();
         $piper = ' | ';
     }
     $html .= html_writer::end_tag('div');
     // END cat_navs
     $html .= html_writer::end_tag('div');
     // END cat_navigation
     foreach ($courses as $key => $course) {
         // If moving course, then don't show course which needs to be moved.
         if ($ismovingcourse && $course->id == $movingcourseid) {
             continue;
         }
         $html .= html_writer::start_tag('div', array('class' => 'all cat_' . $course->category));
         // @autor Cássio Queiroz <Cruzz>
         $html .= $this->output->box_start('coursebox', "course-{$course->id}");
         $html .= html_writer::start_tag('div', array('class' => 'course_title'));
         // If user is editing, then add move icons.
         if ($userediting && !$ismovingcourse) {
             $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move')));
             $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
             $moveurl = html_writer::link($moveurl, $moveicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
         }
         // No need to pass title through s() here as it will be done automatically by html_writer.
         $attributes = array('title' => $course->fullname);
         if ($course->id > 0) {
             if (empty($course->visible)) {
                 $attributes['class'] = 'dimmed';
             }
             $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
             $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
             $link = html_writer::link($courseurl, $coursefullname, $attributes);
             $html .= $this->output->heading($link, 2, 'title');
         } else {
             $html .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
         }
         $html .= $this->output->box('', 'flush');
         $html .= html_writer::end_tag('div');
         // hide-div
         $html .= html_writer::end_tag('div');
         if (!empty($config->showchildren) && $course->id > 0) {
             // List children here.
             if ($children = block_course_overview_get_child_shortnames($course->id)) {
                 $html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
             }
         }
         // If user is moving courses, then down't show overview.
         if (isset($overviews[$course->id]) && !$ismovingcourse) {
             $html .= $this->activity_display($course->id, $overviews[$course->id]);
         }
         if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) {
             // List category parent or categories path here.
             $currentcategory = coursecat::get($course->category, IGNORE_MISSING);
             if ($currentcategory !== null) {
                 $html .= html_writer::start_tag('div', array('class' => 'categorypath'));
                 if ($config->showcategories == BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH) {
                     foreach ($currentcategory->get_parents() as $categoryid) {
                         $category = coursecat::get($categoryid, IGNORE_MISSING);
                         if ($category !== null) {
                             $html .= $category->get_formatted_name() . ' / ';
                         }
                     }
                 }
                 $html .= $currentcategory->get_formatted_name();
                 $html .= html_writer::end_tag('div');
             }
         }
         $html .= $this->output->box('', 'flush');
         $html .= $this->output->box_end();
         $courseordernumber++;
         if ($ismovingcourse) {
             $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
             $a = new stdClass();
             $a->movingcoursename = $courses[$movingcourseid]->fullname;
             $a->currentcoursename = $course->fullname;
             $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere')));
             $moveurl = html_writer::link($moveurl, $movehereicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
         }
     }
     /**
      * Função jquery para mostrar os cursos de acordo com a categoria
      * @author Cássio Queiroz <Cruzz>
      * @date 2015/12/26
      */
     $html .= '<script type="text/javascript">
                 $(document).ready(function(){
                     $(".all").hide();
                     var last = $(".category-' . $firstCat[0] . '");
                     $(".cat_' . $firstCat[0] . '").fadeIn();
                     $(".category-' . $firstCat[0] . '").css("color","orange");
                     $(".allcat").click(function(){
                         if(typeof last === "undefined"){
                             last = $(this);
                         }
                         last.css("color","#656565");
                         last = $(this);
                         $(".all").hide();
                         $(this).css("color","orange");
                         var name = $(this).attr("class").split("-");
                         $(".cat_"+name[1]).fadeIn();
                     });      
                 });
               
               </script>
     ';
     // Wrap course list in a div and return.
     return html_writer::tag('div', $html, array('class' => 'course_list'));
 }
Пример #5
0
    /**
     * Construct contents of course_overview block
     *
     * @param array $courses list of courses in sorted order
     * @param array $overviews list of course overviews
     * @return string html to be displayed in course_overview block
     */
    public function course_overview($courses, $overviews)
    {
        $html = '';
        $config = get_config('block_course_overview');
        $ismovingcourse = false;
        $courseordernumber = 0;
        $maxcourses = count($courses);
        $userediting = false;
        // Intialise string/icon etc if user is editing and courses > 1
        if ($this->page->user_is_editing() && count($courses) > 1) {
            $userediting = true;
            $this->page->requires->js_init_call('M.block_course_overview.add_handles');
            // Check if course is moving
            $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
            $movingcourseid = optional_param('courseid', 0, PARAM_INT);
        }
        // Render first movehere icon.
        if ($ismovingcourse) {
            // Remove movecourse param from url.
            $this->page->ensure_param_not_in_url('movecourse');
            // Show moving course notice, so user knows what is being moved.
            $html .= $this->output->box_start('notice');
            $a = new stdClass();
            $a->fullname = $courses[$movingcourseid]->fullname;
            $a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
            $html .= get_string('movingcourse', 'block_course_overview', $a);
            $html .= $this->output->box_end();
            $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
            // Create move icon, so it can be used.
            $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere')));
            $moveurl = html_writer::link($moveurl, $movetofirsticon);
            $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
        }
        $completedcourseshtml = '';
        $inprogresscourseshtml = '';
        $coursehtmlrecord = '';
        foreach ($courses as $key => $course) {
            $coursehtmlrecord = '';
            // If moving course, then don't show course which needs to be moved.
            if ($ismovingcourse && $course->id == $movingcourseid) {
                continue;
            }
            $coursehtmlrecord .= $this->output->box_start('coursebox', "course-{$course->id}");
            $coursehtmlrecord .= html_writer::start_tag('div', array('class' => 'course_title'));
            // If user is editing, then add move icons.
            //GWL Display course image - Start
            global $CFG, $DB, $USER;
            $course = new course_in_list($course);
            //Getting progress percentage.
            $progress = get_course_progress_percentage($course, $USER);
            $completionstate = get_course_lesson_completionstate($course);
            $info = new completion_info($course);
            //GWL - Add this to add contion to generate certificate when instructor mark completed
            $completionstate = $info->is_course_complete($USER->id);
            //GWL - Add this to add contion to generate certificate when instructor mark completed
            // 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;
            $coursehtmlrecord .= $content;
            $attributes = array('title' => $course->fullname);
            if ($course->id > 0) {
                if (empty($course->visible)) {
                    $attributes['class'] = 'dimmed';
                }
                $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
                $lession_id = get_course_lesson_id($course);
                if ($lession_id) {
                    $courseurl = new moodle_url('/mod/lesson/view.php', array('id' => $lession_id));
                }
                $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
                $link = html_writer::link($courseurl, $coursefullname, $attributes);
                if ($progress >= 100 || $completionstate == 1) {
                    $coursehtmlrecord .= $this->output->heading($coursefullname, 2, 'title');
                } else {
                    $coursehtmlrecord .= $this->output->heading($link, 2, 'title');
                }
            } else {
                $coursehtmlrecord .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
            }
            $result = $DB->get_field("course", "summary", array("id" => $course->id));
            $coursehtmlrecord .= $result;
            //GWL Display course image - END
            //GWL to get download certificate link
            if ($progress < 100 && !$completionstate) {
                $coursehtmlrecord .= '<div style=" background-color: #ccc; color: #fff; text-align: right; vertical-align: middle; height: 20px;  border-radius: 10px;  overflow: hidden; margin-bottom: 5px;"><div style="width: ' . $progress . '%; float: left; background-color: green; padding-right: 10px;">' . $progress . '%</div></div>';
            } else {
                $certificates = get_coursemodules_in_course('iomadcertificate', $course->id);
                $certificatelink = '-';
                if ($certificates) {
                    $showcertificate = 1;
                    foreach ($certificates as $certficate) {
                        $modinfo = get_fast_modinfo($course->id);
                        $cm = $modinfo->get_cm($certficate->id);
                        if ($cm && $cm->uservisible) {
                            $coursehtmlrecord .= '<div><a href="' . $CFG->wwwroot . '/mod/iomadcertificate/view.php?id=' . $certficate->id . '&action=get" class="pull-right" style="color:#f5811e;">
<i class="fa fa-cloud-download" style="color:#f5811e;" ></i> Download Certificate</a> </div>';
                        }
                    }
                }
            }
            //GWL to get download certificate link
            // GWL - Course Status On Dashboard /
            if ($userediting && !$ismovingcourse) {
                $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move')));
                $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
                $moveurl = html_writer::link($moveurl, $moveicon);
                $coursehtmlrecord .= html_writer::tag('div', $moveurl, array('class' => 'move'));
            }
            // No need to pass title through s() here as it will be done automatically by html_writer.
            $coursehtmlrecord .= $this->output->box('', 'flush');
            $coursehtmlrecord .= html_writer::end_tag('div');
            if (!empty($config->showchildren) && $course->id > 0) {
                // List children here.
                if ($children = block_course_overview_get_child_shortnames($course->id)) {
                    $coursehtmlrecord .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
                }
            }
            // If user is moving courses, then down't show overview.
            if (isset($overviews[$course->id]) && !$ismovingcourse) {
                $coursehtmlrecord .= $this->activity_display($course->id, $overviews[$course->id]);
            }
            $coursehtmlrecord .= $this->output->box('', 'flush');
            $coursehtmlrecord .= $this->output->box_end();
            $courseordernumber++;
            if ($ismovingcourse) {
                $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
                $a = new stdClass();
                $a->movingcoursename = $courses[$movingcourseid]->fullname;
                $a->currentcoursename = $course->fullname;
                $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere')));
                $moveurl = html_writer::link($moveurl, $movehereicon);
                $coursehtmlrecord .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
            }
            if ($progress >= 100 || $completionstate == 1) {
                $completedcourseshtml .= $coursehtmlrecord;
            } else {
                $inprogresscourseshtml .= $coursehtmlrecord;
            }
        }
        $html .= '<div class="inprogresscourse">In Progress Courses</div>';
        $html .= $inprogresscourseshtml;
        $html .= '<div class="completecourse">Completed Courses</div>';
        $html .= $completedcourseshtml;
        // Wrap course list in a div and return.
        return html_writer::tag('div', $html, array('class' => 'course_list'));
    }