Klass Theme removing New Courses feature on Front Page

Klass Theme removing New Courses feature on Front Page

by pat webber -
Number of replies: 14

I am using the Klass theme and this is adding all new courses to the front page. I only want to show enrolled courses. I have tried to select this using front page settings in Moodle but this has not worked. Would anyone have any other suggestions that could help to resolve this.


Many thanks 

Average of ratings: -
In reply to pat webber

Re: Klass Theme removing New Courses feature on Front Page

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi in this case I think you should contact the theme developer of the KLASS theme for help?

There is a Comments section on the page where you downloaded the Klass theme from.

Sorry I can't help you with this.

Regards

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Klass Theme removing New Courses feature on Front Page

by Mwambire Karisa -
Go to Site Administration >> Appearance >> Themes >> Klass under the general tab paste this CSS snippet at the custom css textarea:


#frontpage-course-list{display:none;}


The New Course feature will be hidden

In reply to pat webber

Re: Klass Theme removing New Courses feature on Front Page

by Charles Fernando -

Your contribution is dated Nov 2015! Klass is a good theme but some of these issues that have been brought up is feedback that the developer can use to market a better product if needed with a small one-time fee.

Yes, with our www.cfpscourseweb.com site we are still struggling. With reference to the issue "show only enrolled courses on the post-login Frontpage" the logic is that when someone logs in, one wants to work. So nothing else should disturb.

Please let me know how you solved the problem, in case you were successful.

It is essential that only the enrolled courses are visible post-login.

It is desirable that the administrator can turn-off the slider post-login. It would also be useful if on that page there are two columns, one on the left and the other on the right so that general announcements etc can be fitted in.

The attachment provides a sketch

In reply to Charles Fernando

Re: Klass Theme removing New Courses feature on Front Page

by Frankie Kam -
Picture of Plugin developers
Hi Charles and Pat 

I too use the Klass theme. I like its look and feel - especially the frontpage slider and call to action "Read more here" link. 

However, it did bug me that anyone could see all the new courses without logging in. I wanted a user to go to the front page, not be distracted by any new course information, login and *bam*, immediately see only those courses that he or she was enrolled in. 

Here's what I did to remove the "New Courses" title and the rectangular new course links that appear anytime anyone went to the homepage without logging in. Firstly, I modified this file:

/public_html/test/theme/klass/renderers/course_renderer.php

At around line 16, just below the function definition line of "public function new_courses()", I inserted a simple return; statement. That's all.



In addition, for my Frontpage settings, I make sure that I set to the "Front page items when logged in"  setting to Enrolled courses.



The effect of the hack and the Frontpage setting is this: now, the "New Courses" text is no longer displayed, and you will not see any New Courses blocks (rectangular links). Here's the effect on my frontpage:

Before my hack:


Well as you can see, without my hack, any user that doesn't log in can see all the "New courses".

After my hack, the frontpage looks like this to any guest:



No more "New courses" information.


After my hack, the user logs in and the frontpage looks like this to him or her:


So the student now sees only the courses that he or she is enrolled in. Voilà it's magic!

I have one more "improvement" to share. I felt that that course thumbnail image was too small. I'm referring to that image that shows students writing at their desks. 


BTW, in case anyone reading this post doesn't know, that image comes from the Course Summary uploaded image file. You upload that image file by going into a course, access the Administration block, click on the "Course Administration" -> "Edit settings", and upload an image file in the "Course Summary" section). 

So I increased its size and the size of the box outline surrounding it, by using this custom CSS code:

.coursebox .content .courseimage img {
    max-width: 200px;
    max-height: 200px;
}

.coursebox .content {
    min-height: 150px!important;
}

In Moodle, I went to Site administration -> Appearance -> Themes -> Klass -> Header 
and inside the Custom CSS section, I type in the above CSS code:


Now the enrolment course image and its surrounding box is a bit larger:


The thumbnail image is now larger, and I think more eye-catching. it's all about the design, baby!

Hope this helps. In fact if you are helped by any of this, please click the "Like", erm... I mean, "Useful" link. 

Regards
Frankie Kam 
Voted "Most Helpful Moodler of 2017"
(I am claiming this award in advance. Harhar!!)


Average of ratings: Useful (3)
In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by Frankie Kam -
Picture of Plugin developers

Hi Charles and Pat 

If you just want to have the "New courses" and "My courses" sections to swap places, you can by editing this file:

/public_html/moodle/theme/klass/layout/frontpage.php

