I'm new to moodle plugin development and on task to develop a plugin with certain functionalities. Breaking it down into small steps my first goal is to create a plugin that can show another Page based on the "select" made in the activation of this activity_plugin inside a course.
Therefore I created a select form in "mod_form.php" to select between 3 Options:
$simaids = Array(So if one Option is selected there should be a value iE 'aid2', this value needs to be added to an URL that will be shown in "view.php" via:
'aid1' => 'Simulation 1',
'aid2' => 'Simulation 2',
'aid3' => 'Simulation 3',
$mform->addElement('select', 'simaids', 'Simulation', $simaids);
$simulation = file_get_contents('https://myurlexample.com/'.'$simurl');So depending on the option the URL differs.
The current challenge for me is to retrieve the parameter from "mod_form.php" and use it in "view.php".
I checked for a soultion and found many possible solutions which I hadn't had success using until now. These solutions are:
- require_once mod_form.php and stating the variable setting it to be equal to $simurl
- $_Session - as I am not sure if it will work for a user who is just inside the course and clicking on the plugin
- POST and GET as far as I understand it works with adding parameters to the URL which should nit work as the POST will only be done once when activating the plugin?
- Saving the Form Select Input to some table which I can access from "view.php"(but I don't know if this requires to write a new function to create a table or if it's already stored somewhere
As you might have guessed I'm not only new to moodle but pretty much programming in php. Currently I just try to find another example to understand how to extract it, but most plugins seem too complex for me right now to get the gist where to look at like (mod_game_moodle).
I'm glad for any advice you mind sharing that will help me to achieve a better understanding of moodle plugin development.