Exemplo n.º 1
0
 /**
  * Convert object to XML.
  * 
  * @param object $doc DOMDocument
  * @param object $parent DOMElement
  * @param string $nodeName name of the node you want to convert to
  * @param array $arrayToConvert array (or 2d array) you are trying to convert
  *
  * Adds one or more properly formatted xml nodes to the parent
  */
 public function appendChildren($doc, $parent, $nodeName, $arrayToConvert)
 {
     if (array_key_exists($nodeName, $arrayToConvert)) {
         //one object was sent.
         $elem = $doc->createElement($nodeName, $arrayToConvert[$nodeName]);
         $parent->appendChild($elem);
         foreach ($arrayToConvert as $key => $val) {
             if ($key != $nodeName) {
                 $attrName = $doc->createAttribute($key);
                 $elem->appendChild($attrName);
                 $attrVal = $doc->createTextNode($val);
                 $attrName->appendChild($attrVal);
             }
         }
     } else {
         //array of objects was sent
         foreach ($arrayToConvert as $key => $val) {
             $elem = $doc->createElement($nodeName, $val[$nodeName]);
             $parent->appendChild($elem);
             foreach ($val as $attrName => $attrVal) {
                 if ($attrName != $nodeName) {
                     $attribute = $doc->createAttribute($attrName);
                     $elem->appendChild($attribute);
                     $attributevalue = $doc->createTextNode($attrVal);
                     $attribute->appendChild($attributevalue);
                 }
             }
         }
     }
 }
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffle', 'quiz'), null, null, array(0, 1));
     $mform->setHelpButton('shuffleanswers', array('matchshuffle', get_string('shuffle', 'quiz'), 'quiz'));
     $mform->setDefault('shuffleanswers', 1);
     $mform->addElement('static', 'answersinstruct', get_string('choices', 'quiz'), get_string('filloutthreequestions', 'quiz'));
     $mform->closeHeaderBefore('answersinstruct');
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('questionno', 'quiz', '{no}'));
     $repeated[] =& $mform->createElement('textarea', 'subquestions', get_string('question', 'quiz'), array('cols' => 40, 'rows' => 3));
     $repeated[] =& $mform->createElement('text', 'subanswers', get_string('answer', 'quiz'), array('size' => 50));
     if (isset($this->question->options)) {
         $countsubquestions = count($this->question->options->subquestions);
     } else {
         $countsubquestions = 0;
     }
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = QUESTION_NUMANS_START > $countsubquestions + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countsubquestions + QUESTION_NUMANS_ADD;
     } else {
         $repeatsatstart = $countsubquestions;
     }
     $mform->setType('subanswer', PARAM_TEXT);
     $mform->setType('subquestion', PARAM_TEXT);
     $this->repeat_elements($repeated, $repeatsatstart, array(), 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreqblanks', 'qtype_match'));
 }
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $mform->addElement('static', 'answersinstruct', get_string('choices', 'quiz'), get_string('filloutthreeitems', 'qtype_order'));
     $mform->closeHeaderBefore('answersinstruct');
     $mform->addElement('advcheckbox', 'horizontal', get_string('horizontal', 'qtype_order'), null, null, array(0, 1));
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('itemno', 'qtype_order', '{no}'));
     // change elements to support htmleditor (nadavkav)
     $repeated[] =& $mform->createElement('htmleditor', 'subquestions', '', array('cols' => 40, 'rows' => 13));
     if (isset($this->question->options)) {
         $countsubquestions = count($this->question->options->subquestions);
     } else {
         $countsubquestions = 0;
     }
     $repeatsatstart = QUESTION_NUMANS_START > $countsubquestions + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countsubquestions + QUESTION_NUMANS_ADD;
     $mform->setType('subquestion', PARAM_TEXT);
     $this->repeat_elements($repeated, $repeatsatstart, array(), 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreqblanks', 'qtype_order'));
     $repeats = optional_param('noanswers', '', PARAM_INT);
     $addfields = optional_param('addanswers', '', PARAM_TEXT);
     if (!empty($addfields)) {
         $repeats += QUESTION_NUMANS_ADD;
     }
     for ($count = 0; $count < $repeats; $count++) {
         $mform->addElement('hidden', 'subanswers[' . $count . ']', $count + 1);
     }
 }
Exemplo n.º 4
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform) {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name.'_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 5);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name.'_grp');
     }
 }
Exemplo n.º 5
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('text', '', 'filters'));
     $mform->setDefault($this->_name, $this->_value);
     $mform->setDefault($this->_name . '_op', $this->_operator);
 }
