コード例 #1
0
 /**
  * DB_DataObject_FormBuilder_QuickForm::_freezeFormElements()
  *
  * Freezes a list of form elements (set read-only).
  * Used in _generateForm().
  *
  * @param object $form               The form object in question
  * @param array  $elements_to_freeze List of element names to be frozen
  * @access protected
  * @see DB_DataObject_FormBuilder::_generateForm()
  */
 function _freezeFormElements(&$form, $elementsToFreeze)
 {
     foreach ($elementsToFreeze as $elementToFreeze) {
         $elementToFreeze = $this->getFieldName($elementToFreeze);
         if ($form->elementExists($elementToFreeze)) {
             $el =& $form->getElement($elementToFreeze);
             $el->freeze();
         }
     }
 }
コード例 #2
0
 /**
  * hook to add plagiarism specific settings to a module settings page.
  * @param object $mform  - Moodle form
  * @param object $context - current context
  */
 public function get_form_elements_module($mform, $context, $modulename = "")
 {
     global $CFG, $DB, $COURSE;
     $plagiarismsettings = $this->get_settings();
     if (!$plagiarismsettings) {
         return;
     }
     // Hack to prevent this from showing on custom compilatioassignment type.
     if ($mform->elementExists('seuil_faible')) {
         return;
     }
     $cmid = optional_param('update', 0, PARAM_INT);
     // We can't access $this->_cm here.
     if (!empty($modulename)) {
         $modname = 'compilatio_enable_' . $modulename;
         if (empty($plagiarismsettings[$modname])) {
             return;
             // Return if compilatio is not enabled for the module
         }
     }
     if (!empty($cmid)) {
         $plagiarismvalues = $DB->get_records_menu('plagiarism_compilatio_config', array('cm' => $cmid), '', 'name, value');
     }
     // The cmid(0) is the default list.
     $plagiarismdefaults = $DB->get_records_menu('plagiarism_compilatio_config', array('cm' => 0), '', 'name, value');
     $plagiarismelements = $this->config_options();
     if (has_capability('plagiarism/compilatio:enable', $context)) {
         compilatio_get_form_elements($mform);
         if ($mform->elementExists('compilatio_draft_submit')) {
             if ($mform->elementExists('var4')) {
                 $mform->disabledIf('compilatio_draft_submit', 'var4', 'eq', 0);
             } else {
                 if ($mform->elementExists('submissiondrafts')) {
                     $mform->disabledIf('compilatio_draft_submit', 'submissiondrafts', 'eq', 0);
                 }
             }
         }
         // Disable all plagiarism elements if use_plagiarism eg 0.
         foreach ($plagiarismelements as $element) {
             if ($element != 'use_compilatio') {
                 // Ignore this var.
                 $mform->disabledIf($element, 'use_compilatio', 'eq', 0);
             }
         }
     } else {
         // Add plagiarism settings as hidden vars.
         foreach ($plagiarismelements as $element) {
             $mform->addElement('hidden', $element);
         }
     }
     // Now set defaults.
     foreach ($plagiarismelements as $element) {
         if (isset($plagiarismvalues[$element])) {
             $mform->setDefault($element, $plagiarismvalues[$element]);
         } else {
             if (isset($plagiarismdefaults[$element])) {
                 $mform->setDefault($element, $plagiarismdefaults[$element]);
             }
         }
     }
 }
 /**
  * Add custom requirement rules to filter elements
  *
  * @param   object $mform  The mform object for the filter page
  * @param   string $key    The filter field key
  * @param   object $fields The filter field values object
  *
  * @return  object $mform  The modified mform object for the filter page
  */
 function apply_filter_required_rule($mform, $key, $fields)
 {
     if ($mform->elementExists($key . '_grp')) {
         $mform->addRule($key . '_grp', get_string('required'), 'required', null, 'client');
         $mform->registerRule('custom_rule', 'function', 'user_course_completion_check_custom_rule');
         $mform->addRule($key . '_grp', get_string('required'), 'custom_rule', array($key, $fields));
     }
     return $mform;
 }
