Ejemplo n.º 1
0
     }
     break;
 case 'create_dir':
 case 'add':
     //$check = Security::check_token('post');
     //show them the form for the directory name
     if ($is_allowed_to_edit && in_array($action, array('create_dir', 'add'))) {
         //create the form that asks for the directory name
         $form = new FormValidator('form1', 'post', api_get_self() . '?action=create_dir&' . api_get_cidreq());
         $form->addElement('header', get_lang('CreateAssignment') . $token);
         $form->addElement('hidden', 'action', 'add');
         $form->addElement('hidden', 'curdirpath', Security::remove_XSS($curdirpath));
         // $form->addElement('hidden', 'sec_token', $token);
         $form->addElement('text', 'new_dir', get_lang('AssignmentName'));
         $form->addRule('new_dir', get_lang('ThisFieldIsRequired'), 'required');
         $form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
         $form->addElement('advanced_settings', '<a href="javascript: void(0);" onclick="javascript: return plus();"><span id="plus">' . Display::return_icon('div_show.gif', get_lang('AdvancedParameters'), array('style' => 'vertical-align:center')) . ' ' . get_lang('AdvancedParameters') . '</span></a>');
         $form->addElement('html', '<div id="options" style="display: none;">');
         //QualificationOfAssignment
         $form->addElement('text', 'qualification_value', get_lang('QualificationNumeric'));
         if (Gradebook::is_active()) {
             $form->addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), array('id' => 'make_calification_id', 'onclick' => "javascript: if(this.checked){document.getElementById('option1').style.display='block';}else{document.getElementById('option1').style.display='none';}"));
         } else {
             //QualificationOfAssignment
             //$form->addElement('hidden', 'qualification_value',0);
             $form->addElement('hidden', 'make_calification', false);
         }
         $form->addElement('html', '<div id="option1" style="display: none;">');
         //Loading gradebook select
         load_gradebook_select_in_tool($form);
         $form->addElement('text', 'weight', get_lang('WeightInTheGradebook'));
Ejemplo n.º 2
0
/**
 * @param FormValidator $form
 * @param array $defaults
 * @return FormValidator
 */
function getFormWork($form, $defaults = array())
{
    if (!empty($defaults)) {
        if (isset($defaults['submit'])) {
            unset($defaults['submit']);
        }
    }
    // Create the form that asks for the directory name
    $form->addElement('text', 'new_dir', get_lang('AssignmentName'));
    $form->addRule('new_dir', get_lang('ThisFieldIsRequired'), 'required');
    $form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
    $form->addElement(
        'advanced_settings',
        '<a href="javascript: void(0);" onclick="javascript: return plus();">
        <span id="plus">'.
        Display::return_icon(
            'div_show.gif',
            get_lang('AdvancedParameters'),
            array('style' => 'vertical-align:center')
        ).
        ' '.get_lang('AdvancedParameters').
        '</span></a>'
    );

    if (!empty($defaults) && (isset($defaults['enableEndDate']) || isset($defaults['enableExpiryDate']))) {
        $form->addElement('html', '<div id="options" style="display: block;">');
    } else {
        $form->addElement('html', '<div id="options" style="display: none;">');
    }

    // QualificationOfAssignment
    $form->addElement('text', 'qualification', get_lang('QualificationNumeric'));

    if ((api_get_session_id() != 0 && Gradebook::is_active()) || api_get_session_id() == 0) {
        $form->addElement(
            'checkbox',
            'make_calification',
            null,
            get_lang('MakeQualifiable'),
            array(
                'id' =>'make_calification_id',
                'onclick' => "javascript: if(this.checked) { document.getElementById('option1').style.display='block';}else{document.getElementById('option1').style.display='none';}"
            )
        );
    } else {
        // QualificationOfAssignment
        $form->addElement('hidden', 'make_calification', false);
    }

    if (!empty($defaults) && isset($defaults['category_id'])) {
        $form->addElement('html', '<div id=\'option1\' style="display:block">');
    } else {
        $form->addElement('html', '<div id=\'option1\' style="display:none">');
    }

    // Loading Gradebook select
    load_gradebook_select_in_tool($form);

    $form->addElement('text', 'weight', get_lang('WeightInTheGradebook'));
    $form->addElement('html', '</div>');

    $form->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'id="expiry_date"');
    if (isset($defaults['enableExpiryDate']) && $defaults['enableExpiryDate']) {
        $form->addElement('html', '<div id="option2" style="display: block;">');
    } else {
        $form->addElement('html', '<div id="option2" style="display: none;">');
    }

    $currentDate = substr(api_get_local_time(), 0, 10);

    if (!isset($defaults['expires_on'])) {
        $date = substr($currentDate, 0, 10);
        $defaults['expires_on'] = $date.' 23:59';
    }

    if (!isset($defaults['ends_on'])) {
        $date = substr($currentDate, 0, 10);
        $defaults['ends_on'] = $date.' 23:59';
    }

    $form->addElement('date_time_picker', 'expires_on', get_lang('ExpiresAt'));
    $form->addElement('html', '</div>');

    $form->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'id="end_date"');

    if (isset($defaults['enableEndDate']) && $defaults['enableEndDate']) {
        $form->addElement('html', '<div id="option3" style="display: block;">');
    } else {
        $form->addElement('html', '<div id="option3" style="display: none;">');
    }

    $form->addElement('date_time_picker', 'ends_on', get_lang('EndsAt'));
    $form->addElement('html', '</div>');

    $form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
    $form->addElement('select', 'allow_text_assignment', get_lang('DocumentType'), getUploadDocumentType());

    $form->addElement('html', '</div>');

    if (isset($defaults['enableExpiryDate']) && isset($defaults['enableEndDate'])) {
        $form->addRule(array('expires_on', 'ends_on'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
    }
    if (!empty($defaults)) {
        $form->setDefaults($defaults);
    }

    return $form;
}