diff --git a/main/attendance/attendance_add.php b/main/attendance/attendance_add.php index 075a724639..a559ebf711 100755 --- a/main/attendance/attendance_add.php +++ b/main/attendance/attendance_add.php @@ -65,6 +65,9 @@ if ((api_get_session_id() != 0 && Gradebook::is_active()) || api_get_session_id( ); $form->applyFilter('attendance_weight', 'html_filter'); $form->addElement('html', ''); + + $skillList = Skill::addSkillsToForm($form, ITEM_TYPE_ATTENDANCE, 0); + $form->addElement('html', ''); } $form->addButtonCreate(get_lang('Save')); diff --git a/main/attendance/attendance_controller.php b/main/attendance/attendance_controller.php index fca024066b..26b26bf944 100755 --- a/main/attendance/attendance_controller.php +++ b/main/attendance/attendance_controller.php @@ -45,7 +45,6 @@ class AttendanceController { $attendance = new Attendance(); $data = []; - if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { if (!empty($_POST['title'])) { $check = Security::check_token(); @@ -62,10 +61,15 @@ class AttendanceController $link_to_gradebook = true; } $attendance->category_id = isset($_POST['category_id']) ? $_POST['category_id'] : 0; - $last_id = $attendance->attendance_add($link_to_gradebook); + $attendanceId = $attendance->attendance_add($link_to_gradebook); + + if ($attendanceId) { + $form = new FormValidator('attendance_add'); + Skill::saveSkills($form, ITEM_TYPE_ATTENDANCE, $attendanceId); + } Security::clear_token(); } - header('Location: index.php?action=calendar_add&attendance_id='.$last_id.'&'.api_get_cidreq()); + header('Location: index.php?action=calendar_add&attendance_id='.$attendanceId.'&'.api_get_cidreq()); exit; } else { $data['error'] = true; @@ -119,8 +123,13 @@ class AttendanceController $link_to_gradebook = true; } $attendance->attendance_edit($attendance_id, $link_to_gradebook); + + $form = new FormValidator('attendance_edit'); + Skill::saveSkills($form, ITEM_TYPE_ATTENDANCE, $attendance_id); + Display::addFlash(Display::return_message(get_lang('Updated'))); + Security::clear_token(); - header('location:index.php?action=attendance_list&'.api_get_cidreq()); + header('Location:index.php?action=attendance_list&'.api_get_cidreq()); exit; } } else { @@ -167,6 +176,7 @@ class AttendanceController $attendance = new Attendance(); if (!empty($attendance_id)) { $affected_rows = $attendance->attendance_delete($attendance_id); + Skill::deleteSkillsFromItem($attendance_id, ITEM_TYPE_ATTENDANCE); } if ($affected_rows) { diff --git a/main/attendance/attendance_edit.php b/main/attendance/attendance_edit.php index 587469054c..9cde9f1286 100755 --- a/main/attendance/attendance_edit.php +++ b/main/attendance/attendance_edit.php @@ -44,8 +44,8 @@ $form->addHtmlEditor( ] ); -// Adavanced Parameters - +// Advanced Parameters +$skillList = []; if (Gradebook::is_active()) { if (!empty($attendance_qualify_title) || !empty($attendance_weight)) { $form->addButtonAdvancedSettings('id_qualify'); @@ -81,6 +81,9 @@ if (Gradebook::is_active()) { ); $form->applyFilter('attendance_weight', 'html_filter'); $form->addElement('html', ''); + + $skillList = Skill::addSkillsToForm($form, ITEM_TYPE_ATTENDANCE, $attendance_id); + $form->addElement('html', ''); } $form->addButtonUpdate(get_lang('Save')); @@ -90,6 +93,7 @@ $default['title'] = Security::remove_XSS($title); $default['description'] = Security::remove_XSS($description, STUDENT); $default['attendance_qualify_title'] = $attendance_qualify_title; $default['attendance_weight'] = $attendance_weight; +$default['skills'] = array_keys($skillList); $link_info = GradebookUtils::isResourceInCourseGradebook( api_get_course_id(), diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index aa40e9dc54..f47e7d95dc 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -1850,8 +1850,8 @@ class Exercise */ public function delete() { - $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); - $sql = "UPDATE $TBL_EXERCISES SET active='-1' + $table = Database::get_course_table(TABLE_QUIZ_TEST); + $sql = "UPDATE $table SET active='-1' WHERE c_id = ".$this->course_id." AND id = ".intval($this->id); Database::query($sql); @@ -1870,6 +1870,8 @@ class Exercise api_get_user_id() ); + Skill::deleteSkillsFromItem($this->iId, ITEM_TYPE_EXERCISE); + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) { @@ -2498,7 +2500,7 @@ class Exercise } } - //$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_EXERCISE, $this->iId); + $skillList = Skill::addSkillsToForm($form, ITEM_TYPE_EXERCISE, $this->iId); $form->addElement('html', ''); //End advanced setting $form->addElement('html', ''); @@ -2564,7 +2566,7 @@ class Exercise } else { $defaults['enabletimercontroltotalminutes'] = 0; } - //$defaults['skills'] = array_keys($skillList); + $defaults['skills'] = array_keys($skillList); $defaults['notifications'] = $this->getNotifications(); } else { $defaults['exerciseType'] = 2; @@ -2709,9 +2711,9 @@ class Exercise } $iId = $this->save($type); - /*if (!empty($iId)) { + if (!empty($iId)) { Skill::saveSkills($form, ITEM_TYPE_EXERCISE, $iId); - }*/ + } } public function search_engine_save() @@ -6077,7 +6079,6 @@ class Exercise ); $html = '
'; - if (api_get_configuration_value('save_titles_as_html')) { $html .= $this->get_formated_title(); $html .= Display::page_header(get_lang('Result')); diff --git a/main/forum/editthread.php b/main/forum/editthread.php index b50eee6d3b..0f7f2294b0 100644 --- a/main/forum/editthread.php +++ b/main/forum/editthread.php @@ -179,7 +179,7 @@ $form->addElement('text', 'thread_title', get_lang('Title')); $form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters')); $form->addElement('html', ''); +$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, $threadId); + if (!empty($threadData)) { $defaults['thread_qualify_gradebook'] = ($threadData['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0; $defaults['thread_title'] = prepare4display($threadData['threadTitle']); @@ -240,16 +242,20 @@ if (!empty($threadData)) { $defaults['thread_peer_qualify'] = 0; } +$defaults['skills'] = array_keys($skillList); + $form->addButtonUpdate(get_lang('ModifyThread'), 'SubmitPost'); if ($form->validate()) { $redirectUrl = api_get_path(WEB_CODE_PATH).'forum/viewforum.php?forum='.$forumId.'&'.api_get_cidreq(); - $check = Security::check_token('post'); if ($check) { $values = $form->exportValues(); Security::clear_token(); updateThread($values); + + Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $threadId); + header('Location: '.$redirectUrl); exit; } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 8f1c1e7717..583dd9adc2 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -101,7 +101,7 @@ function handle_forum_and_forumcategories($lp_id = null) $get_id = isset($_GET['id']) ? intval($_GET['id']) : ''; $forum_categories_list = get_forum_categories(); - //Verify if forum category exists + // Verify if forum category exists if (empty($forum_categories_list)) { $get_content = 'forumcategory'; } @@ -117,10 +117,9 @@ function handle_forum_and_forumcategories($lp_id = null) if ((($action_forum_cat == 'add' || $action_forum_cat == 'edit') && $get_content == 'forum') || $post_submit_forum ) { + $inputvalues = []; if ($action_forum_cat == 'edit' && $get_id || $post_submit_forum) { $inputvalues = get_forums($get_id); - } else { - $inputvalues = []; } $content = show_add_forum_form($inputvalues, $lp_id); } @@ -246,10 +245,9 @@ function show_add_forum_form($inputvalues = [], $lp_id) $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq()); // The header for the form + $form_title = get_lang('AddForum'); if (!empty($inputvalues)) { $form_title = get_lang('EditForum'); - } else { - $form_title = get_lang('AddForum'); } $form->addElement('header', $form_title); @@ -387,6 +385,10 @@ function show_add_forum_form($inputvalues = [], $lp_id) 'filetype', ['jpg', 'jpeg', 'png', 'gif'] ); + + //$forumId = isset($_GET['id']) ? (int) $_GET['id'] : 0; + //$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_FORUM, $forumId); + $form->addElement('html', '
'); // The OK button @@ -433,14 +435,24 @@ function show_add_forum_form($inputvalues = [], $lp_id) $defaults['public_private_group_forum_group']['public_private_group_forum'] = isset($inputvalues['forum_group_public_private']) ? $inputvalues['forum_group_public_private'] : null; $defaults['group_forum'] = isset($inputvalues['forum_of_group']) ? $inputvalues['forum_of_group'] : null; } + + // $defaults['skills'] = array_keys($skillList); + $form->setDefaults($defaults); // Validation or display if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->getSubmitValues(); - $return_message = store_forum($values); - Display::addFlash(Display::return_message($return_message, 'confirmation')); + $forumId = store_forum($values, '', true); + if ($forumId) { + // Skill::saveSkills($form, ITEM_TYPE_FORUM, $forumId); + if (isset($values['forum_id'])) { + Display::addFlash(Display::return_message(get_lang('ForumEdited'), 'confirmation')); + } else { + Display::addFlash(Display::return_message(get_lang('ForumAdded'), 'confirmation')); + } + } } Security::clear_token(); } else { @@ -647,11 +659,9 @@ function store_forum($values, $courseInfo = [], $returnId = false) $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo; $course_id = $courseInfo['real_id']; $session_id = api_get_session_id(); - + $group_id = api_get_group_id(); if (isset($values['group_id']) && !empty($values['group_id'])) { $group_id = $values['group_id']; - } else { - $group_id = api_get_group_id(); } $groupInfo = []; if (!empty($group_id)) { @@ -677,11 +687,10 @@ function store_forum($values, $courseInfo = [], $returnId = false) // Forum images $image_moved = false; $has_attachment = false; + $image_moved = true; if (!empty($_FILES['picture']['name'])) { $upload_ok = process_uploaded_file($_FILES['picture']); $has_attachment = true; - } else { - $image_moved = true; } // Remove existing picture if it was requested. @@ -765,6 +774,7 @@ function store_forum($values, $courseInfo = [], $returnId = false) ); $return_message = get_lang('ForumEdited'); + $forumId = $values['forum_id']; } else { if ($image_moved) { $new_file_name = isset($new_file_name) ? $new_file_name : ''; @@ -793,31 +803,32 @@ function store_forum($values, $courseInfo = [], $returnId = false) 'forum_id' => 0 ]; - $last_id = Database::insert($table_forums, $params); - if ($last_id > 0) { - $sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $last_id"; + $forumId = Database::insert($table_forums, $params); + if ($forumId > 0) { + $sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $forumId"; Database::query($sql); api_item_property_update( $courseInfo, TOOL_FORUM, - $last_id, + $forumId, 'ForumAdded', api_get_user_id(), $groupInfo ); api_set_default_visibility( - $last_id, + $forumId, TOOL_FORUM, $group_id, $courseInfo ); } $return_message = get_lang('ForumAdded'); - if ($returnId) { - return $last_id; - } + } + + if ($returnId) { + return $forumId; } return $return_message; @@ -911,6 +922,7 @@ function deleteForumCategoryThread($content, $id) if ($content == 'thread') { $tool_constant = TOOL_FORUM_THREAD; $return_message = get_lang('ThreadDeleted'); + Skill::deleteSkillsFromItem($id, ITEM_TYPE_FORUM_THREAD); } api_item_property_update( @@ -2624,8 +2636,8 @@ function store_thread( $visible = 1; } $clean_post_title = $values['post_title']; - // We first store an entry in the forum_thread table because the thread_id is used in the forum_post table. + // We first store an entry in the forum_thread table because the thread_id is used in the forum_post table. $lastThread = new CForumThread(); $lastThread ->setCId($course_id) @@ -2975,6 +2987,10 @@ function show_add_post_form($current_forum, $forum_setting, $action, $id = '', $ $form->addElement('html', ''); } + if ($action == 'newthread') { + Skill::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, 0); + } + if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && $action == 'newthread') { $form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost')); } @@ -3082,6 +3098,7 @@ function show_add_post_form($current_forum, $forum_setting, $action, $id = '', $ switch ($action) { case 'newthread': $myThread = store_thread($current_forum, $values); + Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $myThread); break; case 'quote': case 'replythread': diff --git a/main/gradebook/gradebook_display_summary.php b/main/gradebook/gradebook_display_summary.php index 3a5312afb0..85ba7f0014 100644 --- a/main/gradebook/gradebook_display_summary.php +++ b/main/gradebook/gradebook_display_summary.php @@ -129,21 +129,42 @@ if (count($userList) > 0) { } echo ''; +$allowSkillRelItem = api_get_configuration_value('allow_skill_rel_items'); + if (count($userList) == 0) { echo Display::return_message(get_lang('NoResultsAvailable'), 'warning'); } else { echo '

'; + echo ''; + echo ''; foreach ($userList as $index => $value) { echo ' - '; + '; echo ''; } diff --git a/main/gradebook/lib/be/abstractlink.class.php b/main/gradebook/lib/be/abstractlink.class.php index c8564bb176..a0172baf6d 100755 --- a/main/gradebook/lib/be/abstractlink.class.php +++ b/main/gradebook/lib/be/abstractlink.class.php @@ -695,4 +695,38 @@ abstract class AbstractLink implements GradebookItem return []; } + + /** + * @return string + */ + public function getSkillsFromItem() + { + $toolType = ''; + switch ($this->type) { + case LINK_ATTENDANCE: + $toolType = ITEM_TYPE_ATTENDANCE; + break; + case LINK_EXERCISE: + $toolType = ITEM_TYPE_EXERCISE; + break; + case LINK_FORUM_THREAD: + $toolType = ITEM_TYPE_FORUM_THREAD; + break; + case LINK_LEARNPATH: + $toolType = ITEM_TYPE_LEARNPATH; + break; + case LINK_HOTPOTATOES: + $toolType = ITEM_TYPE_HOTPOTATOES; + break; + case LINK_STUDENTPUBLICATION: + $toolType = ITEM_TYPE_STUDENT_PUBLICATION; + break; + case LINK_SURVEY: + $toolType = ITEM_TYPE_SURVEY; + break; + } + + $skillToString = Skill::getSkillRelItemsToString($toolType, $this->get_ref_id()); + return $skillToString; + } } diff --git a/main/gradebook/lib/fe/evalform.class.php b/main/gradebook/lib/fe/evalform.class.php index 0d30aa3b42..05e2f24001 100755 --- a/main/gradebook/lib/fe/evalform.class.php +++ b/main/gradebook/lib/fe/evalform.class.php @@ -130,9 +130,7 @@ class EvalForm extends FormValidator { //extra field for check on maxvalue $this->addElement('header', get_lang('EditResult')); - $renderer = &$this->defaultRenderer(); - // set new form template $form_template = '
'; + echo get_lang('Student'); + echo ''; + echo get_lang('Action'); + echo '
'. - get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') ' + .api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') '; + $link = ''; + if ($allowSkillRelItem) { + $url = api_get_path(WEB_CODE_PATH).'gradebook/skill_rel_user.php?'.api_get_cidreq().'&user_id='.$value['user_id'].'&selectcat='.$cat_id; + $link = Display::url( + get_lang('Skills'), + $url, + ['class' => 'btn btn-default'] + ).' '; + } + $url = api_get_self().'?'.api_get_cidreq().'&action=download&user_id='.$value['user_id'].'&selectcat='.$cat_id; - $link = Display::url( + $link .= Display::url( get_lang('ExportToPDF'), $url, ['target' => '_blank', 'class' => 'btn btn-default'] ); + + + echo $link; echo '
{content} @@ -179,7 +177,6 @@ class EvalForm extends FormValidator foreach ($results_and_users as $result_and_user) { $user = $result_and_user['user']; $result = $result_and_user['result']; - $renderer = &$this->defaultRenderer(); $this->addFloat( 'score['.$result->get_id().']', @@ -254,7 +251,7 @@ class EvalForm extends FormValidator ' ); - $tblusers = GradebookUtils::get_users_in_course($this->evaluation_object->get_course_code()); + $users = GradebookUtils::get_users_in_course($this->evaluation_object->get_course_code()); $nr_users = 0; //extra field for check on maxvalue $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max()); @@ -284,7 +281,7 @@ class EvalForm extends FormValidator } $firstUser = true; - foreach ($tblusers as $user) { + foreach ($users as $user) { $element_name = 'score['.$user[0].']'; $scoreColumnProperties = ['maxlength' => 5]; if ($firstUser) { diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index ebeb590659..5ca6d992ca 100755 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -1073,18 +1073,18 @@ class GradebookTable extends SortableTable $url = $item->get_link(); + $text = $item->get_name(); if (isset($url) && $show_message === false) { $text = ' ' .$item->get_name() .''; - } else { - $text = $item->get_name(); } $extra = Display::label($item->get_type_name(), 'info'); if ($type == 'simple') { $extra = ''; } + $extra .= $item->getSkillsFromItem(); $text .= " ".$extra.$show_message; $cc = $this->currentcat->get_course_code(); diff --git a/main/gradebook/skill_rel_user.php b/main/gradebook/skill_rel_user.php index 7e8aa4bc4f..923cf1c64b 100644 --- a/main/gradebook/skill_rel_user.php +++ b/main/gradebook/skill_rel_user.php @@ -1,9 +1,9 @@ getSkill()->getId(); $uniqueSkills[$skillId] = $skill->getSkill(); $itemInfo = Skill::getItemInfo($skill->getItemId(), $skill->getItemType()); - $itemInfo['status'] = in_array($skillId, $userSkillsList); - $itemInfo['status'] = false; + $criteria = [ + 'user' => $userId, + 'skillRelItem' => $skill + ]; + $skillRelItemRelUser = $em->getRepository('ChamiloSkillBundle:SkillRelItemRelUser')->findOneBy($criteria); + $itemInfo['status'] = $skillRelItemRelUser ? true : false; + $itemsPerSkill[$skillId][]['info'] = $itemInfo; } @@ -57,6 +65,15 @@ foreach ($itemsPerSkill as $skillId => $skillList) { $uniqueSkillsConclusion[$skillId] = $allSkillsCompleted; } +$interbreadcrumb[] = [ + 'url' => Category::getUrl(), + 'name' => get_lang('Gradebook') +]; +$interbreadcrumb[] = [ + 'url' => api_get_path(WEB_CODE_PATH).'gradebook/gradebook_display_summary.php?'.api_get_cidreq().'&selectcat='.$categoryId, + 'name' => get_lang('GradebookListOfStudentsReports') +]; + $template = new Template(get_lang('SkillUserList')); $template->assign('conclusion_list', $uniqueSkillsConclusion); $template->assign('skills', $uniqueSkills); diff --git a/main/inc/ajax/skill.ajax.php b/main/inc/ajax/skill.ajax.php index f99cdc1fc4..32d6821ff4 100755 --- a/main/inc/ajax/skill.ajax.php +++ b/main/inc/ajax/skill.ajax.php @@ -53,13 +53,11 @@ switch ($action) { //Only course gradebook with certificate if (!empty($gradebooks)) { foreach ($gradebooks as $gradebook) { - if ($gradebook['parent_id'] == 0 && !empty($gradebook['certif_min_score']) && !empty($gradebook['document_id'])) { + if ($gradebook['parent_id'] == 0 && + !empty($gradebook['certif_min_score']) && + !empty($gradebook['document_id']) + ) { $gradebook_list[] = $gradebook; - //$gradebook['name'] = $gradebook['name']; - //$gradebook_list[] = $gradebook; - } else { - // $gradebook['name'] = $gradebook_list[$gradebook['parent_id']]['name'].' > '.$gradebook['name']; - //$gradebook_list[] = $gradebook; } } } @@ -134,7 +132,6 @@ switch ($action) { $template = Display::$global_template->get_template('skill/skill_info.tpl'); $html = Display::$global_template->fetch($template); } - echo $html; break; case 'get_skills_tree_json': @@ -174,7 +171,6 @@ switch ($action) { $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null; $load_user_data = isset($_REQUEST['load_user_data']) ? $_REQUEST['load_user_data'] : null; $skills = $skill->getChildren($id, $load_user_data); - $return = []; foreach ($skills as $skill) { if (isset($skill['data']) && !empty($skill['data'])) { @@ -268,10 +264,8 @@ switch ($action) { Display::$global_template->assign('total_search_skills', $count_skills); $skill_list = []; - if (!empty($total_skills_to_search)) { $total_skills_to_search = $skill->getSkillsInfo($total_skills_to_search); - foreach ($total_skills_to_search as $skill_info) { $skill_list[$skill_info['id']] = $skill_info; } @@ -368,6 +362,68 @@ switch ($action) { 'items' => $returnSkills ]); break; + case 'update_skill_rel_user': + $allowSkillInTools = api_get_configuration_value('allow_skill_rel_items'); + if (empty($allowSkillInTools)) { + exit; + } + + if (!api_is_allowed_to_edit()) { + exit; + } + + $creatorId = api_get_user_id(); + $typeId = isset($_REQUEST['type_id']) ? (int) $_REQUEST['type_id'] : 0; + $itemId = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : 0; + $skillId = isset($_REQUEST['skill_id']) ? (int) $_REQUEST['skill_id'] : 0; + $userId = isset($_REQUEST['user_id']) ? (int) $_REQUEST['user_id'] : 0; + $courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0; + $sessionId = isset($_REQUEST['session_id']) ? (int) $_REQUEST['session_id'] : 0; + + if (!empty($typeId) && !empty($itemId) && !empty($skillId) && !empty($userId) && !empty($courseId)) { + $em = Database::getManager(); + $user = api_get_user_entity($userId); + $skill = $em->getRepository('ChamiloCoreBundle:Skill')->find($skillId); + if (empty($user) || empty($skill)) { + exit; + } + $course = api_get_course_entity($courseId); + if (empty($course)) { + exit; + } + + $session = $em->getRepository('ChamiloCoreBundle:Session')->find($sessionId); + + /** @var \Chamilo\SkillBundle\Entity\SkillRelItem $skillRelItem */ + $skillRelItem = $em->getRepository('ChamiloSkillBundle:SkillRelItem')->findOneBy( + ['itemId' => $itemId, 'itemType' => $typeId, 'skill' => $skillId] + ); + + if ($skillRelItem) { + $criteria = [ + 'user' => $userId, + 'skillRelItem' => $skillRelItem + ]; + $skillRelItemRelUser = $em->getRepository('ChamiloSkillBundle:SkillRelItemRelUser')->findOneBy($criteria); + if ($skillRelItemRelUser) { + $em->remove($skillRelItemRelUser); + $em->flush(); + $skillRelItemRelUser = null; + } else { + $skillRelItemRelUser = new Chamilo\SkillBundle\Entity\SkillRelItemRelUser(); + $skillRelItemRelUser + ->setUser($user) + ->setSkillRelItem($skillRelItem) + ->setCreatedBy($creatorId) + ->setUpdatedBy($creatorId) + ; + $em->persist($skillRelItemRelUser); + $em->flush(); + } + } + echo Skill::getUserSkillStatusLabel($skillRelItem, $skillRelItemRelUser, false); + } + break; default: echo ''; } diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 5974f1343e..b7df8b4816 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -498,6 +498,18 @@ define('EX_Q_SELECTION_CATEGORIES_RANDOM_QUESTIONS_RANDOM_NO_GROUPED', 8); define('EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_ORDERED', 9); define('EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_RANDOM', 10); +// Used to save the skill_rel_item table +define('ITEM_TYPE_EXERCISE', 1); +define('ITEM_TYPE_HOTPOTATOES', 2); +define('ITEM_TYPE_LINK', 3); +define('ITEM_TYPE_LEARNPATH', 4); +define('ITEM_TYPE_GRADEBOOK', 5); +define('ITEM_TYPE_STUDENT_PUBLICATION', 6); +//define('ITEM_TYPE_FORUM', 7); +define('ITEM_TYPE_ATTENDANCE', 8); +define('ITEM_TYPE_SURVEY', 9); +define('ITEM_TYPE_FORUM_THREAD', 10); + // one big string with all question types, for the validator in pear/HTML/QuickForm/Rule/QuestionType define( 'QUESTION_TYPES', @@ -1936,6 +1948,18 @@ function api_get_course_info($course_code = null, $strict = false) return $_course; } +/** + * @param int $courseId + * @return \Chamilo\CoreBundle\Entity\Course + */ +function api_get_course_entity($courseId) +{ + if (empty($courseId)) { + $courseId = api_get_course_int_id(); + } + return Database::getManager()->getRepository('ChamiloCoreBundle:Course')->find($courseId); +} + /** * Returns the current course info array. @@ -6613,6 +6637,8 @@ function api_get_asset($file) /** * Returns the + '; + $form->addHtml($html); + $form->addLabel(get_lang('Skills'), $skills); + } + + } + } + + /** + * Add skills select ajax for an item (exercise, lp) + * @param FormValidator $form + * @param int $typeId see ITEM_TYPE_* constants + * @param int $itemId + * @throws Exception + * @return array + */ + public static function addSkillsToForm(FormValidator $form, $typeId, $itemId = 0) + { + $allowSkillInTools = api_get_configuration_value('allow_skill_rel_items'); + if (!$allowSkillInTools) { + return []; + } + + $skillList = []; + if (!empty($itemId)) { + $em = Database::getManager(); + $items = $em->getRepository('ChamiloSkillBundle:SkillRelItem')->findBy( + ['itemId' => $itemId, 'itemType' => $typeId] + ); + /** @var SkillRelItem $skillRelItem */ + foreach ($items as $skillRelItem) { + $skillList[$skillRelItem->getSkill()->getId()] = $skillRelItem->getSkill()->getName(); + } + } + + $form->addSelectAjax( + 'skills', + get_lang('Skills'), + $skillList, + [ + 'url' => api_get_path(WEB_AJAX_PATH).'skill.ajax.php?a=search_skills', + 'multiple' => 'multiple', + ] + ); + + return $skillList; + } + + /** + * @param int $courseId + * @param int $sessionId + * @return array + */ + public static function getSkillRelItemsPerCourse($courseId, $sessionId = null) + { + $allowSkillInTools = api_get_configuration_value('allow_skill_rel_items'); + $skills = []; + + if (empty($sessionId)) { + $sessionId = null; + } + + if ($allowSkillInTools) { + $em = Database::getManager(); + $skills = $em->getRepository('ChamiloSkillBundle:SkillRelItem')->findBy( + ['courseId' => $courseId, 'sessionId' => $sessionId] + ); + } + + return $skills; + } + + /** + * @param int $itemId + * @param int $itemType + * @return array + */ + public static function getItemInfo($itemId, $itemType) + { + $itemInfo = []; + $itemId = (int) $itemId; + $itemType = (int) $itemType; + $em = Database::getManager(); + + switch ($itemType) { + case ITEM_TYPE_EXERCISE: + /** @var \Chamilo\CourseBundle\Entity\CQuiz $item */ + $item = $em->getRepository('ChamiloCourseBundle:CQuiz')->find($itemId); + if ($item) { + $itemInfo['name'] = $item->getTitle(); + } + break; + case ITEM_TYPE_HOTPOTATOES: + break; + case ITEM_TYPE_LINK: + /** @var \Chamilo\CourseBundle\Entity\CLink $item */ + $item = $em->getRepository('ChamiloCourseBundle:CLink')->find($itemId); + if ($item) { + $itemInfo['name'] = $item->getTitle(); + } + break; + case ITEM_TYPE_LEARNPATH: + /** @var \Chamilo\CourseBundle\Entity\CLp $item */ + $item = $em->getRepository('ChamiloCourseBundle:CLp')->find($itemId); + if ($item) { + $itemInfo['name'] = $item->getName(); + } + break; + case ITEM_TYPE_GRADEBOOK: + break; + case ITEM_TYPE_STUDENT_PUBLICATION: + /** @var \Chamilo\CourseBundle\Entity\CStudentPublication $item */ + $item = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->find($itemId); + if ($item) { + $itemInfo['name'] = $item->getTitle(); + } + break; + //ITEM_TYPE_FORUM', 7); + case ITEM_TYPE_ATTENDANCE: + /** @var \Chamilo\CourseBundle\Entity\CAttendance $item */ + $item = $em->getRepository('ChamiloCourseBundle:CAttendance')->find($itemId); + if ($item) { + $itemInfo['name'] = $item->getName(); + } + break; + case ITEM_TYPE_SURVEY: + /** @var \Chamilo\CourseBundle\Entity\CSurvey $item */ + $item = $em->getRepository('ChamiloCourseBundle:CSurvey')->find($itemId); + if ($item) { + $itemInfo['name'] = strip_tags($item->getTitle()); + } + break; + case ITEM_TYPE_FORUM_THREAD: + /** @var \Chamilo\CourseBundle\Entity\CForumThread $item */ + $item = $em->getRepository('ChamiloCourseBundle:CForumThread')->find($itemId); + if ($item) { + $itemInfo['name'] = $item->getThreadTitle(); + } + break; + } + + return $itemInfo; + } + + + /** + * @param int $typeId + * @param int $itemId + * @return array + */ + public static function getSkillRelItems($typeId, $itemId) + { + $allowSkillInTools = api_get_configuration_value('allow_skill_rel_items'); + $skills = []; + if ($allowSkillInTools) { + $em = Database::getManager(); + $skills = $em->getRepository('ChamiloSkillBundle:SkillRelItem')->findBy( + ['itemId' => $itemId, 'itemType' => $typeId] + ); + } + + return $skills; + } + + /** + * @param int $typeId + * @param int $itemId + * + * @return string + */ + public static function getSkillRelItemsToString($typeId, $itemId) + { + $skills = self::getSkillRelItems($typeId, $itemId); + $skillToString = ''; + if (!empty($skills)) { + /** @var SkillRelItem $skillRelItem */ + $skillList = []; + foreach ($skills as $skillRelItem) { + $skillList[] = Display::label($skillRelItem->getSkill()->getName(), 'success'); + } + $skillToString = ' '.implode(' ', $skillList); + } + + return $skillToString; + } + + /** + * @param int $itemId + * @param int $typeId + */ + public static function deleteSkillsFromItem($itemId, $typeId) + { + $allowSkillInTools = api_get_configuration_value('allow_skill_rel_items'); + if ($allowSkillInTools) { + $itemId = (int) $itemId; + $typeId = (int) $typeId; + + $em = Database::getManager(); + // Delete old ones + $items = $em->getRepository('ChamiloSkillBundle:SkillRelItem')->findBy( + ['itemId' => $itemId, 'itemType' => $typeId] + ); + + /** @var SkillRelItem $skillRelItem */ + foreach ($items as $skillRelItem) { + $em->remove($skillRelItem); + } + $em->flush(); + } + } + + /** + * Relate skill with an item (exercise, gradebook, lp, etc) + * @param FormValidator $form + * @param int $typeId + * @param int $itemId + * @throws \Doctrine\ORM\OptimisticLockException + */ + public static function saveSkills($form, $typeId, $itemId) + { + $allowSkillInTools = api_get_configuration_value('allow_skill_rel_items'); + if ($allowSkillInTools) { + $userId = api_get_user_id(); + $courseId = api_get_course_int_id(); + if (empty($courseId)) { + $courseId = null; + } + $sessionId = api_get_session_id(); + if (empty($sessionId)) { + $sessionId = null; + } + + $em = Database::getManager(); + $skills = (array) $form->getSubmitValue('skills'); + + // Delete old ones + $items = $em->getRepository('ChamiloSkillBundle:SkillRelItem')->findBy( + ['itemId' => $itemId, 'itemType' => $typeId] + ); + if (!empty($items)) { + /** @var SkillRelItem $skillRelItem */ + foreach ($items as $skillRelItem) { + if (!in_array($skillRelItem->getSkill()->getId(), $skills)) { + $em->remove($skillRelItem); + } + } + $em->flush(); + } + + // Add new one + if (!empty($skills)) { + foreach ($skills as $skillId) { + /** @var \Chamilo\CoreBundle\Entity\Skill $skill */ + $skill = $em->getRepository('ChamiloCoreBundle:Skill')->find($skillId); + if ($skill) { + if (!$skill->hasItem($typeId, $itemId)) { + $skillRelItem = new SkillRelItem(); + $skillRelItem + ->setItemType($typeId) + ->setItemId($itemId) + ->setCourseId($courseId) + ->setSessionId($sessionId) + ->setCreatedBy($userId) + ->setUpdatedBy($userId) + ; + $skill->addItem($skillRelItem); + $em->persist($skill); + $em->flush(); + } + } + } + } + } + } } diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 33feecd71c..0d7b399b47 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -733,6 +733,10 @@ $_configuration['gradebook_badge_sidebar'] = [ //$_configuration['allow_teachers_to_access_blocked_lp_by_prerequisite'] = false; // Allow connect skills with course tools +// Uncomment doctrine tags for Entities: +//SkillRelItemRelUser|SkillRelItem|SkillRelUser.validation_status|Skill.items +// DB changes: + //$_configuration['allow_skill_rel_items'] = false; // Generate random login when importing users diff --git a/main/link/link.php b/main/link/link.php index 9a7fc91242..1596cc36d5 100755 --- a/main/link/link.php +++ b/main/link/link.php @@ -107,7 +107,9 @@ switch ($action) { $form = Link::getLinkForm(null, 'addlink', $token); if ($form->validate() && Security::check_token('get')) { // Here we add a link - Link::addlinkcategory("link"); + $linkId = Link::addlinkcategory('link'); + Skill::saveSkills($form, ITEM_TYPE_LINK, $linkId); + Security::clear_token(); header('Location: '.$linkListUrl); exit; @@ -119,6 +121,7 @@ switch ($action) { $form = Link::getLinkForm($id, 'editlink'); if ($form->validate()) { Link::editLink($id, $form->getSubmitValues()); + Skill::saveSkills($form, ITEM_TYPE_LINK, $id); header('Location: '.$linkListUrl); exit; } diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 6817c5781e..9672128bb8 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -3439,7 +3439,6 @@ class learnpath public function get_link($type = 'http', $item_id = null, $provided_toc = false) { $course_id = $this->get_course_int_id(); - if ($this->debug > 0) { error_log('New LP - In learnpath::get_link('.$type.','.$item_id.')', 0); } @@ -3456,7 +3455,7 @@ class learnpath } //still empty, this means there was no item_id given and we are not in an object context or //the object property is empty, return empty link - $item_id = $this->first(); + $this->first(); return ''; } @@ -12322,6 +12321,7 @@ EOD; $main_course_path = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/'; $link = ''; $extraParams = api_get_cidreq(true, true, 'learnpath').'&session_id='.$session_id; + switch ($type) { case 'dir': return $main_dir_path.'lp/blank.php'; diff --git a/main/lp/lp_add.php b/main/lp/lp_add.php index 5b71506613..ccd23280f1 100755 --- a/main/lp/lp_add.php +++ b/main/lp/lp_add.php @@ -151,6 +151,8 @@ $form->addElement('html', ''); +Skill::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, 0); + $form->addElement('html', ''); $defaults['activate_start_date_check'] = 1; diff --git a/main/lp/lp_content.php b/main/lp/lp_content.php index 7c5b889be7..fcfa032b2e 100755 --- a/main/lp/lp_content.php +++ b/main/lp/lp_content.php @@ -40,6 +40,7 @@ foreach ($list as $toc) { $dir = true; } } + if ($dir) { $src = 'blank.php'; } else { diff --git a/main/lp/lp_controller.php b/main/lp/lp_controller.php index 5d481ba6b9..890f93b4cd 100755 --- a/main/lp/lp_controller.php +++ b/main/lp/lp_controller.php @@ -283,21 +283,21 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $ $lp_table = Database::get_course_table(TABLE_LP_MAIN); if (is_numeric($lp_id)) { - $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id"; + $sel = "SELECT iid, lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id"; if ($debug > 0) { error_log('New LP - querying '.$sel, 0); } $res = Database::query($sel); - if (Database::num_rows($res)) { $row = Database::fetch_array($res); + $lpIid = $row['iid']; $type = $row['lp_type']; if ($debug > 0) { error_log('New LP - found row - type '.$type.' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); } switch ($type) { case 1: - $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id()); + $oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id()); if ($oLP !== false) { $lp_found = true; } else { @@ -305,7 +305,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $ } break; case 2: - $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id()); + $oLP = new scorm(api_get_course_id(), $lpIid, api_get_user_id()); if ($oLP !== false) { $lp_found = true; } else { @@ -313,7 +313,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $ } break; case 3: - $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id()); + $oLP = new aicc(api_get_course_id(), $lpIid, api_get_user_id()); if ($oLP !== false) { $lp_found = true; } else { @@ -321,7 +321,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $ } break; default: - $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id()); + $oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id()); if ($oLP !== false) { $lp_found = true; } else { @@ -605,6 +605,11 @@ switch ($action) { ); if (is_numeric($new_lp_id)) { + // Create temp form validator to save skills + $form = new FormValidator('lp_add'); + $form->addSelect('skills', 'skills'); + Skill::saveSkills($form, ITEM_TYPE_LEARNPATH, $new_lp_id); + // TODO: Maybe create a first directory directly to avoid bugging the user with useless queries $_SESSION['oLP'] = new learnpath( api_get_course_id(), @@ -863,6 +868,9 @@ switch ($action) { } else { Session::write('refresh', 1); $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove'); + + Skill::deleteSkillsFromItem($_GET['lp_id'], ITEM_TYPE_LEARNPATH); + Display::addFlash(Display::return_message(get_lang('Deleted'))); Session::erase('oLP'); require 'lp_list.php'; @@ -1028,6 +1036,10 @@ switch ($action) { $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']); } + $form = new FormValidator('form1'); + $form->addSelect('skills', 'skills'); + Skill::saveSkills($form, ITEM_TYPE_LEARNPATH, $_SESSION['oLP']->get_id()); + if (api_get_setting('search_enabled') === 'true') { require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; $specific_fields = get_specific_field_list(); diff --git a/main/lp/lp_edit.php b/main/lp/lp_edit.php index b19f69c3a9..54a9ec8011 100755 --- a/main/lp/lp_edit.php +++ b/main/lp/lp_edit.php @@ -10,11 +10,12 @@ require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; api_protect_course_script(); -$show_description_field = false; //for now $nameTools = get_lang('Doc'); $this_section = SECTION_COURSES; Event::event_access_tool(TOOL_LEARNPATH); +$lpId = $_SESSION['oLP']->get_id(); + if (api_is_in_gradebook()) { $interbreadcrumb[] = [ 'url' => Category::getUrl(), @@ -26,7 +27,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('LearningPaths') ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=".$_SESSION['oLP']->get_id().'&'.api_get_cidreq(), + 'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(), 'name' => $_SESSION['oLP']->get_name() ]; @@ -214,15 +215,17 @@ $form->addElement( $enableLpExtraFields = false; if ($enableLpExtraFields) { $extraField = new ExtraField('lp'); - $extra = $extraField->addElements($form, $_SESSION['oLP']->get_id()); + $extra = $extraField->addElements($form, $lpId); } +$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, $lpId); + // Submit button $form->addButtonSave(get_lang('SaveLPSettings')); // Hidden fields $form->addElement('hidden', 'action', 'update_lp'); -$form->addElement('hidden', 'lp_id', $_SESSION['oLP']->get_id()); +$form->addElement('hidden', 'lp_id', $lpId); if ($enableLpExtraFields) { $htmlHeadXtra[] = ''; $form->addHtml(''); + + + $skillList = Skill::addSkillsToForm($form, ITEM_TYPE_STUDENT_PUBLICATION, $workId); + if (!empty($defaults)) { + $defaults['skills'] = array_keys($skillList); $form->setDefaults($defaults); } diff --git a/main/work/work.php b/main/work/work.php index 4c9ea8a035..60222a91f1 100755 --- a/main/work/work.php +++ b/main/work/work.php @@ -197,6 +197,8 @@ switch ($action) { ); if ($result) { + Skill::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $result); + $message = Display::return_message(get_lang('DirectoryCreated'), 'success'); } else { $currentUrl = $addUrl; diff --git a/src/Chamilo/CoreBundle/Entity/Skill.php b/src/Chamilo/CoreBundle/Entity/Skill.php index 9c34a0124d..29db91d816 100644 --- a/src/Chamilo/CoreBundle/Entity/Skill.php +++ b/src/Chamilo/CoreBundle/Entity/Skill.php @@ -5,7 +5,9 @@ namespace Chamilo\CoreBundle\Entity; use Chamilo\CoreBundle\Component\Utils\ChamiloApi; use Chamilo\SkillBundle\Entity\Profile; +use Chamilo\SkillBundle\Entity\SkillRelItem; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; /** @@ -95,6 +97,12 @@ class Skill */ protected $issuedSkills; + /** + * // uncomment if api_get_configuration_value('allow_skill_rel_items') + * ORM\OneToMany(targetEntity="Chamilo\SkillBundle\Entity\SkillRelItem", mappedBy="skill", cascade={"persist"}) + */ + protected $items; + /** * @return string */ @@ -358,4 +366,53 @@ class Skill { return $this->issuedSkills; } + + /** + * @return ArrayCollection + */ + public function getItems() + { + return $this->items; + } + + /** + * @param ArrayCollection $items + * @return Skill + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * @param int $itemId + * @return bool + */ + public function hasItem($typeId, $itemId) + { + if ($this->getItems()->count()) { + $found = false; + /** @var SkillRelItem $item */ + foreach ($this->getItems() as $item) { + if ($item->getItemId() == $itemId && $item->getItemType() == $typeId) { + $found = true; + break; + } + } + + return $found; + } + + return false; + } + + /** + * @param SkillRelItem $skillRelItem + */ + public function addItem(SkillRelItem $skillRelItem) + { + $skillRelItem->setSkill($this); + $this->items[] = $skillRelItem; + } } diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelUser.php b/src/Chamilo/CoreBundle/Entity/SkillRelUser.php index 5725e34dd0..9b6e8addb7 100644 --- a/src/Chamilo/CoreBundle/Entity/SkillRelUser.php +++ b/src/Chamilo/CoreBundle/Entity/SkillRelUser.php @@ -38,6 +38,7 @@ class SkillRelUser * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) */ private $user; + /** * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Skill", inversedBy="issuedSkills", cascade={"persist"}) * @ORM\JoinColumn(name="skill_id", referencedColumnName="id", nullable=false) @@ -99,6 +100,16 @@ class SkillRelUser */ protected $comments; + /** + * Whether this has been confirmed by a teacher or not + * Only set to 0 when the skill_rel_item says requires_validation = 1 + * @var integer + * + * // uncomment if api_get_configuration_value('allow_skill_rel_items') + * ORM\Column(name="validation_status", type="integer") + */ + protected $validationStatus; + /** * SkillRelUser constructor. */ @@ -409,4 +420,22 @@ class SkillRelUser return number_format($average, 2); } + + /** + * @return int + */ + public function getValidationStatus() + { + return $this->validationStatus; + } + + /** + * @param int $validationStatus + * @return SkillRelUser + */ + public function setValidationStatus($validationStatus) + { + $this->validationStatus = $validationStatus; + return $this; + } } diff --git a/src/Chamilo/SkillBundle/Entity/SkillRelItem.php b/src/Chamilo/SkillBundle/Entity/SkillRelItem.php new file mode 100644 index 0000000000..65e494860e --- /dev/null +++ b/src/Chamilo/SkillBundle/Entity/SkillRelItem.php @@ -0,0 +1,363 @@ +createdAt = new \DateTime('now'); + $this->updatedAt = new \DateTime('now'); + $this->isReal = false; + $this->requiresValidation = false; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + * @return SkillRelItem + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return Skill + */ + public function getSkill() + { + return $this->skill; + } + + /** + * @param mixed $skill + * @return SkillRelItem + */ + public function setSkill($skill) + { + $this->skill = $skill; + return $this; + } + + /** + * @return int + */ + public function getItemId() + { + return $this->itemId; + } + + /** + * @param int $itemId + * @return SkillRelItem + */ + public function setItemId($itemId) + { + $this->itemId = $itemId; + return $this; + } + + /** + * @return string + */ + public function getObtainConditions() + { + return $this->obtainConditions; + } + + /** + * @param string $obtainConditions + * @return SkillRelItem + */ + public function setObtainConditions($obtainConditions) + { + $this->obtainConditions = $obtainConditions; + return $this; + } + + /** + * @return bool + */ + public function isRequiresValidation() + { + return $this->requiresValidation; + } + + /** + * @param bool $requiresValidation + * @return SkillRelItem + */ + public function setRequiresValidation($requiresValidation) + { + $this->requiresValidation = $requiresValidation; + return $this; + } + + /** + * @return bool + */ + public function isReal() + { + return $this->isReal; + } + + /** + * @param bool $isReal + * @return SkillRelItem + */ + public function setIsReal($isReal) + { + $this->isReal = $isReal; + return $this; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + * @return SkillRelItem + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + return $this; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + * @return SkillRelItem + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + return $this; + } + + /** + * @return int + */ + public function getCreatedBy() + { + return $this->createdBy; + } + + /** + * @param int $createdBy + * @return SkillRelItem + */ + public function setCreatedBy($createdBy) + { + $this->createdBy = $createdBy; + return $this; + } + + /** + * @return int + */ + public function getUpdatedBy() + { + return $this->updatedBy; + } + + /** + * @param int $updatedBy + * @return SkillRelItem + */ + public function setUpdatedBy($updatedBy) + { + $this->updatedBy = $updatedBy; + return $this; + } + + /** + * @return int + */ + public function getItemType() + { + return $this->itemType; + } + + /** + * @param int $itemType + * @return SkillRelItem + */ + public function setItemType($itemType) + { + $this->itemType = $itemType; + return $this; + } + + /** + * @return int + */ + public function getCourseId() + { + return $this->courseId; + } + + /** + * @param int $courseId + * @return SkillRelItem + */ + public function setCourseId($courseId) + { + $this->courseId = $courseId; + return $this; + } + + /** + * @return int + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * @param int $sessionId + * @return SkillRelItem + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + return $this; + } +} diff --git a/src/Chamilo/SkillBundle/Entity/SkillRelItemRelUser.php b/src/Chamilo/SkillBundle/Entity/SkillRelItemRelUser.php new file mode 100644 index 0000000000..2e0814f551 --- /dev/null +++ b/src/Chamilo/SkillBundle/Entity/SkillRelItemRelUser.php @@ -0,0 +1,169 @@ +createdAt = new \DateTime('now'); + $this->updatedAt = new \DateTime('now'); + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + * @return SkillRelItemRelUser + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return SkillRelItem + */ + public function getSkillRelItem() + { + return $this->skillRelItem; + } + + /** + * @param SkillRelItem $skillRelItem + * @return SkillRelItemRelUser + */ + public function setSkillRelItem($skillRelItem) + { + $this->skillRelItem = $skillRelItem; + return $this; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @param User $user + * @return SkillRelItemRelUser + */ + public function setUser($user) + { + $this->user = $user; + return $this; + } + + /** + * @return int + */ + public function getCreatedBy() + { + return $this->createdBy; + } + + /** + * @param int $createdBy + * @return SkillRelItemRelUser + */ + public function setCreatedBy($createdBy) + { + $this->createdBy = $createdBy; + return $this; + } + + /** + * @return int + */ + public function getUpdatedBy() + { + return $this->updatedBy; + } + + /** + * @param int $updatedBy + * @return SkillRelItemRelUser + */ + public function setUpdatedBy($updatedBy) + { + $this->updatedBy = $updatedBy; + return $this; + } +}