|
|
@ -12,32 +12,43 @@ |
|
|
|
* @package chamilo.library |
|
|
|
* @package chamilo.library |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class GradeModel extends Model { |
|
|
|
class GradeModel extends Model |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var $table; |
|
|
|
public $table; |
|
|
|
var $columns = array('id', 'name', 'description'); |
|
|
|
public $columns = array('id', 'name', 'description'); |
|
|
|
|
|
|
|
|
|
|
|
public function __construct() { |
|
|
|
public function __construct() |
|
|
|
|
|
|
|
{ |
|
|
|
$this->table = Database::get_main_table(TABLE_GRADE_MODEL); |
|
|
|
$this->table = Database::get_main_table(TABLE_GRADE_MODEL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_all($where_conditions = array()) { |
|
|
|
public function get_all($where_conditions = array()) |
|
|
|
|
|
|
|
{ |
|
|
|
return Database::select('*', $this->table, array('where' => $where_conditions, 'order' => 'name ASC')); |
|
|
|
return Database::select('*', $this->table, array('where' => $where_conditions, 'order' => 'name ASC')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_count() { |
|
|
|
public function get_count() |
|
|
|
|
|
|
|
{ |
|
|
|
$row = Database::select('count(*) as count', $this->table, array(), 'first'); |
|
|
|
$row = Database::select('count(*) as count', $this->table, array(), 'first'); |
|
|
|
|
|
|
|
|
|
|
|
return $row['count']; |
|
|
|
return $row['count']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Displays the title + grid |
|
|
|
* Displays the title + grid |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function display() { |
|
|
|
public function display() |
|
|
|
|
|
|
|
{ |
|
|
|
// action links |
|
|
|
// action links |
|
|
|
echo '<div class="actions" style="margin-bottom:20px">'; |
|
|
|
echo '<div class="actions" style="margin-bottom:20px">'; |
|
|
|
echo '<a href="grade_models.php">'.Display::return_icon('back.png', get_lang('Back'), '', '32').'</a>'; |
|
|
|
echo '<a href="grade_models.php">'.Display::return_icon('back.png', get_lang('Back'), '', '32').'</a>'; |
|
|
|
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>'; |
|
|
|
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon( |
|
|
|
|
|
|
|
'add.png', |
|
|
|
|
|
|
|
get_lang('Add'), |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
'32' |
|
|
|
|
|
|
|
).'</a>'; |
|
|
|
echo '</div>'; |
|
|
|
echo '</div>'; |
|
|
|
echo Display::grid_html('grade_model'); |
|
|
|
echo Display::grid_html('grade_model'); |
|
|
|
} |
|
|
|
} |
|
|
@ -49,7 +60,8 @@ class GradeModel extends Model { |
|
|
|
* @param string action add, edit |
|
|
|
* @param string action add, edit |
|
|
|
* @return obj form validator obj |
|
|
|
* @return obj form validator obj |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function return_form($url, $action) { |
|
|
|
public function return_form($url, $action) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$oFCKeditor = new FCKeditor('description'); |
|
|
|
$oFCKeditor = new FCKeditor('description'); |
|
|
|
$oFCKeditor->ToolbarSet = 'grade_model'; |
|
|
|
$oFCKeditor->ToolbarSet = 'grade_model'; |
|
|
@ -72,7 +84,13 @@ class GradeModel extends Model { |
|
|
|
$form->addElement('hidden', 'id', $id); |
|
|
|
$form->addElement('hidden', 'id', $id); |
|
|
|
|
|
|
|
|
|
|
|
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70')); |
|
|
|
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70')); |
|
|
|
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250')); |
|
|
|
$form->add_html_editor( |
|
|
|
|
|
|
|
'description', |
|
|
|
|
|
|
|
get_lang('Description'), |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
array('ToolbarSet' => 'careers', 'Width' => '100%', 'Height' => '250') |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$form->addElement('label', get_lang('Components')); |
|
|
|
$form->addElement('label', get_lang('Components')); |
|
|
|
|
|
|
|
|
|
|
@ -102,9 +120,24 @@ class GradeModel extends Model { |
|
|
|
for ($i = 0; $i <= $max; $i++) { |
|
|
|
for ($i = 0; $i <= $max; $i++) { |
|
|
|
$counter = $i; |
|
|
|
$counter = $i; |
|
|
|
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1')); |
|
|
|
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1')); |
|
|
|
$form->addElement('text', 'components['.$i.'][acronym]', null, array('class' => 'span1', 'placeholder' => get_lang('Acronym'))); |
|
|
|
$form->addElement( |
|
|
|
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span2', 'placeholder' => get_lang('Title'))); |
|
|
|
'text', |
|
|
|
$form->addElement('text', 'components['.$i.'][prefix]', null, array('class'=> 'span1', 'placeholder' => get_lang('Prefix'))); |
|
|
|
'components['.$i.'][acronym]', |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
array('class' => 'span1', 'placeholder' => get_lang('Acronym')) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$form->addElement( |
|
|
|
|
|
|
|
'text', |
|
|
|
|
|
|
|
'components['.$i.'][title]', |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
array('class' => 'span2', 'placeholder' => get_lang('Title')) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$form->addElement( |
|
|
|
|
|
|
|
'text', |
|
|
|
|
|
|
|
'components['.$i.'][prefix]', |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
array('class' => 'span1', 'placeholder' => get_lang('Prefix')) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$options = array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5); |
|
|
|
$options = array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5); |
|
|
|
$form->addElement('select', 'components['.$i.'][count_elements]', null, $options); |
|
|
|
$form->addElement('select', 'components['.$i.'][count_elements]', null, $options); |
|
|
@ -113,7 +146,6 @@ class GradeModel extends Model { |
|
|
|
$form->addElement('select', 'components['.$i.'][exclusions]', null, $options); |
|
|
|
$form->addElement('select', 'components['.$i.'][exclusions]', null, $options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form->addElement('hidden', 'components['.$i.'][id]'); |
|
|
|
$form->addElement('hidden', 'components['.$i.'][id]'); |
|
|
|
|
|
|
|
|
|
|
|
$template_percentage = |
|
|
|
$template_percentage = |
|
|
@ -130,10 +162,14 @@ class GradeModel extends Model { |
|
|
|
$template_title = |
|
|
|
$template_title = |
|
|
|
' {element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error --> |
|
|
|
' {element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error --> |
|
|
|
<a href="javascript:plusItem('.($counter + 1).')"> |
|
|
|
<a href="javascript:plusItem('.($counter + 1).')"> |
|
|
|
<img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="plus-' . ($counter+1) . '" src="../img/icons/22/add.png" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></img> |
|
|
|
<img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="plus-'.($counter + 1).'" src="../img/icons/22/add.png" alt="'.get_lang( |
|
|
|
|
|
|
|
'Add' |
|
|
|
|
|
|
|
).'" title="'.get_lang('Add').'"></img> |
|
|
|
</a> |
|
|
|
</a> |
|
|
|
<a href="javascript:minItem('.($counter).')"> |
|
|
|
<a href="javascript:minItem('.($counter).')"> |
|
|
|
<img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="min-' . $counter . '" src="../img/delete.png" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></img> |
|
|
|
<img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="min-'.$counter.'" src="../img/delete.png" alt="'.get_lang( |
|
|
|
|
|
|
|
'Delete' |
|
|
|
|
|
|
|
).'" title="'.get_lang('Delete').'"></img> |
|
|
|
</a> |
|
|
|
</a> |
|
|
|
</div></p></div>'; |
|
|
|
</div></p></div>'; |
|
|
|
|
|
|
|
|
|
|
@ -183,18 +219,22 @@ class GradeModel extends Model { |
|
|
|
|
|
|
|
|
|
|
|
// Setting the rules |
|
|
|
// Setting the rules |
|
|
|
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
|
|
|
|
|
|
|
|
return $form; |
|
|
|
return $form; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_components($id) { |
|
|
|
public function get_components($id) |
|
|
|
|
|
|
|
{ |
|
|
|
$obj = new GradeModelComponents(); |
|
|
|
$obj = new GradeModelComponents(); |
|
|
|
if (!empty($id)) { |
|
|
|
if (!empty($id)) { |
|
|
|
return $obj->get_all(array('where' => array('grade_model_id = ?' => $id))); |
|
|
|
return $obj->get_all(array('where' => array('grade_model_id = ?' => $id))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function save($params, $show_query = false) { |
|
|
|
public function save($params, $show_query = false) |
|
|
|
|
|
|
|
{ |
|
|
|
$id = parent::save($params, $show_query); |
|
|
|
$id = parent::save($params, $show_query); |
|
|
|
if (!empty($id)) { |
|
|
|
if (!empty($id)) { |
|
|
|
foreach ($params['components'] as $component) { |
|
|
|
foreach ($params['components'] as $component) { |
|
|
@ -205,11 +245,13 @@ class GradeModel extends Model { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
|
|
//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
|
|
return $id; |
|
|
|
return $id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function update($params) { |
|
|
|
public function update($params) |
|
|
|
|
|
|
|
{ |
|
|
|
parent::update($params); |
|
|
|
parent::update($params); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($params['id'])) { |
|
|
|
if (!empty($params['id'])) { |
|
|
@ -226,12 +268,14 @@ class GradeModel extends Model { |
|
|
|
//$params['components'] |
|
|
|
//$params['components'] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function delete($id) { |
|
|
|
public function delete($id) |
|
|
|
|
|
|
|
{ |
|
|
|
parent::delete($id); |
|
|
|
parent::delete($id); |
|
|
|
//event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
|
|
//event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null) { |
|
|
|
public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null) |
|
|
|
|
|
|
|
{ |
|
|
|
if (api_get_setting('gradebook_enable_grade_model') == 'false') { |
|
|
|
if (api_get_setting('gradebook_enable_grade_model') == 'false') { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -264,15 +308,29 @@ class GradeModel extends Model { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class GradeModelComponents extends Model { |
|
|
|
class GradeModelComponents extends Model |
|
|
|
|
|
|
|
{ |
|
|
|
var $table; |
|
|
|
var $table; |
|
|
|
var $columns = array('id', 'title', 'percentage', 'acronym', 'grade_model_id', 'prefix', 'exclusions', 'count_elements'); |
|
|
|
var $columns = array( |
|
|
|
|
|
|
|
'id', |
|
|
|
public function __construct() { |
|
|
|
'title', |
|
|
|
|
|
|
|
'percentage', |
|
|
|
|
|
|
|
'acronym', |
|
|
|
|
|
|
|
'grade_model_id', |
|
|
|
|
|
|
|
'prefix', |
|
|
|
|
|
|
|
'exclusions', |
|
|
|
|
|
|
|
'count_elements' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct() |
|
|
|
|
|
|
|
{ |
|
|
|
$this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS); |
|
|
|
$this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS); |
|
|
|
} |
|
|
|
} |
|
|
|
public function save($params, $show_query = false) { |
|
|
|
|
|
|
|
|
|
|
|
public function save($params, $show_query = false) |
|
|
|
|
|
|
|
{ |
|
|
|
$id = parent::save($params, $show_query); |
|
|
|
$id = parent::save($params, $show_query); |
|
|
|
|
|
|
|
|
|
|
|
return $id; |
|
|
|
return $id; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |