Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent e493fd5448
commit b4b1ba758c
  1. 165
      main/gradebook/lib/fe/dataform.class.php
  2. 184
      main/gradebook/lib/fe/evalform.class.php
  3. 3
      main/work/work_list.php

@ -21,89 +21,96 @@ class DataForm extends FormValidator
* @param method
* @param action
*/
public function __construct($form_type, $form_name, $method = 'post', $action = null, $target='', $locked_status)
{
parent :: __construct($form_name, $method, $action,$target);
$this->form_type = $form_type;
if ($this->form_type == self :: TYPE_IMPORT) {
$this->build_import_form();
} elseif ($this->form_type == self :: TYPE_EXPORT) {
if ($locked_status == 0) {
$this->build_export_form_option(false);
} else {
$this->build_export_form();
}
} elseif ($this->form_type == self :: TYPE_EXPORT_PDF) {
$this->build_pdf_export_form();
}
$this->setDefaults();
}
public function __construct($form_type, $form_name, $method = 'post', $action = null, $target = '', $locked_status)
{
parent:: __construct($form_name, $method, $action, $target);
$this->form_type = $form_type;
if ($this->form_type == self :: TYPE_IMPORT) {
$this->build_import_form();
} elseif ($this->form_type == self :: TYPE_EXPORT) {
if ($locked_status == 0) {
$this->build_export_form_option(false);
} else {
$this->build_export_form();
}
} elseif ($this->form_type == self :: TYPE_EXPORT_PDF) {
$this->build_pdf_export_form();
}
$this->setDefaults();
}
protected function build_pdf_export_form()
{
$renderer =& $this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span>');
$this->addElement('header', get_lang('ChooseOrientation'));
$this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait');
$this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape');
$this->addButtonExport(get_lang('Export'));
$this->setDefaults(array (
'orientation' => 'portrait'
));
}
protected function build_pdf_export_form()
{
$renderer =& $this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span>');
$this->addElement('header', get_lang('ChooseOrientation'));
$this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait');
$this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape');
$this->addButtonExport(get_lang('Export'));
$this->setDefaults(array (
'orientation' => 'portrait'
));
}
protected function build_export_form()
{
$this->addElement('header', get_lang('ChooseFormat'));
$this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
$this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf');
$this->addButtonExport(get_lang('Export'));
$this->setDefaults(array (
'file_type' => 'csv'
));
}
protected function build_export_form()
{
$this->addElement('header', get_lang('ChooseFormat'));
$this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
$this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf');
$this->addButtonExport(get_lang('Export'));
$this->setDefaults(array (
'file_type' => 'csv'
));
}
protected function build_export_form_option($show_pdf=true)
{
$this->addElement('header', get_lang('ChooseFormat'));
$this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
$this->addElement('radio', 'file_type', Display::return_icon('info3.gif',get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled'));
$this->addButtonExport(get_lang('Export'));
$this->setDefaults(array (
'file_type' => 'csv'
));
}
protected function build_export_form_option($show_pdf=true)
{
$this->addElement('header', get_lang('ChooseFormat'));
$this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
$this->addElement(
'radio',
'file_type',
Display::return_icon('info3.gif', get_lang('ToExportMustLockEvaluation')),
'PDF (Portable Document Format)',
'pdf',
array('disabled')
);
$this->addButtonExport(get_lang('Export'));
$this->setDefaults(array (
'file_type' => 'csv'
));
}
protected function build_import_form()
{
$this->addElement('hidden', 'formSent');
$this->addElement('header', get_lang('ImportFileLocation'));
$this->addElement('file', 'import_file',get_lang('Location'));
$allowed_file_types = array (
'xml',
'csv'
);
//$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types);
$this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml');
$this->addElement('checkbox','overwrite', null,get_lang('OverwriteScores'));
$this->addElement('checkbox','ignoreerrors',null,get_lang('IgnoreErrors'));
$this->addButtonImport(get_lang('Ok'));
$this->setDefaults(array(
'formSent' => '1',
'file_type' => 'csv'
));
}
protected function build_import_form()
{
$this->addElement('hidden', 'formSent');
$this->addElement('header', get_lang('ImportFileLocation'));
$this->addElement('file', 'import_file',get_lang('Location'));
$allowed_file_types = array (
'xml',
'csv'
);
//$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types);
$this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml');
$this->addElement('checkbox', 'overwrite', null, get_lang('OverwriteScores'));
$this->addElement('checkbox', 'ignoreerrors', null, get_lang('IgnoreErrors'));
$this->addButtonImport(get_lang('Ok'));
$this->setDefaults(array(
'formSent' => '1',
'file_type' => 'csv'
));
}
public function display()
{
parent :: display();
}
public function display()
{
parent :: display();
}
public function setDefaults($defaults = array(), $filter = null)
{
parent :: setDefaults($defaults, $filter);
}
public function setDefaults($defaults = array(), $filter = null)
{
parent :: setDefaults($defaults, $filter);
}
}

@ -24,12 +24,12 @@ class EvalForm extends FormValidator
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1=add, 2=edit,3=move,4=result_add
* @param obj cat_obj the category object
* @param obj res_obj the result object
* @param string form name
* @param method
* @param action
* @param int $form_type 1=add, 2=edit,3=move,4=result_add
* @param obj $evaluation_object the category object
* @param obj $result_object the result object
* @param string $form_name
* @param string $method
* @param string $action
*/
public function __construct(
$form_type,
@ -97,11 +97,17 @@ class EvalForm extends FormValidator
$select->addOption($letter, $letter);
}
}
$select = $this->addElement('select', 'add_users', null, null, array(
'multiple' => 'multiple',
'size' => '15',
'style' => 'width:250px'
));
$select = $this->addElement(
'select',
'add_users',
null,
null,
array(
'multiple' => 'multiple',
'size' => '15',
'style' => 'width:250px',
)
);
foreach ($this->evaluation_object->get_not_subscribed_students() as $user) {
if ((!isset($this->extra)) || empty($this->extra) || api_strtoupper(api_substr($user[1], 0, 1)) == $this->extra) {
$select->addoption($user[1] . ' ' . $user[2] . ' (' . $user[3] . ')', $user[0]);
@ -131,8 +137,8 @@ class EvalForm extends FormValidator
if (api_is_western_name_order()) {
$renderer->setHeaderTemplate(
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
<th>' . get_lang('UserName') . '</th>
<th>' . get_lang('FirstName') . '</th>
<th>' . get_lang('LastName') . '</th>
@ -141,8 +147,8 @@ class EvalForm extends FormValidator
);
} else {
$renderer->setHeaderTemplate(
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
<th>' . get_lang('UserName') . '</th>
<th>' . get_lang('LastName') . '</th>
<th>' . get_lang('FirstName') . '</th>
@ -151,12 +157,12 @@ class EvalForm extends FormValidator
);
}
$template_submit = '<tr>
<td colspan="4" ></td>
<td >
{element}
<!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
</td>
</tr>';
<td colspan="4" ></td>
<td>
{element}
<!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
</td>
</tr>';
$results_and_users = array();
foreach ($this->result_object as $result) {
@ -172,14 +178,35 @@ class EvalForm extends FormValidator
$result = $result_and_user['result'];
$renderer = &$this->defaultRenderer();
$this->addText('score[' . $result->get_id() . ']', $this->build_stud_label($user['user_id'], $user['username'], $user['lastname'], $user['firstname']), false, array('class' => "span2",
'maxlength' => 5));
$this->addText(
'score['.$result->get_id().']',
$this->build_stud_label($user['user_id'], $user['username'], $user['lastname'], $user['firstname']),
false,
array(
'class' => "span2",
'maxlength' => 5
)
);
$this->addRule('score[' . $result->get_id() . ']', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array(
'score[' . $result->get_id() . ']', 'maxvalue'), get_lang('OverMax'), 'compare', '<=');
$this->addRule(array(
'score[' . $result->get_id() . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$this->addRule(
array(
'score['.$result->get_id().']',
'maxvalue',
),
get_lang('OverMax'),
'compare',
'<='
);
$this->addRule(
array(
'score['.$result->get_id().']',
'minvalue',
),
get_lang('UnderMin'),
'compare',
'>='
);
$defaults['score[' . $result->get_id() . ']'] = $result->get_score();
if (api_is_western_name_order()) {
@ -250,8 +277,8 @@ class EvalForm extends FormValidator
if (api_is_western_name_order()) {
$renderer->setHeaderTemplate(
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
<th>' . get_lang('UserName') . '</th>
<th>' . get_lang('FirstName') . '</th>
<th>' . get_lang('LastName') . '</th>
@ -260,8 +287,8 @@ class EvalForm extends FormValidator
);
} else {
$renderer->setHeaderTemplate(
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
'<tr>
<th>' . get_lang('OfficialCode') . '</th>
<th>' . get_lang('UserName') . '</th>
<th>' . get_lang('LastName') . '</th>
<th>' . get_lang('FirstName') . '</th>
@ -274,14 +301,18 @@ class EvalForm extends FormValidator
foreach ($tblusers as $user) {
$element_name = 'score[' . $user[0] . ']';
$scoreColumnProperties = array('maxlength' => 5);
if ($firstUser) {
$scoreColumnProperties['autofocus'] = '';
$firstUser = false;
}
//user_id, user.username, lastname, firstname
$this->addText($element_name, $this->build_stud_label($user[0], $user[1], $user[2], $user[3]), false, $scoreColumnProperties);
$this->addText(
$element_name,
$this->build_stud_label($user[0], $user[1], $user[2], $user[3]),
false,
$scoreColumnProperties
);
$this->addRule($element_name, get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array($element_name, 'maxvalue'), get_lang('OverMax'), 'compare', '<=');
@ -340,25 +371,31 @@ class EvalForm extends FormValidator
'maxlength' => '5'
));
/* $this->addText('maximum', null, false, array (
'size' => '4',
'maxlength' => '5',
'disabled' => 'disabled'
)); */
$this->addButtonSave(get_lang('Edit'), 'submit');
$this->addElement('hidden', 'minvalue', 0);
$this->addElement('hidden', 'hid_user_id', $this->result_object->get_user_id());
$this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
$this->addRule('score', get_lang('OnlyNumbers'), 'numeric', null, 'client');
$this->addRule(array(
'score',
'maxvalue'
), get_lang('OverMax'), 'compare', '<=', 'client');
$this->addRule(array(
'score',
'minvalue'
), get_lang('UnderMin'), 'compare', '>=', 'client');
$this->addRule(
array(
'score',
'maxvalue',
),
get_lang('OverMax'),
'compare',
'<=',
'client'
);
$this->addRule(
array(
'score',
'minvalue',
),
get_lang('UnderMin'),
'compare',
'>=',
'client'
);
}
/**
@ -441,7 +478,13 @@ class EvalForm extends FormValidator
if (count($all_categories) == 1) {
$this->addElement('hidden', 'hid_category_id', $cat_id);
} else {
$select_gradebook = $this->addElement('select', 'hid_category_id', get_lang('SelectGradebook'), array(), array('id' => 'hid_category_id'));
$select_gradebook = $this->addElement(
'select',
'hid_category_id',
get_lang('SelectGradebook'),
array(),
array('id' => 'hid_category_id')
);
$this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'nonzero');
$default_weight = 0;
@ -469,11 +512,19 @@ class EvalForm extends FormValidator
}
}
$this->addText('weight_mask', array(get_lang('Weight'), null, ' [0 .. <span id="max_weight">' . $all_categories[0]->get_weight() . '</span>] '), true, array(
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));
$this->addText(
'weight_mask',
array(
get_lang('Weight'),
null,
' [0 .. <span id="max_weight">'.$all_categories[0]->get_weight().'</span>] ',
),
true,
array(
'size' => '4',
'maxlength' => '5'
)
);
/* $this->addText('weight', array(null, null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
'size' => '4',
@ -484,16 +535,24 @@ class EvalForm extends FormValidator
if ($edit) {
if (!$this->evaluation_object->has_results()) {
$this->addText('max', get_lang('QualificationNumeric'), true, array(
'class' => 'span1',
'maxlength' => '5'
));
$this->addText(
'max',
get_lang('QualificationNumeric'),
true,
array(
'maxlength' => '5'
)
);
} else {
$this->addText('max', array(get_lang('QualificationNumeric'), get_lang('CannotChangeTheMaxNote')), false, array(
'class' => 'span1',
'maxlength' => '5',
'disabled' => 'disabled'
));
$this->addText(
'max',
array(get_lang('QualificationNumeric'), get_lang('CannotChangeTheMaxNote')),
false,
array(
'maxlength' => '5',
'disabled' => 'disabled'
)
);
}
} else {
$this->addText('max', get_lang('QualificationNumeric'), true, array(
@ -506,7 +565,6 @@ class EvalForm extends FormValidator
}
$this->addElement('textarea', 'description', get_lang('Description'));
$this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'required');
$this->addElement('checkbox', 'visible', null, get_lang('Visible'));
$this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric');

@ -63,7 +63,8 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_in
get_lang('UploadMyAssignment'),
null,
ICON_SIZE_MEDIUM
) . get_lang('UploadMyAssignment'), $url,
) . get_lang('UploadMyAssignment'),
$url,
array('class'=>'btn-toolbar')
);
}

Loading…
Cancel
Save