Netflix-like frontpage in Moodle

Netflix-like frontpage in Moodle

by Harm Hofstede -
Number of replies: 30

I would like a "Netflix-like" frontpage in Moodle, showing interesting courses for my pupils like:

1. New courses

2. Popular courses

3. Courses now followed

4. Interesting for you (based on course-tags)

5. More in this category

6. More for you (based on info in user-profile)

etc.

Does something like this excist or is it possible to have anyone build this for me?

Kind regards,


Harm Hofstede

Using Moodle 3.1 on http://www.koekelen.nl/moodle (in dutch, for primary schools)

Average of ratings: -
In reply to Harm Hofstede

Re: Netflix-like frontpage in Moodle

by Olumuyiwa Taiwo -
Picture of Plugin developers

Try searching the Moodle Themes directory (https://moodle.org/plugins/browse.php?list=category&id=3) to see if there's anything there that meets your needs. To find people who may be able to build it, you can post a message in the Moodle jobs database (https://moodle.org/mod/data/view.php?d=54)

In reply to Olumuyiwa Taiwo

Re: Netflix-like frontpage in Moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

And it may be possible to achieve a Netflix like front page by using the Lightbox gallery option. There are a number of plugins that might help you do this, but I have never considered the possibility. Interesting idea though.  

In reply to Colin Fraser

Re: Netflix-like frontpage in Moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

As a thought... It would be hard to assess what courses people take and what courses they may be interested in. One person may be interested in Physics, Chemistry and underwater basket weaving. Another may be interested in photography, but only take a language and literature as the "courses you may be interested in" does not mention photography. Be a real good trick though.  

In reply to Harm Hofstede

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I could build it.  I already have some basic structure done.  It wouldn't be that hard to modify the code.  My theme uses a Featured Courses Slider option where all you do is put in the ID of the courses you want featured  and it pulls a custom image, title, and course summary directly from the courses.   

Check out Pioneer and the bottom featured course slider.  

The nice part about Pioneer is that you can upload images into the course summary file area and it will make that the custom header as well as use that image throughout the site.

I like your idea and I may put this in place for my next release.

Check it out and let me know if it kinda meets your needs.


Although the tagging and more for you might be a stretch.  I can add a link that would take them to a course category below the slider.  

Average of ratings: Useful (1)
In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

That sounds pretty promising Chris, be a nice feature for a theme. Also might tart Moodle up a bit for users who like a more modern approach..smile 

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I am exploring something that might look like this using the Pioneer theme:



What do you think?

Average of ratings: Useful (8)
In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Wow! That looks great Chris, terrific work. 

If I may, this could be used as the dashboard, so I think it is likely that the user would prefer their existing enrollments be displayed in the first group. The next group would then be Featured Courses, but the issue may then be what does that particular user need to go to next. If they are on a defined and heavily proscribed course of underwater activities they will not be wanting to look at courses involving building skyhooks, if I am making myself clear. After that it would then break into segmented groupings of specialist courses based on disciplines, Maths, Science, and so on, but then refining it further, could lead to each  Maths-Algebra, Maths-Calculus and so on. So the question would be how can the Admin, when setting this up, do it so as to suit their particular institutional need?  

Please, do not allow anything I have said here put you off, because this is an excellent idea, really worth following up. Just throwing in my perspectives, Cheers. 


In reply to Colin Fraser

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

If I was a better programmer I am sure it could be done based off of a user profile field.  The adaptable theme mentions some ability to show items based on profile fields.  I might take a look there and see if I can gleam some type of features like that.

It might be possible to match profile tags with course tags and display a custom listing of suggested courses.

But I wouldn't know how to do it.  It would make a killer feature for a theme though!!!  I will see if I can enlist the help of some of the better programmers. 

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Harm Hofstede -

I really appriciate your ideas and your will to help! I am not a programmer at all, otherwise I would really like to help too!

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Chris,
Haven't worked out any code yet (the examples are 'psuedo-code' from my head not tested sql or code!) - just brainstorming some ideas about the tags idea, and using this as an aide memoire smile

It looks like the main table we need is the tag_instance:
For user x find all tagids as an array
Find all tagids that have 'course' as an itemtype and list the itemid for those tags_instances into an array (itemid for itemtype=course is the course id number)
Parse that array so we only have one unique instance of each course id

I think that can all be wrung down to one sql query, something like:

SELECT DISTINCT itemid WHERE itemtype='course' AND tagid IN(SELECT tagid WHERE itemtype='user' AND itemid=$USER->id)

Use the $DB api to get records for a query like that into an array and use that array in place of the setting in your existing setting in your featured courses slider.

Put like that it doesn't seem to be too complex - actually making it work in the code and not too heavy on the database on a large site might be the key to it though - ensuring it doesn't hit performance too much smile

In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers
This sounds pretty easy to implement!  Easier than what we discussed earlier.   


Can we set a limit for queries so it won't go crazy? 

Let me know what you'd like me to do to test.

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Chris - add this into your code (at the moment this replaces the setting, but I'm sure you/we can come up with something that enables both - either by displaying the featured courses renderer twice, sending it a value of which to use, or by an admin setting to opt one or the other smile )

It appears to work - although I don't have access to a large site to test it on right now (and probably better not experiment on my live site in work tomorrow! smile ). I've just tested it with a limited 3 users and 10 courses with tags. The user tags are the Interests from the profile.

    public function promoted_courses() {
        global $CFG, $OUTPUT, $DB, $PAGE, $USER;

        $featuredcontent = '';
        /* Get Featured courses id from DB */
        $sql = 'SELECT DISTINCT itemid FROM {tag_instance} WHERE itemtype = "course" AND tagid IN(SELECT tagid FROM {tag_instance} WHERE itemtype = "user" AND itemid = '.$USER->id.')';
        $featuredidsarray = $DB->get_records_sql($sql, array());
        $featuredids = '';
        foreach ($featuredidsarray as $fid) {
            $featuredids .= $fid->itemid.',';
        }
//
        $featuredids = theme_pioneer_get_setting('promotedcourses');

Looking forward now to adding this to flexibase too!

Average of ratings: Useful (1)
In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

On frontpage.php

echo $courserenderer->promoted_courses('tags');
echo $courserenderer->promoted_courses('setting');

In renderer, something like this should default it to using the admin setting, but if the word 'tags' is passed will do the tag comparison.

    public function promoted_courses($type) {
        global $CFG, $OUTPUT, $DB, $PAGE, $USER;

        $featuredcontent = '';
        /* Get Featured courses id from DB */
        $featuredids = theme_pioneer_get_setting('promotedcourses');
       if ($type == 'tags') {
            $sql = 'SELECT DISTINCT itemid FROM {tag_instance} WHERE itemtype = "course" AND tagid IN(SELECT tagid FROM {tag_instance} WHERE itemtype = "user" AND itemid = '.$USER->id.')';
            $featuredidsarray = $DB->get_records_sql($sql, array());
            $featuredids = '';
            foreach ($featuredidsarray as $fid) {
                $featuredids .= $fid->itemid.',';
            }
     }


In the same way, it could have other options for getting the list of 'featured' courses, just by passing a different keyword and a section working out exactly what set of courses you want to pass into the $featuredids variable - anything from another way to present 'My Courses', 'All courses' on a small site, courses in a specific category (its a shame categories dont have tags smile ), new courses (set up since...) maybe even courses with recent activity (from the MyCourses list? - on the Dashboard, rather than front page? )

For example - your top promoted courses renderer could reuse the same renderer by passing 'top'. If the conditionals that get the course ids also included some logic to get the right title and other language strings... smile

Oh, the possibilities  go on and on!

Average of ratings: Useful (1)
In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

I think what I'd like to do now is go back to what I did in Flexibase v2.0 with the concept of 'components' and develop this and the radials and a few other things as code snippets that anyone could drop in regardless of the theme being used.

Some of these ideas we've shared recently are too powerful to be kept in just one or two themes, they need to be shared (in an easy way, I know you and Gareth and Mary and a few others could pick them apart and implement them if they wanted, but I'd like to see them available as 'theme modules'/'components' (don't really care what we call them, just want to see them shared and used :D )

I wish I was free and available to present at the iMoot about some of these developments!!! I think they would be great to share there, Chris!

Richard

Average of ratings: Useful (2)
In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I think the tags and recently active courses would be ideal to start with.  

I will need to think this through tomorrow and see how it could best be implemented.  

This is exciting stuff!   

Is there a way to use tags and a fallback array if no matches are found?  That would be ideal.

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

It could default to the admin setting you already have - actually the second code I gave https://moodle.org/mod/forum/discuss.php?d=332988#p1342756 would start with the admin setting and add the personalised on, so ideally that probably needs a quick line to exclude that when they are not wanted, or to - as you suggest - default to it if there are no tags.

Probably does then need a 'catch all' to either return null if there are no tags AND no setting, or some way to just generate a random list of courses.

$settingfeaturedcourses = get from setting

$tagsfeaturedcourses = get from tags

$randomfeaturedcourses = for loop = 1 to x,  get random course id, add to string next

if $type == 'tags' AND $tagsfeaturedcourses != NULL then use $featuredids = $tagsfeaturedcourses

elseif $settingfeaturedcourses != NULL then use $featuredids = $settingfeaturedcourses

else $featuredids = $randomfeaturedcourses

In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Actually, I was tinkering and I am thinking that if there are no matching courses it should just remain hidden. 

I am also trying to take out H2 heading from the renderer and I will use another means to display the titles.  My idea is that on the admin page the site admin can enter in text for both recommended and featured course sliders.  If tags are found it would display the tag text along with the tagged courses.  Same for featured.  

 Initially, just playing around I did this:

 if($courserenderer->promoted_courses('tags')) {echo ('<h2>Recommended for you...</h2>'); } 

 echo $courserenderer->promoted_courses('tags');

I would replace the "Recommended for you..." text with the theme setting that a site admin enters.

It seems to work and is simple enough.  It would be cleaner to put this into the course renderer, so maybe that is the next step so that if we re-use the function for various "types" then we can also use the proper heading text for each output.  

In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Richard, 

In the course renderer, line 166  https://github.com/kennibc/moodle-theme_pioneer/blob/master/renderers/course_renderer.php#L166

Can we make the $promotedtitle into an "if" statement.

Where if (type=tags) show this theme text setting, if (type=settings) show this theme text setting?

So based on the type it will retrieve the proper heading text?

$promotedtitle = theme_pioneer_get_setting('promotedtitle', 'format_text');


Maybe use something like these below which would need to be added to the Theme Settings page?

theme_pioneer_get_setting('settingtitle', 'format_text')

theme_pioneer_get_setting('tagtitle', 'format_text')

Would that solve the issue of featured course heading text most efficiently?

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Yes it would work like that Chris

I'm planning to look at that side of the implementation this evening/weekend (as well as getting it into Flexibase smile ), but that's the general idea - although I do have a thought about making it more generic again, of passing something like $type.'title' as the identifier:

$promotedtitle = theme_pioneer_get_setting($type.'title', 'format_text');

But having some sort of error catching to make sure it was always some valid value there.

My thought is to make the code as generic and reusable as possible, for adding other possibilities in the future without too much interference with the code itself smile

Average of ratings: Useful (1)
In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Richard,

I worked it out using this starting around line 130:

---------------------------------------------------------------------------------

public function promoted_courses($type) {

        global $CFG, $OUTPUT, $DB, $PAGE, $USER;


        $featuredcontent = '';

        /* Get Featured courses id from DB */

        $featuredids = theme_pioneer_get_setting('promotedcourses');

        if ($type == 'tags') {

            $sql = 'SELECT DISTINCT itemid FROM {tag_instance} WHERE itemtype = "course" AND tagid IN(SELECT tagid FROM {tag_instance} WHERE itemtype = "user" AND itemid = '.$USER->id.')';

            $featuredidsarray = $DB->get_records_sql($sql, array());

            $featuredids = '';

            $promotedtitle = theme_pioneer_get_setting('promotedtag', 'format_text');

            $promotedlinktext = theme_pioneer_get_setting('promotedtaglinktext', 'format_text');

            $promotedlink = theme_pioneer_get_setting('promotedtaglink', 'format_text');

            foreach ($featuredidsarray as $fid) {

                $featuredids .= $fid->itemid.',';

            }

         }

        if ($type == 'setting') {

            $promotedtitle = theme_pioneer_get_setting('promotedtitle', 'format_text');

            $promotedlinktext = theme_pioneer_get_setting('promotedlinktext', 'format_text');

            $promotedlink = theme_pioneer_get_setting('promotedlink', 'format_text');

        }


        $featuredcontent = '';

        /* Get Featured courses id from DB */

---------------------------------------------------------------------------------------

Moving the title, text and link url into the if statement and then removing those three items from the original location worked.   Now I just have to add the theme admin settings for promotedtag items and it can utilize the same function with types.

Maybe this was what you were thinking???

Average of ratings: Useful (1)
In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Pretty close Chris, yes.

I've taken some of the language settings out - they can always be changed in the language customisations anyway, so mine looks like

    public function promoted_courses($type) {
        global $CFG, $OUTPUT, $DB, $PAGE, $USER;

        $featuredcontent = '';
$featuredids = '';
        $promotedlinktext = get_string('promotedcourseslinkdefault', 'theme_flexibase');
        $promotedlink = $CFG->wwwroot.'/course/index.php';

        /* Get tagged courses from DB */
        if ($type == 'tags') {
            $sql = 'SELECT DISTINCT itemid FROM {tag_instance} WHERE itemtype = "course" AND tagid IN(SELECT tagid FROM {tag_instance} WHERE itemtype = "user" AND itemid = '.$USER->id.')';
            $featuredidsarray = $DB->get_records_sql($sql, array());
            foreach ($featuredidsarray as $fid) {
                $featuredids .= $fid->itemid.',';
            }
            $promotedtitle = get_string($type.'coursestitle', 'theme_flexibase');
        }
        /* Get promoted courses from setting */
        if ($type == 'setting') {
            $featuredids = theme_flexibase_get_setting('promotedcourses');
            $promotedlinktext = theme_flexibase_get_setting('promotedlinktext', 'format_text'); //Override default.
            $promotedlink = theme_flexibase_get_setting('promotedlink', 'format_text'); //Override default.
            $promotedtitle = get_string($type.'coursestitle', 'theme_flexibase');
        }
/* Get My Courses list */
if ($type == 'my') {
$courses = enrol_get_all_users_courses($USER->id);
foreach ($courses as $fid) {
$featuredids .= $fid->id.',';
}
$promotedtitle = get_string($type.'coursestitle', 'theme_flexibase');
}
        /* Add other Types and their course identifying logic here. */

I left the $promotedtitle in the conditionals as an error trap. By using $type.'coursetitle' it should always return a title, but if someone calls the function without a $type declared, or with a typo, then this way it wont throw an error out for a missing language string. All that will happen, if there is no recognised $type is there will be no logic applied to fetch the course ids and so the later check to see if there are any identified courses will throw the function back as false anyway.

I decided to go without the 'fall back' option of displaying the admin set courses if there were no tags - which I think you said in your post as well is how you decided to go too. If there are no matching tags, return false; if there is no admin list of promoted courses, return false - but I am calling them as two separate instances.

Haven't got to the Recent Activity one I suggested yet - that's next on the list smile


In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

This is cutting edge stuff!  Personalized learning is gaining traction and is the big buzz over here.  Glad to see this organic activity and community coming together to build better learning  tools here with Moodle!

In reply to Richard Oelmann

Re: Netflix-like frontpage in Moodle

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

This could be huge for developing personalized course suggestions and a step forward for implementing more personalized learning!

In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

That would be a given wouldn't it? Such a great idea!!!



In reply to Chris Kenniburg

Re: Netflix-like frontpage in Moodle

by Harm Hofstede -

Hello Chris,


Thanks a lot! for your replies - this looks very promising.

First I have to set up my project before we are going to work on Moodle, but it's really great to know that Moodle might be our solution!


Best regards,

Harm

In reply to Harm Hofstede

Re: Netflix-like frontpage in Moodle

by Dom F -

Im always hoping Moodle can find a way to look MUCH better than it does!

Can you clarify which of these styles you are aiming for?

https://www.google.co.uk/search?q=netflix+front+page&espv=2&biw=1036&bih=622&tbm=isch&tbo=u&source=univ&sa=X&ved=0ahUKEwjR4PjtgOHMAhUG1hoKHZ3MCnQQsAQIGw

I will also reach out to Chris as I'd love to know what he has done (or see it) 

THIS is our front page in Drupal (brand site) 

THIS is our front page in Moodle 

So you can see how we'd love to make the front page look anything but like Moodle!

In reply to Dom F

Re: Netflix-like frontpage in Moodle

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Dom -

There are many new themes that take advantage of all of the new display possibilities of Moodle. Its not that difficult any more to make Moodle look as beautiful as you want, and make it responsive to all devices. There are a lot of examples in this discussion - https://moodle.org/mod/forum/discuss.php?d=314373

Some examples from there:

You can definitely make the front page look much different than it does now.

In reply to Mike Churchward

Re: Netflix-like frontpage in Moodle

by Dom F -

Hi Mike

Both of those examples look fantastic. But if I install another theme on top of the base theme and current custom theme I have, will that not cause a minor catastrophe for the rest of the site? if not how would I avoid that having taken months to correct all the content for the current theme! smile

If it would do that - is there not some sort of plug in that will allow me JUST  to change the front page - as per your beautiful looking examples? Our front page is the worst looking part of our site - and thats such a pity.

In reply to Dom F

Re: Netflix-like frontpage in Moodle

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Dom -

"But if I install another theme on top of the base theme and current custom theme I have, will that not cause a minor catastrophe for the rest of the site?"

Perhaps? I wasn't suggesting that you take one of those and attempt to just drop it in. I just wanted you to know that you can, with the current state of Moodle, create some pretty visually stunning sites. This is not your father's 1.9! wink

"is there not some sort of plug in that will allow me JUST  to change the front page"

You may not need any plugins. You do have some control over what themes apply to what pages of the site. If you go to "[yoursite]/admin/settings.php?section=themesettings", you can enable things like course and category level themes, and then set those to different themes than the site's. So you could use a new theme as the general site theme, and then use your existing ones for courses.

It may work.

mike

Average of ratings: Useful (1)