Exemplo n.º 1
0
 /**
  * Returns the HTML code to print the user interface
  */
 public function ui()
 {
     global $PAGE;
     $output = $PAGE->get_renderer('mod_teamwork');
     $m = optional_param('m', null, PARAM_INT);
     // status message code
     $message = new teamwork_message();
     if ($m == self::MSG_SUCCESS) {
         $message->set_text(get_string('randomallocationdone', 'teamworkallocation_random'));
         $message->set_type(teamwork_message::TYPE_OK);
     }
     $out = $output->container_start('random-allocator');
     $out .= $output->render($message);
     // the nasty hack follows to bypass the sad fact that moodle quickforms do not allow to actually
     // return the HTML content, just to display it
     ob_start();
     $this->mform->display();
     $out .= ob_get_contents();
     ob_end_clean();
     // if there are some not-grouped participant in a group mode, warn the user
     $gmode = groups_get_activity_groupmode($this->teamwork->cm, $this->teamwork->course);
     if (VISIBLEGROUPS == $gmode or SEPARATEGROUPS == $gmode) {
         $users = $this->teamwork->get_potential_authors() + $this->teamwork->get_potential_reviewers();
         $users = $this->teamwork->get_grouped($users);
         if (isset($users[0])) {
             $nogroupusers = $users[0];
             foreach ($users as $groupid => $groupusers) {
                 if ($groupid == 0) {
                     continue;
                 }
                 foreach ($groupusers as $groupuserid => $groupuser) {
                     unset($nogroupusers[$groupuserid]);
                 }
             }
             if (!empty($nogroupusers)) {
                 $list = array();
                 foreach ($nogroupusers as $nogroupuser) {
                     $list[] = fullname($nogroupuser);
                 }
                 $a = implode(', ', $list);
                 $out .= $output->box(get_string('nogroupusers', 'teamworkallocation_random', $a), 'generalbox warning nogroupusers');
             }
         }
     }
     // TODO $out .= $output->heading(get_string('stats', 'teamworkallocation_random'));
     $out .= $output->container_end();
     return $out;
 }