Specifically, comment off the code "echo $courserenderer->new_courses();" at around line 89, and then copy and paste in that exact same line to around line 94, after the line "echo $OUTPUT->course_content_footer();". A picture is worth a zillion words, so here's what I mean:



Here's what my course looks like if I maintain the "New courses" section, but I swap the locations of the "New courses" and "My courses" sections:

Part 1 - before logging in



Part 2 - after logging in


Observe that the "New courses" and "My courses" sections have swapped. So this means that the student will be greeted first with his list of courses that he or she is enrolled in, and can still access the "New courses" by scrolling down. In my humble opinion, this will be be usable for the student so that they do not need to wade through scores of new course rectangles before being able to see their enrolled courses - which is the case now on your website.

Is this what you want? 

Regards
Frankie Kam 

P.S.,
Yet another improvement on this is to make the "New courses" section an accordion. Hidden by default, but when the user clicks the "New courses" words, the new course rectangles will appear accordion fashion. In this way, you can make the frontpage less cluttered. Hmm...let's see if I can't implement this in my next post. Mad scientist at work. Do not disturb.

Average of ratings: Useful (3)
In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by Frankie Kam -
Picture of Plugin developers

Hi Charles and Pat 

My previous post above, I think, solves your need of having the "My courses" section come before the "New courses" section,
as per your illustration that you attached in your post:

So this post contains an optional design addition - the "Accordion" technique of reducing clutter on the frontpage. I am happy to report that I have emerged from my laboratory with a sample solution. First I will show you what I've done. Then I will show you how I did it. If it's helpful, don't forget to vote me as the most helpful Moodle of 2017 on moodle.org. I need your votes.

Before I ramble on, I need to mention on my Moodle site, that I changed the words "New courses" into "New modules", and the words "My courses" into "My modules" using Home  ► Site administration  ► Language  ► Language customisation

So on my website, I display "New modules" in place of "New courses" and "My modules" in place of "My courses". But I bet that you have figured that one out.  Now that's out of the way, let me proceed.


Part 1. WHAT FRANKIE DID

I converted the "New courses" link into an accordion hyperlink. The screen below shows my Moodle website being viewed by a guest (not logged in yet). Nothing shows below the "New courses" words until I click on it. 



Now I click on the link "New courses" (my "New modules"). The new course rectangular links appear.



The screen below shows you my frontpage after a user has logged in. He or she only sees the enrolled courses. And the "New courses" link is displayed, to be clicked upon if the user so wishes to.




If the user clicks the "New courses" (my "New modules") link, the full set of new courses will appear in accordion style.



So what have I achieved with this alchemy? I have de-cluttered my frontpage.


Part 2. HOW FRANKIE DID IT

2.1 Go to Site administration -> Appearance -> Themes -> Klass -> Header  and inside the Custom CSS section, type in the below CSS code:

       a.accordion {
           /* background-color: #eee; */
           color: #444;
           cursor: pointer;
           padding: 18px;
           width: 100%;
           border: none;
           text-align: left;
           outline: none;
           font-size: 15px;
           transition: 0.4s;
       }

       a.accordion.active, button.accordion:hover {
       /* background-color: #ddd; */
       }


       div.panel {
           padding: 0 18px;
           background-color: white;
           max-height: 0;
           overflow: hidden;
           transition: max-height 0.2s ease-out;
       }


2.2 Create a subfolder named javascript inside the klass folder

2.3 Create a javascript file named accordion.js with this code inside it:

       var acc = document.getElementsByClassName("accordion");
       var i;
       for (i = 0; i < acc.length; i++) {
         acc[i].onclick = function() {
           this.classList.toggle("active");
           var panel = this.nextElementSibling;
           if (panel.style.maxHeight){
            panel.style.maxHeight = null;
           } else {
            panel.style.maxHeight = panel.scrollHeight + "px";
           }
         }
       }


2.4 Store the accordion.js file inside the javascript subfolder



2.5 Edit the file /public_html/moodle/theme/klass/config.php
       and insert this line of code in it: $THEME->javascripts_footer = array('accordion'); 
       Like so:


Save your config.php file.


2.6  Edit your /public_html/moodle/theme/klass/renderers/course_renderer.php file (make sure you backup the original php file first!)

       Add in the yellow highlighted snippets of code:


Save your /public_html/moodle/theme/klass/renderers/course_renderer.php file.

That's it! I hope this helps. You may or may not want to do it this way, but at least you now know what is possible. 