Exemplo n.º 6
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform) {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name .'_rl', null, $this->get_roles());
     $objs[] =& $mform->createElement('select', $this->_name .'_ct', null, $this->get_course_categories());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name.'_grp');
     }
 }
Exemplo n.º 7
0
 /**
  * Createa an XML element (tag)
  * @param 	string $name 		Name of the element
  * @param  	object $bind 		Parent object to bind the new element to
  * @param   string $value 		The value of the element (if any) 
  * @param  	array  $attributes 	Associative array of tag attributes "attribute" => "value"
  * @return 	The created XML element
  */
 public function createElement($name, $bind, $value = null, $attributes = array())
 {
     $item = $bind->appendChild($this->dom->createElement($name));
     if ($value) {
         $this->addText($value, $item);
     }
     foreach ($attributes as $k => $v) {
         $this->createAttribute($k, $v, $item);
     }
     return $item;
 }
Exemplo n.º 8
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_rl', null, $this->getRoles());
     $objs[] =& $mform->createElement('select', $this->_name . '_ct', null, $this->getCourseCategories());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('courserole', '', 'filters'));
     $mform->setDefault($this->_name, $this->_value);
     $mform->setDefault($this->_name . '_rl', $this->_roleid);
     $mform->setDefault($this->_name . '_ct', $this->_categoryid);
 }
Exemplo n.º 9
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     if (!is_null($this->_offoption)) {
         $objs[] =& $mform->createElement('radio', $this->_name, null, get_string('anyvalue', 'filters'), $this->_offoption);
     }
     foreach ($this->_options as $k => $v) {
         $objs[] =& $mform->createElement('radio', $this->_name, null, $v, $k);
     }
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setDefault($this->_name, $this->_value);
     $grp->setHelpButton(array('radios', '', 'filters'));
 }
Exemplo n.º 10
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('static', $this->_name . '_sck', null, get_string('isafter', 'filters'));
     $objs[] = $mform->createElement('date_selector', $this->_name . '_sdt', null, array('optional' => true));
     $objs[] = $mform->createElement('static', $this->_name . '_break', null, '<br/>');
     $objs[] = $mform->createElement('static', $this->_name . '_edk', null, get_string('isbefore', 'filters'));
     $objs[] = $mform->createElement('date_selector', $this->_name . '_edt', null, array('optional' => true));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
Exemplo n.º 11
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs[] =& $mform->createElement('select', $this->_name, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
Exemplo n.º 12
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_uniqueid . '_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_uniqueid, null);
     $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_uniqueid, PARAM_RAW);
     $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]);
     // TBV
     $mform->disabledIf($this->_uniqueid, $this->_uniqueid . '_op', 'eq', 5);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_uniqueid . '_grp');
     }
 }
Exemplo n.º 13
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform) {
     $profile_fields = $this->get_profile_fields();
     if (empty($profile_fields)) {
         return;
     }
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name.'_fld', null, $profile_fields);
     $objs[] =& $mform->createElement('select', $this->_name.'_op', null, $this->get_operators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name.'_grp');
     }
 }