コード例 #4
0
    /**
     * Add the input areas for each unit.
     * @param object $mform the form being built.
     */
    protected function add_unit_fields($mform) {
        $repeated = array(
            $mform->createElement('header', 'unithdr',
                    get_string('unithdr', 'qtype_numerical', '{no}')),
            $mform->createElement('text', 'unit', get_string('unit', 'quiz')),
            $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')),
        );

        $repeatedoptions['unit']['type'] = PARAM_NOTAGS;
        $repeatedoptions['multiplier']['type'] = PARAM_NUMBER;
        $repeatedoptions['unit']['disabledif'] =
                array('unitrole', 'eq', qtype_numerical::UNITNONE);
        $repeatedoptions['multiplier']['disabledif'] =
                array('unitrole', 'eq', qtype_numerical::UNITNONE);

        if (isset($this->question->options->units)) {
            $countunits = count($this->question->options->units);
        } else {
            $countunits = 0;
        }
        if ($this->question->formoptions->repeatelements) {
            $repeatsatstart = $countunits + 1;
        } else {
            $repeatsatstart = $countunits;
        }
        $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'nounits',
                'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));

        if ($mform->elementExists('multiplier[0]')) {
            $firstunit = $mform->getElement('multiplier[0]');
            $firstunit->freeze();
            $firstunit->setValue('1.0');
            $firstunit->setPersistantFreeze(true);
            $mform->addHelpButton('multiplier[0]', 'numericalmultiplier', 'qtype_numerical');
        }
    }
コード例 #5
0
 /**
  * Add custom requirement rules to filter elements
  *
  * @param   object $mform  The mform object for the filter page
  * @param   string $key    The filter field key
  * @param   object $fields The filter field values object
  *
  * @return  object $mform  The modified mform object for the filter page
  */
 public static function apply_filter_required_rule($mform, $key, $fields)
 {
     $elem = "{$key}_grp";
     if ($mform->elementExists($elem)) {
         $mform->addRule($elem, get_string('required'), 'required', null, 'client');
         $mform->registerRule('custom_rule', 'function', 'course_completion_check_custom_rule');
         $mform->addRule($elem, get_string('required'), 'custom_rule', array($key, $fields));
     }
     return $mform;
 }
コード例 #6
0
 /**
  * Add custom requirement rules to filter elements
  *
  * @param   object $mform  The mform object for the filter page
  * @param   string $key    The filter field key
  * @param   object $fields The filter field values object
  *
  * @return  object $mform  The modified mform object for the filter page
  */
 public static function apply_filter_required_rule($mform, $key, $fields)
 {
     $elem = "{$key}_grp";
     if ($mform->elementExists($elem)) {
         $mform->addRule($elem, get_string('required'), 'required', null, 'client');
         $mform->addGroupRule($elem, get_string('required'), 'required', null, 2, 'client');
         // TBV
     }
     return $mform;
 }
コード例 #7
0
/**
 * Adds the list of plagiarism settings to a form.
 *
 * @param object $mform - Moodle form object.
 */
