include_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
 // Checking command.
 if (!isset($SESSION->vmoodle_sa['command'])) {
     $SESSION['vmoodle_sa']['wizardnow'] = 'commandchoice';
     return 0;
 }
 // Getting retrieve platforms command
 $command = unserialize($SESSION->vmoodle_sa['command']);
 $rpcommand = $command->getRPCommand();
 if (is_null($rpcommand)) {
     return 0;
 }
 // Invoking form.
 $rpcommand_form = new Command_Form($rpcommand, Command_Form::MODE_RETRIEVE_PLATFORM);
 // Checking if form is submitted.
 if (!($data = $rpcommand_form->get_data())) {
     return 0;
 }
 // Setting parameters' values.
 $rpcommand->populate($data);
 // Sending command on available platforms
 $platforms = get_available_platforms();
 $rpcommand->setReturned(true);
 $rpcommand->run($platforms);
 // Removing failed platforms.
 foreach ($platforms as $host => $platform) {
     if (!($rpcommand->getResult($host, 'status') == RPC_SUCCESS && $rpcommand->getResult($host, 'value'))) {
         unset($platforms[$host]);
     }
 }
 // Saving selected platforms in session.