Exemplo n.º 14
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs['select'] = $mform->createElement('select', $this->_name . '_op', null, $this->getOperators());
     $objs['text'] = $mform->createElement('text', $this->_name, null);
     $objs['select']->setLabel(get_string('limiterfor', 'filters', $this->_label));
     $objs['text']->setLabel(get_string('valuefor', 'filters', $this->_label));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_name, PARAM_RAW);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 5);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $QTYPES;
     $menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice'));
     $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu);
     $mform->setDefault('single', 1);
     $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1));
     $mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers', 'qtype_multichoice'), 'quiz'));
     $mform->setDefault('shuffleanswers', 1);
     $numberingoptions = $QTYPES[$this->qtype()]->get_numbering_styles();
     $menu = array();
     foreach ($numberingoptions as $numberingoption) {
         $menu[$numberingoption] = get_string('answernumbering' . $numberingoption, 'qtype_multichoice');
     }
     $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), $menu);
     $mform->setDefault('answernumbering', 'abc');
     /*        $mform->addElement('static', 'answersinstruct', get_string('choices', 'qtype_multichoice'), get_string('fillouttwochoices', 'qtype_multichoice'));
             $mform->closeHeaderBefore('answersinstruct');
     */
     $creategrades = get_grade_options();
     $gradeoptions = $creategrades->gradeoptionsfull;
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('choiceno', 'qtype_multichoice', '{no}'));
     $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 50));
     $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
     $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid));
     if (isset($this->question->options)) {
         $countanswers = count($this->question->options->answers);
     } else {
         $countanswers = 0;
     }
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = max(5, QUESTION_NUMANS_START, $countanswers + QUESTION_NUMANS_ADD);
     } else {
         $repeatsatstart = $countanswers;
     }
     $repeatedoptions = array();
     $repeatedoptions['fraction']['default'] = 0;
     $mform->setType('answer', PARAM_RAW);
     $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice'));
     $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice'));
     $mform->addElement('htmleditor', 'correctfeedback', get_string('correctfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid));
     $mform->setType('correctfeedback', PARAM_RAW);
     $mform->addElement('htmleditor', 'partiallycorrectfeedback', get_string('partiallycorrectfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid));
     $mform->setType('partiallycorrectfeedback', PARAM_RAW);
     $mform->addElement('htmleditor', 'incorrectfeedback', get_string('incorrectfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid));
     $mform->setType('incorrectfeedback', PARAM_RAW);
 }
Exemplo n.º 16
0
 /**
  * Constructor Summary
  *
  * o Creates a standard progress bar into a dialog box (QuickForm).
  *   Form name, buttons 'start', 'cancel' labels and style, and
  *   title of dialog box may also be changed.
  *   <code>
  *   $monitor = new HTML_Progress_Monitor();
  *   </code>
  *
  * o Creates a progress bar into a dialog box, with only a new
  *   form name.
  *   <code>
  *   $monitor = new HTML_Progress_Monitor($formName);
  *   </code>
  *
  * o Creates a progress bar into a dialog box, with a new form name,
  *   new buttons name and style, and also a different title box.
  *   <code>
  *   $monitor = new HTML_Progress_Monitor($formName, $attributes);
  *   </code>
  *
  * @param      string    $formName      (optional) Name of monitor dialog box (QuickForm)
  * @param      array     $attributes    (optional) List of renderer options
  * @param      array     $errorPrefs    (optional) Hash of params to configure error handler
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Monitor($formName = 'ProgressMonitor', $attributes = array(), $errorPrefs = array())
 {
     $bar = new HTML_Progress($errorPrefs);
     $this->_progress = $bar;
     if (!is_string($formName)) {
         return $this->_progress->raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$formName', 'was' => gettype($formName), 'expected' => 'string', 'paramnum' => 1));
     } elseif (!is_array($attributes)) {
         return $this->_progress->raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array', 'paramnum' => 2));
     }
     $this->_id = md5(microtime());
     $this->_form = new HTML_QuickForm($formName);
     $this->_form->removeAttribute('name');
     // XHTML compliance
     $this->windowname = isset($attributes['title']) ? $attributes['title'] : 'In progress ...';
     $this->buttonStart = isset($attributes['start']) ? $attributes['start'] : 'Start';
     $this->buttonCancel = isset($attributes['cancel']) ? $attributes['cancel'] : 'Cancel';
     $buttonAttr = isset($attributes['button']) ? $attributes['button'] : '';
     $this->_form->addElement('header', 'windowname', $this->windowname);
     $this->_form->addElement('static', 'progressBar');
     $this->_form->addElement('static', 'progressStatus');
     $style = $this->isStarted() ? array('disabled' => 'true') : null;
     $buttons[] =& $this->_form->createElement('submit', 'start', $this->buttonStart, $style);
     $buttons[] =& $this->_form->createElement('submit', 'cancel', $this->buttonCancel);
     $buttons[0]->updateAttributes($buttonAttr);
     $buttons[1]->updateAttributes($buttonAttr);
     $this->_form->addGroup($buttons, 'buttons', '', '&nbsp;', false);
     // default embedded progress element with look-and-feel
     $this->setProgressElement($bar);
     $str =& $this->_form->getElement('progressStatus');
     $str->setText('<div id="status" class="progressStatus">&nbsp;</div>');
 }
Exemplo n.º 17
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $profile_fields =& $this->getProfileFields();
     if (empty($profile_fields)) {
         return;
     }
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_fld', null, $profile_fields);
     $objs[] =& $mform->createElement('select', $this->_name . '_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('profilefield', '', 'filters'));
     $mform->setDefault($this->_name . '_fld', $this->_profile_field);
     $mform->setDefault($this->_name . '_op', $this->_operator);
     $mform->setDefault($this->_name, $this->_value);
 }
Exemplo n.º 18
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_uniqueid . '_op', null, $this->get_operators());
     $objs[] =& $mform->createElement('select', $this->_uniqueid, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false);
     $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]);
     // TBV
     $mform->disabledIf($this->_uniqueid, $this->_uniqueid . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_uniqueid, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_uniqueid . '_grp');
     }
 }
Exemplo n.º 19
0
 /**
  * The progress uploader class constructor
  *
  * @param      string    $formName      (optional) Name of monitor dialog box (QuickForm)
  * @param      array     $attributes    (optional) List of renderer options
  *
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Uploader($formName = 'ProgressUploader', $attributes = array())
 {
     $this->_package = 'HTML_Progress_Uploader';
     Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
     if (!is_string($formName)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$formName', 'was' => gettype($formName), 'expected' => 'string', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
     } elseif (!is_array($attributes)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
     }
     parent::FTP_Upload();
     // checks all necessary dependencies
     $this->_form = new HTML_QuickForm($formName);
     $this->windowname = isset($attributes['title']) ? $attributes['title'] : 'Upload ...';
     $this->captionMask = isset($attributes['mask']) ? $attributes['mask'] : '%s';
     $this->buttonStart = isset($attributes['start']) ? $attributes['start'] : 'Start';
     $this->buttonCancel = isset($attributes['cancel']) ? $attributes['cancel'] : 'Cancel';
     $buttonAttr = isset($attributes['button']) ? $attributes['button'] : '';
     $this->_form->addElement('header', 'windowname', $this->windowname);
     $this->_form->addElement('static', 'progressBar');
     $this->_form->addElement('static', 'progressStatus');
     $style = $this->isStarted() ? array('disabled' => 'true') : null;
     $buttons[] =& $this->_form->createElement('submit', 'start', $this->buttonStart, $style);
     $buttons[] =& $this->_form->createElement('submit', 'cancel', $this->buttonCancel);
     $buttons[0]->updateAttributes($buttonAttr);
     $buttons[1]->updateAttributes($buttonAttr);
     $this->_form->addGroup($buttons, 'buttons', '', '&nbsp;', false);
     // default embedded progress element with look-and-feel
     $this->_progress = new HTML_Progress();
     $this->setProgressElement($this->_progress);
     $str =& $this->_form->getElement('progressStatus');
     $str->setText('<div id="status" class="progressStatus">&nbsp;</div>');
 }
Exemplo n.º 20
0
 /**
  * Converts the place to properly formatted XML..
  * 
  * @param object $doc DOMDocument object
  * @param object $root DOMDocument root
  */
 public function toXML($doc, $root)
 {
     $payload = $doc->createElement('payload');
     if ($this->title != null) {
         $payload->appendChild($doc->createElement('title', $this->title));
     }
     if ($this->body != null) {
         $payload->appendChild($doc->createElement('body', $this->body));
     }
     if ($this->mediaURL != null) {
         $doc->appendChildren($doc, $payload, "mediaURL", $this->mediaURL);
     }
     $payload->appendChild($doc->createElement('raw', $this->raw));
     if ($payload->hasChildNodes()) {
         $root->appendChild($payload);
     }
 }
Exemplo n.º 21
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  * @uses  $PAGE
  */
 function setupForm(&$mform)
 {
     global $PAGE;
     $options_array = $this->get_main_options();
     $fullpath = $this->_report_path . $this->_filename;
     $parent = $this->_uniqueid . '_parent';
     $PAGE->requires->yui_module('moodle-local_eliscore-dependentselect', 'M.local_eliscore.init_dependentselect', array($parent, $this->_uniqueid, $fullpath));
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_uniqueid . '_parent', null, $options_array);
     $objs[] =& $mform->createElement('select', $this->_uniqueid, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '<br/>', false);
     $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]);
     // TBV
     if ($this->_advanced) {
         $mform->setAdvanced($this->_uniqueid . '_grp');
     }
 }
Exemplo n.º 22
0
 /**
  * Converts the place to properly formatted XML.
  * 
  * @param object $doc DOMDocument object
  * @param object $root DOMDocument root
  */
 public function toXML($doc, $root)
 {
     $place = $doc->createElement('place');
     if ($this->point != null) {
         $place->appendChild($doc->createElement('point', $this->point));
     }
     if ($this->elev != null) {
         $place->appendChild($doc->createElement('elev', $this->elev));
     }
     if ($this->floor != null) {
         $place->appendChild($doc->createElement('floor', $this->floor));
     }
     if ($this->featuretypetag != null) {
         $place->appendChild($doc->createElement('featuretypetag', $this->featuretypetag));
     }
     if ($this->featurename != null) {
         $place->appendChild($doc->createElement('featurename', $this->featurename));
     }
     if ($this->relationshiptag != null) {
         $place->appendChild($doc->createElement('relationshiptag', $this->relationshiptag));
     }
     if ($place->hasChildNodes()) {
         $root->appendChild($place);
     }
 }
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 public function definition_inner($mform)
 {
     // cache this plugins name
     $plugin = 'qtype_ordering';
     // selecttype
     $name = 'selecttype';
     $label = get_string($name, $plugin);
     $options = array(0 => get_string('selectall', $plugin), 1 => get_string('selectrandom', $plugin), 2 => get_string('selectcontiguous', $plugin));
     $mform->addElement('select', $name, $label, $options);
     $mform->addHelpButton($name, $name, $plugin);
     $mform->setDefault($name, 0);
     // selectcount
     $name = 'selectcount';
     $label = get_string($name, $plugin);
     $options = array(0 => get_string('all'));
     for ($i = 3; $i <= 20; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', $name, $label, $options);
     $mform->disabledIf($name, 'selecttype', 'eq', 0);
     $mform->addHelpButton($name, $name, $plugin);
     $mform->setDefault($name, 0);
     // answers (=items)
     $elements = array();
     $name = 'answerheader';
     $label = get_string($name, $plugin);
     $elements[] =& $mform->createElement('header', $name, $label);
     $name = 'answer';
     $label = get_string($name, $plugin);
     $options = array('rows' => self::NUM_ANS_ROWS, 'cols' => self::NUM_ANS_COLS);
     $elements[] =& $mform->createElement('textarea', $name, $label, $options);
     if (empty($this->question->options)) {
         $start = 0;
     } else {
         $start = count($this->question->options->answers);
     }
     if ($start < self::NUM_ANS_START) {
         $start = self::NUM_ANS_START;
     }
     $options = array('answerheader' => array('expanded' => true));
     $buttontext = get_string('addmoreanswers', $plugin, self::NUM_ANS_ADD);
     $this->repeat_elements($elements, $start, $options, 'countanswers', 'addanswers', self::NUM_ANS_ADD, $buttontext);
     // feedback
     $this->add_ordering_feedback_fields();
 }
Exemplo n.º 24
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $profilefields = $this->get_profile_fields();
     if (empty($profilefields)) {
         return;
     }
     $objs = array();
     $objs['field'] = $mform->createElement('select', $this->_name . '_fld', null, $profilefields);
     $objs['op'] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs['value'] = $mform->createElement('text', $this->_name, null);
     $objs['field']->setLabel(get_string('profilefilterfield', 'filters'));
     $objs['op']->setLabel(get_string('profilefilterlimiter', 'filters'));
     $objs['value']->setLabel(get_string('valuefor', 'filters', $this->_label));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_name, PARAM_RAW);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
Exemplo n.º 25
0
 /**
  * Export the coverage of a metrics.
  *
  * @param  object $xmlDocument The DOMDocument root node instance.
  * @return object              The XML file node.
  */
 protected static function _exportMetrics($xmlDocument, $metrics)
 {
     $data = $metrics->data();
     $xmlMetrics = $xmlDocument->createElement('metrics');
     $xmlMetrics->setAttribute('loc', $data['loc']);
     $xmlMetrics->setAttribute('ncloc', $data['nlloc']);
     $xmlMetrics->setAttribute('statements', $data['lloc']);
     $xmlMetrics->setAttribute('coveredstatements', $data['cloc']);
     return $xmlMetrics;
 }
Exemplo n.º 26
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('checkbox', $this->_name . '_sck', null, get_string('isafter', 'filters'));
     $objs[] =& $mform->createElement('date_selector', $this->_name . '_sdt', null);
     $objs[] =& $mform->createElement('checkbox', $this->_name . '_eck', null, get_string('isbefore', 'filters'));
     $objs[] =& $mform->createElement('date_selector', $this->_name . '_edt', null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('date', $this->_label, 'filters'));
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
     $mform->disabledIf($this->_name . '_sdt[day]', $this->_name . '_sck', 'notchecked');
     $mform->disabledIf($this->_name . '_sdt[month]', $this->_name . '_sck', 'notchecked');
     $mform->disabledIf($this->_name . '_sdt[year]', $this->_name . '_sck', 'notchecked');
     $mform->disabledIf($this->_name . '_edt[day]', $this->_name . '_eck', 'notchecked');
     $mform->disabledIf($this->_name . '_edt[month]', $this->_name . '_eck', 'notchecked');
     $mform->disabledIf($this->_name . '_edt[year]', $this->_name . '_eck', 'notchecked');
 }
Exemplo n.º 27
0
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $creategrades = get_grade_options();
     $gradeoptions = $creategrades->gradeoptionsfull;
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('choiceno', 'qtype_multichoice', '{no}'));
     $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'));
     $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
     $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'));
     if (isset($this->question->options)) {
         $countanswers = count($this->question->options->answers);
     } else {
         $countanswers = 0;
     }
     $repeatsatstart = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + QUESTION_NUMANS_ADD;
     $repeatedoptions = array();
     $repeatedoptions['fraction']['default'] = 0;
     $mform->setType('answer', PARAM_NOTAGS);
     $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice'));
 }