function urkund_get_form_elements($mform)
{
    $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
    $tiioptions = array(0 => get_string("never"), 1 => get_string("always"), 2 => get_string("showwhenclosed", "plagiarism_urkund"));
    $urkunddraftoptions = array(PLAGIARISM_URKUND_DRAFTSUBMIT_IMMEDIATE => get_string("submitondraft", "plagiarism_urkund"), PLAGIARISM_URKUND_DRAFTSUBMIT_FINAL => get_string("submitonfinal", "plagiarism_urkund"));
    $mform->addElement('header', 'plagiarismdesc', get_string('urkund', 'plagiarism_urkund'));
    $mform->addElement('select', 'use_urkund', get_string("useurkund", "plagiarism_urkund"), $ynoptions);
    $mform->addElement('text', 'urkund_receiver', get_string("urkund_receiver", "plagiarism_urkund"), array('size' => 40));
    $mform->addHelpButton('urkund_receiver', 'urkund_receiver', 'plagiarism_urkund');
    $mform->setType('urkund_receiver', PARAM_TEXT);
    $mform->addElement('select', 'urkund_show_student_score', get_string("urkund_show_student_score", "plagiarism_urkund"), $tiioptions);
    $mform->addHelpButton('urkund_show_student_score', 'urkund_show_student_score', 'plagiarism_urkund');
    $mform->addElement('select', 'urkund_show_student_report', get_string("urkund_show_student_report", "plagiarism_urkund"), $tiioptions);
    $mform->addHelpButton('urkund_show_student_report', 'urkund_show_student_report', 'plagiarism_urkund');
    if ($mform->elementExists('submissiondrafts')) {
        $mform->addElement('select', 'urkund_draft_submit', get_string("urkund_draft_submit", "plagiarism_urkund"), $urkunddraftoptions);
    }
    $mform->addElement('select', 'urkund_studentemail', get_string("urkund_studentemail", "plagiarism_urkund"), $ynoptions);
    $mform->addHelpButton('urkund_studentemail', 'urkund_studentemail', 'plagiarism_urkund');
    $filetypes = urkund_default_allowed_file_types(true);
    $supportedfiles = array();
    foreach ($filetypes as $ext => $mime) {
        $supportedfiles[$ext] = $ext;
    }
    $mform->addElement('select', 'urkund_allowallfile', get_string('allowallsupportedfiles', 'plagiarism_urkund'), $ynoptions);
    $mform->addHelpButton('urkund_allowallfile', 'allowallsupportedfiles', 'plagiarism_urkund');
    $mform->addElement('select', 'urkund_selectfiletypes', get_string('restrictfiles', 'plagiarism_urkund'), $supportedfiles, array('multiple' => true));
    $contentoptions = array(PLAGIARISM_URKUND_RESTRICTCONTENTNO => get_string('restrictcontentno', 'plagiarism_urkund'), PLAGIARISM_URKUND_RESTRICTCONTENTFILES => get_string('restrictcontentfiles', 'plagiarism_urkund'), PLAGIARISM_URKUND_RESTRICTCONTENTTEXT => get_string('restrictcontenttext', 'plagiarism_urkund'));
    $mform->addElement('select', 'urkund_restrictcontent', get_string('restrictcontent', 'plagiarism_urkund'), $contentoptions);
    $mform->addHelpButton('urkund_restrictcontent', 'restrictcontent', 'plagiarism_urkund');
}
コード例 #8
0
ファイル: grading.php プロジェクト: alanaipe2015/moodle
 /**
  * Called by HTML_QuickForm whenever form event is made on this element.
  * Adds necessary rules to the element and checks that coorenct instance of gradingform_instance
  * is passed in attributes
  *
  * @param string $event Name of event
  * @param mixed $arg event arguments
  * @param object $caller calling object
  * @return bool
  * @throws moodle_exception
  */
 public function onQuickFormEvent($event, $arg, &$caller)
 {
     if ($event == 'createElement') {
         $attributes = $arg[2];
         if (!is_array($attributes) || !array_key_exists('gradinginstance', $attributes) || !$attributes['gradinginstance'] instanceof gradingform_instance) {
             throw new moodle_exception('exc_gradingformelement', 'grading');
         }
     }
     $name = $this->getName();
     if ($name && $caller->elementExists($name)) {
         $caller->addRule($name, $this->get_gradinginstance()->default_validation_error_message(), 'gradingvalidated', $this->gradingattributes);
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
コード例 #9
0
ファイル: modgrade.php プロジェクト: abhilash1994/moodle
 /**
  * Called by HTML_QuickForm whenever form event is made on this element.
  *
  * @param string $event Name of event
  * @param mixed $arg event arguments
  * @param object $caller calling object
  * @return mixed
  */
 public function onQuickFormEvent($event, $arg, &$caller)
 {
     global $COURSE;
     switch ($event) {
         case 'updateValue':
             $value = $this->_findValue($caller->_constantValues);
             if (null === $value) {
                 if ($caller->isSubmitted()) {
                     $value = $this->_findValue($caller->_submitValues);
                 } else {
                     $value = $this->_findValue($caller->_defaultValues);
                 }
             }
             $name = $this->getName();
             // Set disable actions.
             $caller->disabledIf($name . '[modgrade_scale]', $name . '[modgrade_type]', 'neq', 'scale');
             $caller->disabledIf($name . '[modgrade_point]', $name . '[modgrade_type]', 'neq', 'point');
             // Set element state for existing data.
             if (!empty($this->_elements)) {
                 if (!empty($value)) {
                     if ($value < 0) {
                         $this->_elements[1]->setValue('scale');
                         $this->_elements[4]->setValue($value * -1);
                     } else {
                         if ($value > 0) {
                             $this->_elements[1]->setValue('point');
                             $this->_elements[7]->setValue($value);
                         }
                     }
                 } else {
                     $this->_elements[1]->setValue('none');
                     $this->_elements[7]->setValue('');
                 }
             }
             // Value Validation.
             if ($name && $caller->elementExists($name)) {
                 $checkmaxgrade = function ($val) {
                     if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'point') {
                         if (!isset($val['modgrade_point'])) {
                             return false;
                         }
                         return $this->validate_point($val['modgrade_point']);
                     }
                     return true;
                 };
                 $checkvalidscale = function ($val) {
                     if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'scale') {
                         if (!isset($val['modgrade_scale'])) {
                             return false;
                         }
                         return $this->validate_scale($val['modgrade_scale']);
                     }
                     return true;
                 };
                 $maxgradeexceeded = get_string('modgradeerrorbadpoint', 'grades', get_config('core', 'gradepointmax'));
                 $invalidscale = get_string('modgradeerrorbadscale', 'grades');
                 $caller->addRule($name, $maxgradeexceeded, 'callback', $checkmaxgrade);
                 $caller->addRule($name, $invalidscale, 'callback', $checkvalidscale);
             }
             break;
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
コード例 #10
0
/**
 * adds the list of plagiarism settings to a form
 *
 * @param object $mform - Moodle form object
 */
function turnitin_get_form_elements($mform)
{
    $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
    $tiishowoptions = array(PLAGIARISM_TII_SHOW_NEVER => get_string("never"), PLAGIARISM_TII_SHOW_ALWAYS => get_string("always"), PLAGIARISM_TII_SHOW_CLOSED => get_string("showwhenclosed", "plagiarism_turnitin"));
    $tiidraftoptions = array(PLAGIARISM_TII_DRAFTSUBMIT_IMMEDIATE => get_string("submitondraft", "plagiarism_turnitin"), PLAGIARISM_TII_DRAFTSUBMIT_FINAL => get_string("submitonfinal", "plagiarism_turnitin"));
    $reportgenoptions = array(0 => get_string('reportgenimmediate', 'plagiarism_turnitin'), 1 => get_string('reportgenimmediateoverwrite', 'plagiarism_turnitin'), 2 => get_string('reportgenduedate', 'plagiarism_turnitin'));
    $excludetype = array(0 => get_string('no'), 1 => get_string('wordcount', 'plagiarism_turnitin'), 2 => get_string('percentage', 'plagiarism_turnitin'));
    $mform->addElement('header', 'plagiarismdesc');
    $mform->addElement('select', 'use_turnitin', get_string("useturnitin", "plagiarism_turnitin"), $ynoptions);
    $mform->addElement('select', 'plagiarism_show_student_score', get_string("showstudentsscore", "plagiarism_turnitin"), $tiishowoptions);
    $mform->addHelpButton('plagiarism_show_student_score', 'showstudentsscore', 'plagiarism_turnitin');
    $mform->addElement('select', 'plagiarism_show_student_report', get_string("showstudentsreport", "plagiarism_turnitin"), $tiishowoptions);
    $mform->addHelpButton('plagiarism_show_student_report', 'showstudentsreport', 'plagiarism_turnitin');
    if ($mform->elementExists('var4')) {
        $mform->addElement('select', 'plagiarism_draft_submit', get_string("draftsubmit", "plagiarism_turnitin"), $tiidraftoptions);
    }
    $mform->addElement('select', 'plagiarism_compare_student_papers', get_string("comparestudents", "plagiarism_turnitin"), $ynoptions);
    $mform->addHelpButton('plagiarism_compare_student_papers', 'comparestudents', 'plagiarism_turnitin');
    $mform->addElement('select', 'plagiarism_compare_internet', get_string("compareinternet", "plagiarism_turnitin"), $ynoptions);
    $mform->addHelpButton('plagiarism_compare_internet', 'compareinternet', 'plagiarism_turnitin');
    $mform->addElement('select', 'plagiarism_compare_journals', get_string("comparejournals", "plagiarism_turnitin"), $ynoptions);
    $mform->addHelpButton('plagiarism_compare_journals', 'comparejournals', 'plagiarism_turnitin');
    if (get_config('plagiarism', 'turnitin_institutionnode')) {
        $mform->addElement('select', 'plagiarism_compare_institution', get_string("compareinstitution", "plagiarism_turnitin"), $ynoptions);
        $mform->addHelpButton('plagiarism_compare_institution', 'compareinstitution', 'plagiarism_turnitin');
    }
    $mform->addElement('select', 'plagiarism_report_gen', get_string("reportgen", "plagiarism_turnitin"), $reportgenoptions);
    $mform->addHelpButton('plagiarism_report_gen', 'reportgen', 'plagiarism_turnitin');
    $mform->addElement('select', 'plagiarism_exclude_biblio', get_string("excludebiblio", "plagiarism_turnitin"), $ynoptions);
    $mform->addHelpButton('plagiarism_exclude_biblio', 'excludebiblio', 'plagiarism_turnitin');
    $mform->addElement('select', 'plagiarism_exclude_quoted', get_string("excludequoted", "plagiarism_turnitin"), $ynoptions);
    $mform->addHelpButton('plagiarism_exclude_quoted', 'excludequoted', 'plagiarism_turnitin');
    $mform->addElement('select', 'plagiarism_exclude_matches', get_string("excludematches", "plagiarism_turnitin"), $excludetype);
    $mform->addHelpButton('plagiarism_exclude_matches', 'excludematches', 'plagiarism_turnitin');
    $mform->addElement('text', 'plagiarism_exclude_matches_value', '');
    $mform->addRule('plagiarism_exclude_matches_value', null, 'numeric', null, 'client');
    $mform->disabledIf('plagiarism_exclude_matches_value', 'plagiarism_exclude_matches', 'eq', 0);
    $mform->addElement('select', 'plagiarism_anonymity', get_string("anonymity", "plagiarism_turnitin"), $ynoptions);
    $mform->addHelpButton('plagiarism_anonymity', 'anonymity', 'plagiarism_turnitin');
}
コード例 #11
0
/**
 * Adds the list of plagiarism settings to a form.
 *
 * @param object $mform - Moodle form object.
 */
function urkund_get_form_elements($mform)
{
    $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
    $tiioptions = array(0 => get_string("never"), 1 => get_string("always"), 2 => get_string("showwhenclosed", "plagiarism_urkund"));
    $urkunddraftoptions = array(PLAGIARISM_URKUND_DRAFTSUBMIT_IMMEDIATE => get_string("submitondraft", "plagiarism_urkund"), PLAGIARISM_URKUND_DRAFTSUBMIT_FINAL => get_string("submitonfinal", "plagiarism_urkund"));
    $mform->addElement('header', 'plagiarismdesc', get_string('urkund', 'plagiarism_urkund'));
    $mform->addElement('select', 'use_urkund', get_string("useurkund", "plagiarism_urkund"), $ynoptions);
    $mform->addElement('text', 'urkund_receiver', get_string("urkund_receiver", "plagiarism_urkund"), array('size' => 40));
    $mform->addHelpButton('urkund_receiver', 'urkund_receiver', 'plagiarism_urkund');
    $mform->setType('urkund_receiver', PARAM_TEXT);
    $mform->addElement('select', 'urkund_show_student_score', get_string("urkund_show_student_score", "plagiarism_urkund"), $tiioptions);
    $mform->addHelpButton('urkund_show_student_score', 'urkund_show_student_score', 'plagiarism_urkund');
    $mform->addElement('select', 'urkund_show_student_report', get_string("urkund_show_student_report", "plagiarism_urkund"), $tiioptions);
    $mform->addHelpButton('urkund_show_student_report', 'urkund_show_student_report', 'plagiarism_urkund');
    if ($mform->elementExists('var4') || $mform->elementExists('submissiondrafts')) {
        $mform->addElement('select', 'urkund_draft_submit', get_string("urkund_draft_submit", "plagiarism_urkund"), $urkunddraftoptions);
    }
    $mform->addElement('select', 'urkund_studentemail', get_string("urkund_studentemail", "plagiarism_urkund"), $ynoptions);
    $mform->addHelpButton('urkund_studentemail', 'urkund_studentemail', 'plagiarism_urkund');
}
コード例 #12
0
 /**
  * Adds the list of plagiarism settings to a form.
  *
  * @param object $mform - Moodle form object.
  */
 static function unplag_get_form_elements($mform)
 {
     $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
     $tiioptions = array(0 => get_string("never"), 1 => get_string("always"), 2 => get_string("showwhenclosed", "plagiarism_unplag"));
     $unplagdraftoptions = array(PLAGIARISM_UNPLAG_DRAFTSUBMIT_IMMEDIATE => get_string("submitondraft", "plagiarism_unplag"), PLAGIARISM_UNPLAG_DRAFTSUBMIT_FINAL => get_string("submitonfinal", "plagiarism_unplag"));
     $mform->addElement('header', 'plagiarismdesc', get_string('unplag', 'plagiarism_unplag'));
     $mform->addElement('select', 'use_unplag', get_string("useunplag", "plagiarism_unplag"), $ynoptions);
     $mform->addElement('select', 'unplag_show_student_score', get_string("unplag_show_student_score", "plagiarism_unplag"), $tiioptions);
     $mform->addHelpButton('unplag_show_student_score', 'unplag_show_student_score', 'plagiarism_unplag');
     $mform->addElement('select', 'unplag_show_student_report', get_string("unplag_show_student_report", "plagiarism_unplag"), $tiioptions);
     $mform->addHelpButton('unplag_show_student_report', 'unplag_show_student_report', 'plagiarism_unplag');
     if ($mform->elementExists('var4') || $mform->elementExists('submissiondrafts')) {
         $mform->addElement('select', 'unplag_draft_submit', get_string("unplag_draft_submit", "plagiarism_unplag"), $unplagdraftoptions);
     }
     $mform->addElement('select', 'unplag_studentemail', get_string("unplag_studentemail", "plagiarism_unplag"), $ynoptions);
     $mform->addHelpButton('unplag_studentemail', 'unplag_studentemail', 'plagiarism_unplag');
 }
コード例 #13
0
 /**
  * Add custom requirement rules to filter elements
  *
  * @param   object $mform  The mform object for the filter page
  * @param   string $key    The filter field key
  * @param   object $fields The filter field values object
  *
  * @return  object $mform  The modified mform object for the filter page
  */
 function apply_filter_required_rule($mform, $key, $fields)
 {
     if ($mform->elementExists($key . '_grp')) {
         $mform->addRule($key . '_grp', get_string('required'), 'required', null, 'client');
         $mform->addGroupRule($key . '_grp', array($key => array(array(get_string('required'), 'required', null, 'client'))));
     }
     return $mform;
 }