You said:
It is desirable that the administrator can turn-off the slider post-login.
>

Do you want the slider to be automatically hidden after the user has logged in?
Or do you want the slider to still show after the user has logged in, and the user can click a link/button to toggle-hide the slider? In which case an accordion link might be what you are looking for. The solution is similar to how I toggled on and off the "New courses" section.

You said: 
> It would also be useful if on that page there are two columns, one on the left and the other on the right so that general
>announcements etc can be fitted in.
>

As for this requirement I don't know yet how to add the extra left and right columns to the Klass theme. Perhaps someone else can assist you on this. I'm not a huge fan of a three-column frontpage because I think it makes the Moodle website look cluttered. But then, it's your website so the design is up to you.

My work is done here - for now. I can go for my lunch now, haha. In the meantime, keep calm and Moodle on! wink

Cheers and best regards 
Frankie Kam 
References:
http://www.w3schools.com/howto/howto_js_accordion.asp
http://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_accordion_animate

Average of ratings: Useful (2)
In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by Charles Fernando -

Dear Frankie Kam,

You are really great and most helpful. You have done a lot of work on the issue. Yes, really great and I believe others using the Klass theme will also profit. We here agree with you that the theme is a good one.

Since my post the technical person who is busy but helps us with special problems when needed did a small adjustment to show those "enrolled in" before the "new courses". I will now discuss your contribution with him and solve the problem effectively and fine-tune things.

We are quite happy to leave things as two columns without bothering about three.

As for the slider, yes, we would be quite happy to make "the slider to be automatically hidden after the user has logged in". Any suggestion would be most welcome.

With all good wishes,

Charles

In reply to Charles Fernando

Re: Klass Theme removing New Courses feature on Front Page

by Frankie Kam -
Picture of Plugin developers

Hi Charles

Thank you and you are most welcome! wink

You said:
>"As for the slider, yes, we would be quite happy to make "the slider to be automatically hidden after the user has
>logged in". Any suggestion would be most welcome."
>

Here's my suggestion. And I've tested it on my site already. So I know it works. But you will have to test it for yourself.

To show the slideshow and title and description when the user is not logged in, you will need to edit this file:
/public_html/moodle/theme/klass/layout/frontpage.php


Before:


After:


Here is the same "After:"  code, but with the differences highlighted more clearly in yellow background:


Finally I've attached the code of that section (from lines 50 to 85) taken from the 3rd screenshot.
See the attached file named "code_fragment.txt".

Hope this helps.

Regards
Frankie Kam 

P.S.,
Proof it works - Disclaimer: at least on my site. wink
here's what my site looks like when the Guest is looking at it - the user has not yet logged in:



Here's what my site looks like immediately after I log in:


Enjoy! 
P.S.2 the best tea comes from Sri Lanka - I think.


Average of ratings: Useful (1)
In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by Charles Fernando -

Dear Frankie,

Thank you so much. Once again you have done work and we rated it too. During the coming week we hope to put things in order at our site following your suggestions. Once again I really hope others using the theme and had problems notice what you have contributed.

Kind regards

Charles



In reply to Charles Fernando

Re: Klass Theme removing New Courses feature on Front Page

by Frankie Kam -
Picture of Plugin developers

Hi Charles

You are most welcome. big grin

Regards Frankie 

In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by ling yang -
I want to add show " Most active courses" Module below "New courses" Module,Thank you kindly for any help you can offer.
In reply to ling yang

Re: Klass Theme removing New Courses feature on Front Page

by Frankie Kam -
Picture of Plugin developers

Hi Ling Yang

What version of Moodle are you using?

Regards
Frankie Kam 

In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by Peshali Randika -

Hi all,

I am using Moodle 3.3.  Before it doesn't show the 'New Courses' in front page.

Now it is displaying. I removed it because I want to hide some courses.

But I want to know the reason to display New courses suddenly  :|


Regards,

Peshali

In reply to Frankie Kam

Re: Klass Theme removing New Courses feature on Front Page

by Kassie Phillips -

Hi Frankie,

I was wondering if you might be able to help with making the enrolled courses "My Courses" appear more like the "New Courses" I hope to use your hack (thank you!) to get rid of the New Courses entirely as I only want to show enrolled courses, however, I don't like the way the enrolled courses look and would like to reduce scrolling.
I've had play (attached) but cant get it to look the same.. I am no coder sad



Attachment KLASS Enrolled Courses.PNG