Forums | Mahara Community

Developers /
Change the order of the progressbar


12 May 2017, 20:39

Hello,

I would like to change the order of the institutions in the progress bar. By default there is the raw theme, and I would like to replace it with the current theme / institution.

I found the artefact_get_progressbar_items function in artefact/lib.php, and I read that I can use the function local_progressbar_sortorder in the local folder, but how can I do it ?

Thank you for your help ! laughing

Robert Lyon's profile picture
Posts: 749

29 May 2017, 11:26

Hi Antonella,

I'm not quite sure what you are meaning? Are you taking about the institution selector in the Profile completion sidebar?

progressbar.png

If it about that selector then the institution that appears first on the list is the institution that appears first for a user. Currently there is no way to force a particular institution to appear first by default. If you wanted to do this manually then you would need to make a change in the progressbar_sideblock() function.

If the user is in only one institution then they don't see the selector at all.

 

Or are you meaning something else? if so can you describe the page/place you see it

Cheers

Robert

29 May 2017, 19:43

Hello Robert,

Thank you for your help !

I change the function progressbar_sideblock and it works :

// Set user's first institution in case that institution isn't
// set yet or user is not member of currently set institution.
if (!$institution || !array_key_exists($institution, $institutions)) {
$institution = get_current_theme_value(); // key(array_slice($institutions, 0, 1))
}

 In this way the user can sees the current institution as the first institution cool

Kristina Hoeppner's profile picture
Posts: 4717

30 May 2017, 5:15

Hello Antonella,

This sounds like a good idea. Do you want to submit it for inclusion into Mahara core?

Cheers

Kristina

 

15 June 2017, 23:13

Hello Kristina,

Yes if you want !

I create a simple function (probably it's not the mahara style) :

/**
* Get the theme of the current institution
* @return mixed
*/
function get_current_theme_value()
{
global $USER;

$usrinstval = get_field_sql('SELECT i.name iname
FROM usr_account_preference ui
INNER JOIN institution i
ON CONCAT(i.theme, \'/\', i.name) = ui.value
WHERE ui.usr = ?', array($USER->id));


if(!empty($usrinstval))
{
return $usrinstval;
}
else
{
return 'raw';
}
}

And after in lib/mahara.php in the function progressbar_sideblock I replace the line $institution = key(array_slice($institutions, 0, 1)); with $institution = get_current_theme_value();

 

Robert Lyon's profile picture
Posts: 749

16 June 2017, 11:12

Hi Antonella,

I've taken your idea and have added it as a patch to our reviews system

https://reviews.mahara.org/#/c/7826/1

I made a couple of changes, the main difference is I fetched the user's account theme via the $USER object rather than a SQL query and had the fallback to the default institution 'mahara' rather than the default theme 'raw'

Cheers

Robert

6 results