Пример #1
0
 public function test_no_course_image()
 {
     $actual = local::course_coverimage_url($this->course->id);
     $this->assertFalse($actual);
 }
Пример #2
0
 /**
  * Set image css for course card (cover image, etc).
  */
 private function apply_image_css()
 {
     $bgcolor = local::get_course_color($this->courseid);
     $this->imagecss = "background-color: #{$bgcolor};";
     $bgimage = local::course_coverimage_url($this->courseid);
     if (!empty($bgimage)) {
         $this->imagecss .= "background-image: url({$bgimage});";
     }
 }
Пример #3
0
 /**
  * get course image
  *
  * @return bool|moodle_url
  */
 public function get_course_image()
 {
     global $COURSE;
     return \theme_snap\local::course_coverimage_url($COURSE->id);
 }
Пример #4
0
 /**
  * Print fixy (login or menu for signed in users)
  *
  */
 public function print_fixed_menu()
 {
     global $CFG, $USER, $PAGE, $DB;
     $logout = get_string('logout');
     $isguest = isguestuser();
     if (!isloggedin() || $isguest) {
         $login = get_string('login');
         $cancel = get_string('cancel');
         $username = get_string('username');
         $password = get_string('password');
         $loginform = get_string('loginform', 'theme_snap');
         $helpstr = '';
         if (empty($CFG->forcelogin) || $isguest || !isloggedin() || !empty($CFG->registerauth) || is_enabled_auth('none') || !empty($CFG->auth_instructions)) {
             if ($isguest) {
                 $helpstr = '<p class="text-center">' . get_string('loggedinasguest', 'theme_snap') . '</p>';
                 $helpstr .= '<p class="text-center">' . '<a class="btn btn-primary" href="' . s($CFG->wwwroot) . '/login/logout.php?sesskey=' . sesskey() . '">' . $logout . '</a></p>';
                 $helpstr .= '<p class="text-center">' . '<a href="' . s($CFG->wwwroot) . '/login/index.php">' . get_string('helpwithloginandguest', 'theme_snap') . '</a></p>';
             } else {
                 if (empty($CFG->forcelogin)) {
                     $help = get_string('helpwithloginandguest', 'theme_snap');
                 } else {
                     $help = get_string('helpwithlogin', 'theme_snap');
                 }
                 $helpstr = "<p class='text-center'><a href='" . s($CFG->wwwroot) . "/login/index.php'>{$help}</a></p>";
             }
         }
         echo $this->print_login_button();
         echo "<form class=fixy action='{$CFG->wwwroot}/login/'  method='post' id='login'>\n        <a id='fixy-close' class='pull-right snap-action-icon' href='#'>\n            <i class='icon icon-office-52'></i><small>{$cancel}</small>\n        </a>\n            <div class=fixy-inner>\n            <legend>{$loginform}</legend>\n            <label for='username'>{$username}</label>\n            <input autocapitalize='off' type='text' name='username' id='username' placeholder='" . s($username) . "'>\n            <label for='password'>{$password}</label>\n            <input type='password' name='password' id='password' placeholder='" . s($password) . "'>\n            <br>\n            <input type='submit' id='loginbtn' value='" . s($login) . "'>\n            {$helpstr}\n            </div>\n        </form>";
     } else {
         $courselist = "";
         $userpicture = new user_picture($USER);
         $userpicture->link = false;
         $userpicture->alttext = false;
         $userpicture->size = 100;
         $picture = $this->render($userpicture);
         $mycourses = enrol_get_my_courses(null, 'visible DESC, fullname ASC, id DESC');
         $courselist .= "<section id='fixy-my-courses'><div class='clearfix'><h2>" . get_string('courses') . "</h2>";
         foreach ($mycourses as $c) {
             $pubstatus = "";
             if (!$c->visible) {
                 $notpublished = get_string('notpublished', 'theme_snap');
                 $pubstatus = "<small class='published-status'>" . $notpublished . "</small>";
             }
             $bgcolor = local::get_course_color($c->id);
             $courseimagecss = "background-color: #{$bgcolor};";
             $bgimage = local::course_coverimage_url($c->id);
             if (!empty($bgimage)) {
                 $courseimagecss .= "background-image: url({$bgimage});";
             }
             $dynamicinfo = '<div data-courseid="' . $c->id . '" class=dynamicinfo></div>';
             $teachers = '';
             $courseteachers = '';
             $clist = new course_in_list($c);
             $teachers = $clist->get_course_contacts();
             if (!empty($teachers)) {
                 $courseteachers = "<div class='sr-only'>" . get_string('coursecontacts', 'theme_snap') . "</div>";
                 // Get all teacher user records in one go.
                 $teacherids = array();
                 foreach ($teachers as $teacher) {
                     $teacherids[] = $teacher['user']->id;
                 }
                 $teacherusers = $DB->get_records_list('user', 'id', $teacherids);
                 foreach ($teachers as $teacher) {
                     if (!isset($teacherusers[$teacher['user']->id])) {
                         continue;
                     }
                     $teacheruser = $teacherusers[$teacher['user']->id];
                     $userpicture = new user_picture($teacheruser);
                     $userpicture->link = false;
                     $userpicture->size = 100;
                     $teacherpicture = $this->render($userpicture);
                     $courseteachers .= $teacherpicture;
                 }
             }
             $clink = '<div data-href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '" class="courseinfo" style="' . $courseimagecss . '">
                 <div class="courseinfo-body"><h3><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . format_string($c->fullname) . '</a></h3>' . $dynamicinfo . $courseteachers . $pubstatus . '</div></div>';
             $courselist .= $clink;
         }
         $courselist .= "</div>";
         $courselist .= '<div class="row fixy-browse-search-courses"><br>';
         if (has_capability('moodle/site:config', context_system::instance())) {
             $courserenderer = $PAGE->get_renderer('core', 'course');
             $courselist .= '<div class="col-md-6">';
             $courselist .= $courserenderer->course_search_form(null, 'fixy');
             $courselist .= '</div>';
         }
         $courselist .= '<div class="col-md-6">';
         $courselist .= $this->print_view_all_courses();
         $courselist .= '</div>';
         $courselist .= '</div></section>';
         // Close row.
         $menu = get_string('menu', 'theme_snap');
         echo '<a href="#primary-nav" aria-haspopup="true" class="fixy-trigger" id="js-personal-menu-trigger" ' . 'aria-controls="primary-nav" title="' . get_string('sitenavigation', 'theme_snap') . '" data-toggle="tooltip" data-placement="bottom">' . $menu . $picture . $this->render_badge_count() . '</a>';
         $close = get_string('close', 'theme_snap');
         $viewyourprofile = get_string('viewyourprofile', 'theme_snap');
         $realuserinfo = '';
         if (\core\session\manager::is_loggedinas()) {
             $realuser = \core\session\manager::get_realuser();
             $via = get_string('via', 'theme_snap');
             $fullname = fullname($realuser, true);
             $realuserinfo = html_writer::span($via . ' ' . html_writer::span($fullname, 'real-user-name'), 'real-user-info');
         }
         echo '<nav id="primary-nav" class="fixy toggle-details" tabindex="0">
     <a id="fixy-close" class="pull-right snap-action-icon" href="#">
         <i class="icon icon-office-52"></i><small>' . $close . '</small>
     </a>
     <div class=fixy-inner>
     <h1 id="fixy-profile-link">
         <a title="' . s($viewyourprofile) . '" href="' . s($CFG->wwwroot) . '/user/profile.php" >' . $picture . '<span id="fixy-username">' . format_string(fullname($USER)) . '</span>
         </a>
     </h1>' . $realuserinfo . $courselist . $this->render_callstoaction() . '
     <div class="fixy-logout-footer clearfix text-center">
         <a class="btn btn-default logout" href="' . s($CFG->wwwroot) . '/login/logout.php?sesskey=' . sesskey() . '">' . $logout . '</a>
     </div>
     </div><!-- end fixy-inner -->
     </nav><!-- end primary nav -->';
     }
 }