General help

 
 
Picture of Константин Елшанский
Help find replacement for get_and_set_current_group()
 

Good day for everyone. I need to replace the old function get_and_set_current_group() with new equivalent. Using moodle search and google I only have found information that it's deprecated. Can you tell me how I should replace it?

This is a fragment of code;

GLOBAL $cm,$course,$CFG,$USER;
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
print_error('badcontext');
}

$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
$groupmode = groupmode($course,$cm);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);

 

Thanks!

 
Average of ratings: -
Picture of Olja Petrovic
Re: Help find replacement for get_and_set_current_group()
 

Take a look at groups_get_course_group() in lib/grouplib.php. It "Returns group active in course, changes the group by default if 'group' page param present".

Like in this patch

http://fisheye.moodle.org/rdiff/Moodle?csid=ffc536af8e068a6e8e3c46432bca0473b289ed35&u&N

Look at the code of the function, now the part

$changegroup = optional_param('group', -1, PARAM_INT);

appears to be done inside the function itself.

Any help?

Good luck.

 
Average of ratings: -
Picture of Константин Елшанский
Re: Help find replacement for get_and_set_current_group()
 

Thanks, this function has replaced several code strings in old module.

However, I have a new problem.

print 'bla-bla'.get_string('task','bacs').'bla-bla'; 

doesn't work. I'm getting this error " Invalid string identifier. The identifier cannot be empty. Please fix your get_string() call.".

Why? I have normal identifier task and translation in directory lang inside module. A lot of other get_strings works.

 
Average of ratings: -
Picture of Olja Petrovic
Re: Help find replacement for get_and_set_current_group()
 

'bacs' is the name of a module as in /mod/bacs?

And there is a /mod/bacs/lang that contains both your language directory and /mod/bacs/lang/en/bacs.php? And you have added the string in the English file also? That could give an error.

 
Average of ratings: -