/**
  * Defines forms elements
  */
 public function definition()
 {
     global $PAGE, $CFG;
     $PAGE->requires->jquery();
     $PAGE->requires->jquery_plugin('ui');
     $PAGE->requires->jquery_plugin('ui-css');
     $PAGE->requires->js('/mod/codeactivity/js/codeactivity.js');
     $PAGE->requires->js('/mod/codeactivity/js/ace/ace.js');
     $mform = $this->_form;
     //echo '<pre>'.print_r($this, true).'</pre>';
     /* Check to see if there are languages set, and if not display
      * a message.  The $languages variable is going to be used later
      * as well when the select box for languages is displayed. 
      */
     $languages = codeactivity::getLanguages();
     if (empty($languages)) {
         $mform->addElement('html', '<p class="ca-error">' . get_string('err_nolanguages', 'codeactivity') . '</p>');
     }
     //-------------------------------------------------------------------------------
     // Adding the "general" fieldset, where all the common settings are showed
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Adding the standard "name" field
     $mform->addElement('text', 'name', get_string('codeactivityname', 'codeactivity'), array('size' => '64'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEAN);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addHelpButton('name', 'codeactivityname', 'codeactivity');
     // Adding the standard "intro" and "introformat" fields
     $this->add_intro_editor();
     // Language dropdown
     $mform->addElement('select', 'language', get_string('language', 'codeactivity'), $languages);
     $mform->addHelpButton('language', 'language', 'codeactivity');
     $this->timingSection($mform);
     $this->filesSection($mform);
     $this->testsSection();
     //-------------------------------------------------------------------------------
     // add standard elements, common to all modules
     $this->standard_coursemodule_elements();
     //-------------------------------------------------------------------------------
     // add standard buttons, common to all modules
     $this->add_action_buttons();
     $this->addScripts();
 }