Add student_follow_page_add_LP_acquisition_info conf setting - refs BT#18671
Add column "Acquisition" in student LPs table to display info about a lo adquisition. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(0, 3, 'acquisition', 'Acquisition', '', 0, 1, 0, 0, 0, NOW());
SET @ef_id = LAST_INSERT_ID();
INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES
(@ef_id, '1', 'Acquired', NULL, NULL, 1),
(@ef_id, '2', 'In the process of acquisition', NULL, NULL, 2),
(@ef_id, '3', 'Not acquired', NULL, NULL, 3);
5 years ago
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
|
|
|
|
|
|
use Chamilo\CourseBundle\Entity\CLp;
|
|
|
|
|
use Chamilo\CourseBundle\Entity\CLpView;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
|
|
|
|
|
|
|
|
|
require_once __DIR__.'/../global.inc.php';
|
|
|
|
|
|
|
|
|
|
$httpRequest = HttpRequest::createFromGlobals();
|
|
|
|
|
|
|
|
|
|
$isAllowedToEdit = api_is_allowed_to_edit();
|
|
|
|
|
|
|
|
|
|
switch ($httpRequest->get('a')) {
|
|
|
|
|
case 'form_adquisition':
|
|
|
|
|
displayForm(
|
|
|
|
|
$httpRequest->query->getInt('lp_view')
|
|
|
|
|
);
|
|
|
|
|
break;
|
Add student_follow_page_add_LP_invisible_checkbox conf setting - refs BT#18671
Prepend a column in student LPs table to display a checkbox to select the LP category and its LPs. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(20, 13, 'invisible', 'Invisible', '', 0, 1, 0, 0, 0, NOW());
5 years ago
|
|
|
case 'views_invisible':
|
|
|
|
|
processViewsInvisible(
|
|
|
|
|
$httpRequest->request->get('chkb_view') ?: [],
|
|
|
|
|
$httpRequest->request->getBoolean('state')
|
|
|
|
|
);
|
|
|
|
|
break;
|
Add student_follow_page_add_LP_acquisition_info conf setting - refs BT#18671
Add column "Acquisition" in student LPs table to display info about a lo adquisition. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(0, 3, 'acquisition', 'Acquisition', '', 0, 1, 0, 0, 0, NOW());
SET @ef_id = LAST_INSERT_ID();
INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES
(@ef_id, '1', 'Acquired', NULL, NULL, 1),
(@ef_id, '2', 'In the process of acquisition', NULL, NULL, 2),
(@ef_id, '3', 'Not acquired', NULL, NULL, 3);
5 years ago
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function displayForm(int $lpViewId)
|
|
|
|
|
{
|
|
|
|
|
$em = Database::getManager();
|
|
|
|
|
|
|
|
|
|
$lpView = $em->find(CLpView::class, $lpViewId);
|
|
|
|
|
|
|
|
|
|
if (null === $lpView) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lp = $em->find(CLp::class, $lpView->getLpId());
|
|
|
|
|
|
|
|
|
|
$extraField = new ExtraField('lp_view');
|
|
|
|
|
$field = $extraField->get_handler_field_info_by_field_variable(StudentFollowPage::VARIABLE_ACQUISITION);
|
|
|
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('lp_view');
|
|
|
|
|
$value = $extraFieldValue->get_values_by_handler_and_field_variable(
|
|
|
|
|
$lpViewId,
|
|
|
|
|
StudentFollowPage::VARIABLE_ACQUISITION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$options = [];
|
|
|
|
|
|
|
|
|
|
foreach ($field['options'] as $option) {
|
|
|
|
|
$options[$option['option_value']] = ExtraFieldOption::translateDisplayName($option['display_text']);
|
Add student_follow_page_add_LP_acquisition_info conf setting - refs BT#18671
Add column "Acquisition" in student LPs table to display info about a lo adquisition. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(0, 3, 'acquisition', 'Acquisition', '', 0, 1, 0, 0, 0, NOW());
SET @ef_id = LAST_INSERT_ID();
INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES
(@ef_id, '1', 'Acquired', NULL, NULL, 1),
(@ef_id, '2', 'In the process of acquisition', NULL, NULL, 2),
(@ef_id, '3', 'Not acquired', NULL, NULL, 3);
5 years ago
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$frmId = 'frm_lp_acquisition_'.$lpView->getLpId();
|
|
|
|
|
$frmAction = api_get_self().'?'.http_build_query(['lp_view' => $lpViewId, 'a' => 'form_adquisition']);
|
|
|
|
|
|
|
|
|
|
$form = new FormValidator($frmId, 'post', $frmAction);
|
|
|
|
|
$form->addRadio(StudentFollowPage::VARIABLE_ACQUISITION, get_lang('Acquisition'), $options);
|
|
|
|
|
$form->addHidden('lp_view', $lpViewId);
|
|
|
|
|
$form->addButtonSave(get_lang('Save'));
|
|
|
|
|
|
|
|
|
|
if ($form->validate()) {
|
|
|
|
|
$values = $form->exportValues();
|
|
|
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('lp_view');
|
|
|
|
|
$extraFieldValue->save(
|
|
|
|
|
[
|
|
|
|
|
'variable' => StudentFollowPage::VARIABLE_ACQUISITION,
|
|
|
|
|
'item_id' => $lpViewId,
|
|
|
|
|
'comment' => json_encode(['user' => api_get_user_id(), 'datetime' => api_get_utc_datetime()]),
|
|
|
|
|
'value' => $values[StudentFollowPage::VARIABLE_ACQUISITION],
|
Add student_follow_page_add_LP_acquisition_info conf setting - refs BT#18671
Add column "Acquisition" in student LPs table to display info about a lo adquisition. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(0, 3, 'acquisition', 'Acquisition', '', 0, 1, 0, 0, 0, NOW());
SET @ef_id = LAST_INSERT_ID();
INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES
(@ef_id, '1', 'Acquired', NULL, NULL, 1),
(@ef_id, '2', 'In the process of acquisition', NULL, NULL, 2),
(@ef_id, '3', 'Not acquired', NULL, NULL, 3);
5 years ago
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
echo StudentFollowPage::getLpAcquisition(
|
|
|
|
|
[
|
|
|
|
|
'iid' => $lp->getIid(),
|
|
|
|
|
'lp_name' => $lp->getName(),
|
|
|
|
|
],
|
|
|
|
|
$lpView->getUserId(),
|
|
|
|
|
$lpView->getCId(),
|
|
|
|
|
$lpView->getSessionId(),
|
|
|
|
|
true
|
Add student_follow_page_add_LP_acquisition_info conf setting - refs BT#18671
Add column "Acquisition" in student LPs table to display info about a lo adquisition. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(0, 3, 'acquisition', 'Acquisition', '', 0, 1, 0, 0, 0, NOW());
SET @ef_id = LAST_INSERT_ID();
INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES
(@ef_id, '1', 'Acquired', NULL, NULL, 1),
(@ef_id, '2', 'In the process of acquisition', NULL, NULL, 2),
(@ef_id, '3', 'Not acquired', NULL, NULL, 3);
5 years ago
|
|
|
);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($value)) {
|
|
|
|
|
$form->setDefaults([StudentFollowPage::VARIABLE_ACQUISITION => $value['value']]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo $form->returnForm()
|
|
|
|
|
."<script>$(function () {
|
|
|
|
|
$('#$frmId').on('submit', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
var self = $(this);
|
|
|
|
|
|
|
|
|
|
self.find(':submit').prop('disabled', true);
|
|
|
|
|
|
|
|
|
|
$.post(this.action, self.serialize()).done(function (response) {
|
|
|
|
|
$('#acquisition-$lpViewId').html(response);
|
|
|
|
|
|
|
|
|
|
$('#global-modal').modal('hide');
|
|
|
|
|
|
|
|
|
|
self.find(':submit').prop('disabled', false);
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
})</script>";
|
|
|
|
|
}
|
Add student_follow_page_add_LP_invisible_checkbox conf setting - refs BT#18671
Prepend a column in student LPs table to display a checkbox to select the LP category and its LPs. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(20, 13, 'invisible', 'Invisible', '', 0, 1, 0, 0, 0, NOW());
5 years ago
|
|
|
|
|
|
|
|
function processViewsInvisible(array $lpViews, bool $state)
|
Add student_follow_page_add_LP_invisible_checkbox conf setting - refs BT#18671
Prepend a column in student LPs table to display a checkbox to select the LP category and its LPs. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(20, 13, 'invisible', 'Invisible', '', 0, 1, 0, 0, 0, NOW());
5 years ago
|
|
|
{
|
|
|
|
|
foreach ($lpViews as $lpViewData) {
|
|
|
|
|
$parts = explode('_', $lpViewData);
|
|
|
|
|
|
|
|
|
|
[$lpId, $userId, $courseId, $sessionId] = array_map('intval', $parts);
|
|
|
|
|
|
|
|
|
|
$lpView = learnpath::findLastView($lpId, $userId, $courseId, $sessionId);
|
|
|
|
|
|
|
|
|
|
if (empty($lpView)) {
|
|
|
|
|
$tblLpView = Database::get_course_table(TABLE_LP_VIEW);
|
|
|
|
|
|
|
|
|
|
$lpViewId = Database::insert(
|
|
|
|
|
$tblLpView,
|
|
|
|
|
[
|
|
|
|
|
'c_id' => $courseId,
|
|
|
|
|
'lp_id' => $lpId,
|
|
|
|
|
'user_id' => $userId,
|
|
|
|
|
'view_count' => 1,
|
|
|
|
|
'session_id' => $sessionId,
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
Database::update($tblLpView, ['id' => $lpViewId], ['iid = ?' => $lpViewId]);
|
|
|
|
|
} else {
|
|
|
|
|
$lpViewId = $lpView['iid'];
|
|
|
|
|
}
|
Add student_follow_page_add_LP_invisible_checkbox conf setting - refs BT#18671
Prepend a column in student LPs table to display a checkbox to select the LP category and its LPs. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(20, 13, 'invisible', 'Invisible', '', 0, 1, 0, 0, 0, NOW());
5 years ago
|
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('lp_view');
|
|
|
|
|
$extraFieldValue->save(
|
|
|
|
|
[
|
|
|
|
|
'variable' => StudentFollowPage::VARIABLE_INVISIBLE,
|
|
|
|
|
'item_id' => $lpViewId,
|
|
|
|
|
'comment' => json_encode(['user' => api_get_user_id(), 'datetime' => api_get_utc_datetime()]),
|
|
|
|
|
'value' => $state,
|
Add student_follow_page_add_LP_invisible_checkbox conf setting - refs BT#18671
Prepend a column in student LPs table to display a checkbox to select the LP category and its LPs. Requires DB changes:
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(20, 13, 'invisible', 'Invisible', '', 0, 1, 0, 0, 0, NOW());
5 years ago
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|