Skip to content
Permalink
Browse files

Add support for skills tags - refs CT#8318

  • Loading branch information...
ywarnier committed Jul 6, 2016
1 parent f17126f commit f2bf214175308a627d420561ed4f114e9ef1e60c
@@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160706145000
* Add tag extra field for skills
* @package Application\Migrations\Schema\V111
*/
class Version20160706145000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW())");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("DELETE FROM extra_field WHERE extra_field_type = 8 AND field_type = 10 AND variable = 'tags'");
}
}
@@ -70,13 +70,32 @@
['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]
);
$createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
// EXTRA FIELDS
$extraField = new ExtraField('skill');
$returnParams = $extraField->addElements($createForm);
$jquery_ready_content = $returnParams['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
if (!empty($jquery_ready_content)) {
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
' . $jquery_ready_content . '
});
</script>';
}
$createForm->addButtonSave(get_lang('Save'));
$createForm->addHidden('id', null);
$createForm->setDefaults($formDefaultValues);
if ($createForm->validate()) {
$created = $objSkill->add($createForm->getSubmitValues());
$skillValues = $createForm->getSubmitValues();
$created = $objSkill->add($skillValues);
$skillValues['item_id'] = $created;
$extraFieldValue = new ExtraFieldValue('skill');
$extraFieldValue->saveFieldValues($skillValues);
if ($created) {
Session::write(
@@ -74,13 +74,31 @@
['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]
);
$editForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
// EXTRA FIELDS
$extraField = new ExtraField('skill');
$returnParams = $extraField->addElements($editForm, $skillId);
$jquery_ready_content = $returnParams['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
if (!empty($jquery_ready_content)) {
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
' . $jquery_ready_content . '
});
</script>';
}
$editForm->addButtonSave(get_lang('Save'));
$editForm->addHidden('id', null);
$editForm->setDefaults($skillDefaultInfo);
if ($editForm->validate()) {
$updated = $objSkill->edit($editForm->getSubmitValues());
$skillValues = $editForm->getSubmitValues();
$updated = $objSkill->edit($skillValues);
$extraFieldValue = new ExtraFieldValue('skill');
$extraFieldValue->saveFieldValues($skillValues);
if ($updated) {
Session::write(
@@ -122,6 +122,8 @@ public function __construct($type)
case 'lp_item':
$this->extraFieldType = EntityExtraField::LP_ITEM_FIELD_TYPE;
break;
case 'skill':
$this->extraFieldType = EntityExtraField::SKILL_FIELD_TYPE;
}
$this->pageUrl = 'extra_fields.php?type='.$this->type;
@@ -149,7 +151,8 @@ public static function getValidExtraFieldTypes()
'question',
'lp',
'calendar_event',
'lp_item'
'lp_item',
'skill'
);
}
@@ -286,7 +289,7 @@ public function get_handler_field_info_by_field_variable($variable)
}
/**
* Get all the field info for User Tags
* Get all the field info for tags
* @param string $variable
*
* @return array|bool
@@ -410,8 +413,12 @@ public static function get_extra_fields_by_handler($handler)
switch ($handler) {
case 'course':
// no break
case 'session':
// no break
case 'user':
// no break
case 'skill':
break;
}
@@ -594,9 +601,9 @@ public function get_field_type_by_id($id)
* France:Paris;Bretagne;Marseille;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura;
* into
* array(
* 'France' =>
* 'France' =>
* array('Paris', 'Bregtane', 'Marseille'),
* 'Belgique' =>
* 'Belgique' =>
* array('Namur', 'Liège')
* ), etc
* @param string $string
@@ -769,15 +776,17 @@ public function delete($id)
}
/**
* Add an element that matches the given extra field to the given $form object
* @param FormValidator $form
* @param array $extraData
* @param bool $admin_permissions
* @param int $user_id
* @param array $extra
* @param int $itemId
* @param array $exclude variables of extra field to exclude
* @param array
* @return array
* @param bool $useTagAsSelect
* @param array $showOnlyThisFields
* @param array $orderFields
* @return array If relevant, returns a one-element array with JS code to be added to the page HTML headers
*/
public function set_extra_fields_in_form(
$form,
@@ -1348,16 +1357,16 @@ public function set_extra_fields_in_form(
//if cache is set to true the jquery will be called 1 time
$jquery_ready_content .= <<<EOF
$("#extra_$variable").fcbkcomplete({
json_url: "$url?a=search_tags&field_id=$field_id&type={$this->type}",
cache: false,
filter_case: true,
filter_hide: true,
complete_text:"$complete_text",
firstselected: false,
filter_selected: true,
newel: true
});
$("#extra_$variable").fcbkcomplete({
json_url: "$url?a=search_tags&field_id=$field_id&type={$this->type}",
cache: false,
filter_case: true,
filter_hide: true,
complete_text:"$complete_text",
firstselected: false,
filter_selected: true,
newel: true
});
EOF;
}
break;
@@ -1885,3 +1885,7 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('show_offic
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 1);
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 2);
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 3);

UPDATE settings_current SET selected_value = '1.11.0.5' WHERE variable = 'chamilo_database_version';

INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW());
@@ -24,6 +24,7 @@ class ExtraField extends BaseAttribute
const CALENDAR_FIELD_TYPE = 5;
const LP_FIELD_TYPE = 6;
const LP_ITEM_FIELD_TYPE = 7;
const SKILL_FIELD_TYPE = 8;
/**
* @var integer

0 comments on commit f2bf214

Please sign in to comment.
You can’t perform that action at this time.