Exemplo n.º 28
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_sck', null, get_string('isafter', 'filters'), null, array('0', '1'));
     $objs[] =& $mform->createElement('date_selector', $this->_uniqueid . '_sdt', null, array('optional' => false));
     $objs[] =& $mform->createElement('static', $this->_uniqueid . '_break', null, '<br/>');
     $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_eck', null, get_string('isbefore', 'filters'), null, array('0', '1'));
     $objs[] =& $mform->createElement('date_selector', $this->_uniqueid . '_edt', null, array('optional' => false));
     if ($this->_never_included) {
         $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_never', null, get_string('includenever', 'filters'));
     }
     $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton($this->_filterhelp);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_uniqueid . '_grp');
     }
     $mform->disabledIf($this->_uniqueid . '_sdt[day]', $this->_uniqueid . '_sck', '0');
     $mform->disabledIf($this->_uniqueid . '_sdt[month]', $this->_uniqueid . '_sck', '0');
     $mform->disabledIf($this->_uniqueid . '_sdt[year]', $this->_uniqueid . '_sck', '0');
     $mform->disabledIf($this->_uniqueid . '_edt[day]', $this->_uniqueid . '_eck', '0');
     $mform->disabledIf($this->_uniqueid . '_edt[month]', $this->_uniqueid . '_eck', '0');
     $mform->disabledIf($this->_uniqueid . '_edt[year]', $this->_uniqueid . '_eck', '0');
     if ($this->_never_included) {
         $mform->disabledIf($this->_uniqueid . '_never', $this->_uniqueid . '_eck', '0');
     }
 }
Exemplo n.º 29
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     global $CFG;
     require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_connection', 'yui_json', "{$CFG->wwwroot}/curriculum/js/dependentselect.js"), true);
     $options_array = $this->get_main_options();
     $fullpath = $this->_report_path . $this->_filename;
     $parent = $this->_uniqueid . '_parent';
     $js = "dependentselect_updateoptions('{$parent}','{$this->_uniqueid}','{$fullpath}');";
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_uniqueid . '_parent', null, $options_array, array('onChange' => $js));
     $objs[] =& $mform->createElement('select', $this->_uniqueid, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '<br/>', false);
     $grp->setHelpButton($this->_filterhelp);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_uniqueid, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_uniqueid . '_grp');
     }
     // Always refresh the child pulldown
     $mform->addElement('html', '<script>' . $js . '</script>');
 }
Exemplo n.º 30
0
 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     if (is_array($this->_fields)) {
         $objs[] =& $mform->createElement('select', $this->_name . '_fld', null, $this->_fields);
     }
     $objs[] =& $mform->createElement('checkbox', $this->_name . '_sck', null, get_string('isafter', 'filters'));
     $objs[] =& $mform->createElement('date_selector', $this->_name . '_sdt', null);
     $objs[] =& $mform->createElement('checkbox', $this->_name . '_eck', null, get_string('isbefore', 'filters'));
     $objs[] =& $mform->createElement('date_selector', $this->_name . '_edt', null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('date', '', 'filters'));
     $mform->setDefault($this->_name . '_sck', !empty($this->_value));
     $mform->setDefault($this->_name . '_eck', !empty($this->_value2));
     $mform->setDefault($this->_name . '_sdt', $this->_value);
     $mform->setDefault($this->_name . '_edt', $this->_value2);
     if (is_array($this->_fields)) {
         $mform->setDefault($this->_name . '_fld', $this->_field);
     }
     $mform->disabledIf($this->_name . '_sdt', $this->_name . '_sck');
     $mform->disabledIf($this->_name . '_edt', $this->_name . '_eck');
 }