Actualización
This commit is contained in:
94
main/course_description/add.php
Normal file
94
main/course_description/add.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* View (MVC patter) for adding a course description.
|
||||
*
|
||||
* @author Christian Fasanando <christian1827@gmail.com>
|
||||
*/
|
||||
|
||||
// protect a course script
|
||||
api_protect_course_script(true);
|
||||
|
||||
// display categories
|
||||
$categories = [];
|
||||
foreach ($default_description_titles as $id => $title) {
|
||||
$categories[$id] = $title;
|
||||
}
|
||||
$categories[ADD_BLOCK] = get_lang('NewBloc');
|
||||
|
||||
$i = 1;
|
||||
echo '<div class="actions" style="margin-bottom:30px">';
|
||||
echo '<a href="index.php?'.api_get_cidreq().'">'.
|
||||
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM).
|
||||
'</a>';
|
||||
ksort($categories);
|
||||
foreach ($categories as $id => $title) {
|
||||
if ($i == ADD_BLOCK) {
|
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
|
||||
Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
||||
break;
|
||||
} else {
|
||||
echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
|
||||
Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
// error messages
|
||||
if (isset($error) && intval($error) == 1) {
|
||||
echo Display::return_message(
|
||||
get_lang('FormHasErrorsPleaseComplete'),
|
||||
'error',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// default header title form
|
||||
$header = '';
|
||||
$description_type = intval($description_type);
|
||||
if ($description_type >= ADD_BLOCK) {
|
||||
$header = $default_description_titles[ADD_BLOCK];
|
||||
}
|
||||
|
||||
// display form
|
||||
$form = new FormValidator(
|
||||
'course_description',
|
||||
'POST',
|
||||
'index.php?action=add&'.api_get_cidreq()
|
||||
);
|
||||
$form->addElement('header', $header);
|
||||
$form->addElement('hidden', 'description_type', $description_type);
|
||||
if (api_get_configuration_value('save_titles_as_html')) {
|
||||
$form->addHtmlEditor(
|
||||
'title',
|
||||
get_lang('Title'),
|
||||
true,
|
||||
false,
|
||||
['ToolbarSet' => 'TitleAsHtml']
|
||||
);
|
||||
} else {
|
||||
$form->addText('title', get_lang('Title'));
|
||||
$form->applyFilter('title', 'html_filter');
|
||||
}
|
||||
$form->addHtmlEditor(
|
||||
'contentDescription',
|
||||
get_lang('Content'),
|
||||
true,
|
||||
false,
|
||||
[
|
||||
'ToolbarSet' => 'Basic',
|
||||
'Width' => '100%',
|
||||
'Height' => '200',
|
||||
]
|
||||
);
|
||||
$form->addButtonCreate(get_lang('Save'));
|
||||
|
||||
// display default questions
|
||||
if (isset($question[$description_type])) {
|
||||
$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
|
||||
$message .= $question[$description_type];
|
||||
echo Display::return_message($message, 'normal', false);
|
||||
}
|
||||
$form->display();
|
||||
322
main/course_description/course_description_controller.php
Normal file
322
main/course_description/course_description_controller.php
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Class CourseDescriptionController
|
||||
* This file contains class used like controller,
|
||||
* it should be included inside a dispatcher file (e.g: index.php).
|
||||
*
|
||||
* @author Christian Fasanando <christian1827@gmail.com>
|
||||
*/
|
||||
class CourseDescriptionController
|
||||
{
|
||||
private $toolname;
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->toolname = 'course_description';
|
||||
$this->view = new View($this->toolname);
|
||||
}
|
||||
|
||||
/**
|
||||
* It's used for listing course description,
|
||||
* render to listing view.
|
||||
*
|
||||
* @param bool true for listing history (optional)
|
||||
* @param array message for showing by action['edit','add','destroy'] (optional)
|
||||
*/
|
||||
public function listing($history = false, $messages = [])
|
||||
{
|
||||
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
|
||||
$course_description = new CourseDescription();
|
||||
$session_id = api_get_session_id();
|
||||
$data = [];
|
||||
$course_description->set_session_id($session_id);
|
||||
$course_description_data = $course_description->get_description_data();
|
||||
$data['descriptions'] = isset($course_description_data['descriptions']) ? $course_description_data['descriptions'] : '';
|
||||
$data['default_description_titles'] = $course_description->get_default_description_title();
|
||||
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
|
||||
$data['default_description_icon'] = $course_description->get_default_description_icon();
|
||||
$data['messages'] = $messages;
|
||||
$browser = api_get_navigator();
|
||||
|
||||
api_protect_course_script(true);
|
||||
|
||||
if (!is_array($data['descriptions'])) {
|
||||
$data['descriptions'] = [$data['descriptions']];
|
||||
}
|
||||
|
||||
// Prepare confirmation code for item deletion
|
||||
global $htmlHeadXtra;
|
||||
$htmlHeadXtra[] = "<script>
|
||||
function confirmation(name) {
|
||||
if (confirm(\" ".trim(get_lang('AreYouSureToDeleteJS'))." \"+name+\"?\")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>";
|
||||
|
||||
foreach ($data['descriptions'] as $id => $description) {
|
||||
if (!empty($description['content'])
|
||||
&& strpos($description['content'], '<iframe') !== false
|
||||
&& $browser['name'] == 'Chrome'
|
||||
) {
|
||||
header("X-XSS-Protection: 0");
|
||||
}
|
||||
// Add an escape version for the JS code of delete confirmation
|
||||
if ($description) {
|
||||
$data['descriptions'][$id]['title_js'] = addslashes(strip_tags($description['title']));
|
||||
}
|
||||
}
|
||||
$actions = null;
|
||||
$actionLeft = null;
|
||||
// display actions menu
|
||||
if ($is_allowed_to_edit) {
|
||||
$categories = [];
|
||||
foreach ($data['default_description_titles'] as $id => $title) {
|
||||
$categories[$id] = $title;
|
||||
}
|
||||
$categories[ADD_BLOCK] = get_lang('NewBloc');
|
||||
$i = 1;
|
||||
|
||||
ksort($categories);
|
||||
foreach ($categories as $id => $title) {
|
||||
if ($i == ADD_BLOCK) {
|
||||
$actionLeft .= '<a href="index.php?'.api_get_cidreq().'&action=add">'.
|
||||
Display::return_icon(
|
||||
$data['default_description_icon'][$id],
|
||||
$title,
|
||||
'',
|
||||
ICON_SIZE_MEDIUM
|
||||
).
|
||||
'</a>';
|
||||
break;
|
||||
} else {
|
||||
$actionLeft .= '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
|
||||
Display::return_icon(
|
||||
$data['default_description_icon'][$id],
|
||||
$title,
|
||||
'',
|
||||
ICON_SIZE_MEDIUM
|
||||
).
|
||||
'</a>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$actions = Display::toolbarAction('toolbar', [0 => $actionLeft]);
|
||||
}
|
||||
|
||||
$tpl = new Template(get_lang('CourseProgram'));
|
||||
$tpl->assign('listing', $data);
|
||||
$tpl->assign('is_allowed_to_edit', $is_allowed_to_edit);
|
||||
$tpl->assign('actions', $actions);
|
||||
$tpl->assign('session_id', $session_id);
|
||||
$templateName = $tpl->get_template('course_description/index.tpl');
|
||||
$content = $tpl->fetch($templateName);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
}
|
||||
|
||||
/**
|
||||
* It's used for editing a course description,
|
||||
* render to listing or edit view.
|
||||
*
|
||||
* @param int $id description item id
|
||||
* @param int $description_type description type id
|
||||
*/
|
||||
public function edit($id, $description_type)
|
||||
{
|
||||
$course_description = new CourseDescription();
|
||||
$session_id = api_get_session_id();
|
||||
$course_description->set_session_id($session_id);
|
||||
$data = [];
|
||||
$data['id'] = $id;
|
||||
$affected_rows = null;
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
|
||||
if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
|
||||
if (1) {
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['contentDescription'];
|
||||
$description_type = $_POST['description_type'];
|
||||
$id = $_POST['id'];
|
||||
if (empty($id)) {
|
||||
// If the ID was not provided, find the first matching description item given the item type
|
||||
$description = $course_description->get_data_by_description_type(
|
||||
$description_type
|
||||
);
|
||||
if (count($description) > 0) {
|
||||
$id = $description['id'];
|
||||
}
|
||||
// If no corresponding description is found, edit a new one
|
||||
}
|
||||
$progress = isset($_POST['progress']) ? $_POST['progress'] : '';
|
||||
$course_description->set_description_type($description_type);
|
||||
$course_description->set_title($title);
|
||||
$course_description->set_content($content);
|
||||
$course_description->set_progress($progress);
|
||||
$thematic_advance = $course_description->get_data_by_id($id);
|
||||
|
||||
if (!empty($thematic_advance)) {
|
||||
$course_description->set_id($id);
|
||||
$course_description->update();
|
||||
} else {
|
||||
$course_description->insert();
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
get_lang('CourseDescriptionUpdated')
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->listing(false);
|
||||
} else {
|
||||
$data['error'] = 1;
|
||||
$data['default_description_titles'] = $course_description->get_default_description_title();
|
||||
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
|
||||
$data['default_description_icon'] = $course_description->get_default_description_icon();
|
||||
$data['question'] = $course_description->get_default_question();
|
||||
$data['information'] = $course_description->get_default_information();
|
||||
$data['description_title'] = $_POST['title'];
|
||||
$data['description_content'] = $_POST['contentDescription'];
|
||||
$data['description_type'] = $_POST['description_type'];
|
||||
$data['progress'] = $_POST['progress'];
|
||||
$data['descriptions'] = $course_description->get_data_by_id($_POST['id']);
|
||||
// render to the view
|
||||
$this->view->set_data($data);
|
||||
$this->view->set_layout('layout');
|
||||
$this->view->set_template('edit');
|
||||
$this->view->render();
|
||||
}
|
||||
} else {
|
||||
$data['default_description_titles'] = $course_description->get_default_description_title();
|
||||
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
|
||||
$data['default_description_icon'] = $course_description->get_default_description_icon();
|
||||
$data['question'] = $course_description->get_default_question();
|
||||
$data['information'] = $course_description->get_default_information();
|
||||
|
||||
$data['description_type'] = $description_type;
|
||||
if (empty($id)) {
|
||||
// If the ID was not provided, find the first matching description item given the item type
|
||||
$description = $course_description->get_data_by_description_type($description_type);
|
||||
if (count($description) > 0) {
|
||||
$id = $description['id'];
|
||||
}
|
||||
// If no corresponding description is found, edit a new one
|
||||
}
|
||||
if (!empty($id)) {
|
||||
if (isset($_GET['id_session'])) {
|
||||
$session_id = intval($_GET['id_session']);
|
||||
}
|
||||
$course_description_data = $course_description->get_data_by_id(
|
||||
$id,
|
||||
null,
|
||||
$session_id
|
||||
);
|
||||
$data['description_type'] = $course_description_data['description_type'];
|
||||
$data['description_title'] = $course_description_data['description_title'];
|
||||
$data['description_content'] = $course_description_data['description_content'];
|
||||
$data['progress'] = $course_description_data['progress'];
|
||||
$data['descriptions'] = $course_description->get_data_by_description_type(
|
||||
$description_type,
|
||||
null,
|
||||
$session_id
|
||||
);
|
||||
}
|
||||
|
||||
// render to the view
|
||||
$this->view->set_data($data);
|
||||
$this->view->set_layout('layout');
|
||||
$this->view->set_template('edit');
|
||||
$this->view->render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It's used for adding a course description,
|
||||
* render to listing or add view.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$course_description = new CourseDescription();
|
||||
$session_id = api_get_session_id();
|
||||
$course_description->set_session_id($session_id);
|
||||
|
||||
$data = [];
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
|
||||
if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
|
||||
if (1) {
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['contentDescription'];
|
||||
$description_type = $_POST['description_type'];
|
||||
if ($description_type >= ADD_BLOCK) {
|
||||
$course_description->set_description_type($description_type);
|
||||
$course_description->set_title($title);
|
||||
$course_description->set_content($content);
|
||||
$course_description->insert(api_get_course_int_id());
|
||||
}
|
||||
|
||||
Display::addFlash(
|
||||
Display::return_message(
|
||||
get_lang('CourseDescriptionUpdated')
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->listing(false);
|
||||
} else {
|
||||
$data['error'] = 1;
|
||||
$data['default_description_titles'] = $course_description->get_default_description_title();
|
||||
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
|
||||
$data['default_description_icon'] = $course_description->get_default_description_icon();
|
||||
$data['question'] = $course_description->get_default_question();
|
||||
$data['information'] = $course_description->get_default_information();
|
||||
$data['description_title'] = $_POST['title'];
|
||||
$data['description_content'] = $_POST['contentDescription'];
|
||||
$data['description_type'] = $_POST['description_type'];
|
||||
$this->view->set_data($data);
|
||||
$this->view->set_layout('layout');
|
||||
$this->view->set_template('add');
|
||||
$this->view->render();
|
||||
}
|
||||
} else {
|
||||
$data['default_description_titles'] = $course_description->get_default_description_title();
|
||||
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
|
||||
$data['default_description_icon'] = $course_description->get_default_description_icon();
|
||||
$data['question'] = $course_description->get_default_question();
|
||||
$data['information'] = $course_description->get_default_information();
|
||||
$data['description_type'] = $course_description->get_max_description_type();
|
||||
// render to the view
|
||||
$this->view->set_data($data);
|
||||
$this->view->set_layout('layout');
|
||||
$this->view->set_template('add');
|
||||
$this->view->render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It's used for destroy a course description,
|
||||
* render to listing view.
|
||||
*
|
||||
* @param int $id description type
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$course_description = new CourseDescription();
|
||||
$session_id = api_get_session_id();
|
||||
$course_description->set_session_id($session_id);
|
||||
if (!empty($id)) {
|
||||
$course_description->set_id($id);
|
||||
$course_description->delete();
|
||||
Display::addFlash(
|
||||
Display::return_message(get_lang('CourseDescriptionDeleted'))
|
||||
);
|
||||
}
|
||||
$this->listing(false);
|
||||
}
|
||||
}
|
||||
122
main/course_description/edit.php
Normal file
122
main/course_description/edit.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* View (MVC patter) for editing a course description.
|
||||
*
|
||||
* @author Christian Fasanando <christian1827@gmail.com>
|
||||
*/
|
||||
|
||||
// protect a course script
|
||||
api_protect_course_script(true);
|
||||
|
||||
if (empty($id)) {
|
||||
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : '';
|
||||
if (empty($id)) {
|
||||
// If the ID was not provided, find the first matching description item given the item type
|
||||
$course_description = new CourseDescription();
|
||||
$description = $course_description->get_data_by_description_type($description_type);
|
||||
if (count($description) > 0) {
|
||||
$id = $description['id'];
|
||||
}
|
||||
// If no corresponding description is found, edit a new one
|
||||
unset($course_description);
|
||||
}
|
||||
}
|
||||
$original_id = $id;
|
||||
|
||||
if (empty($error)) {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
// display categories
|
||||
$categories = [];
|
||||
foreach ($default_description_titles as $id => $title) {
|
||||
$categories[$id] = $title;
|
||||
}
|
||||
$categories[ADD_BLOCK] = get_lang('NewBloc');
|
||||
|
||||
$i = 1;
|
||||
echo '<div class="actions" style="margin-bottom:30px">';
|
||||
echo '<a href="index.php?'.api_get_cidreq().'">'.
|
||||
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM).
|
||||
'</a>';
|
||||
|
||||
ksort($categories);
|
||||
foreach ($categories as $id => $title) {
|
||||
if ($i == ADD_BLOCK) {
|
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
|
||||
Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
||||
break;
|
||||
} else {
|
||||
echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
|
||||
Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
// error messages
|
||||
if (isset($error) && intval($error) == 1) {
|
||||
echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false);
|
||||
}
|
||||
|
||||
// default header title form
|
||||
$description_type = intval($description_type);
|
||||
$header = $default_description_titles[$description_type];
|
||||
if ($description_type >= ADD_BLOCK) {
|
||||
$header = $default_description_titles[ADD_BLOCK];
|
||||
}
|
||||
|
||||
// display form
|
||||
$form = new FormValidator(
|
||||
'course_description',
|
||||
'POST',
|
||||
'index.php?action=edit&id='.$original_id.'&description_type='.$description_type.'&'.api_get_cidreq()
|
||||
);
|
||||
$form->addElement('header', $header);
|
||||
$form->addElement('hidden', 'id', $original_id);
|
||||
$form->addElement('hidden', 'description_type', $description_type);
|
||||
$form->addElement('hidden', 'sec_token', $token);
|
||||
|
||||
if (api_get_configuration_value('save_titles_as_html')) {
|
||||
$form->addHtmlEditor(
|
||||
'title',
|
||||
get_lang('Title'),
|
||||
true,
|
||||
false,
|
||||
['ToolbarSet' => 'TitleAsHtml']
|
||||
);
|
||||
} else {
|
||||
$form->addText('title', get_lang('Title'));
|
||||
$form->applyFilter('title', 'html_filter');
|
||||
}
|
||||
$form->addHtmlEditor(
|
||||
'contentDescription',
|
||||
get_lang('Content'),
|
||||
true,
|
||||
false,
|
||||
[
|
||||
'ToolbarSet' => 'Basic',
|
||||
'Width' => '100%',
|
||||
'Height' => '200',
|
||||
]
|
||||
);
|
||||
$form->addButtonCreate(get_lang('Save'));
|
||||
|
||||
// Set some default values
|
||||
if (!empty($description_title)) {
|
||||
$default['title'] = Security::remove_XSS($description_title);
|
||||
}
|
||||
if (!empty($description_content)) {
|
||||
$default['contentDescription'] = Security::remove_XSS($description_content, COURSEMANAGERLOWSECURITY);
|
||||
}
|
||||
$default['description_type'] = $description_type;
|
||||
|
||||
$form->setDefaults($default);
|
||||
|
||||
if (isset($question[$description_type])) {
|
||||
$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
|
||||
$message .= $question[$description_type];
|
||||
Display::addFlash(Display::return_message($message, 'normal', false));
|
||||
}
|
||||
$form->display();
|
||||
106
main/course_description/index.php
Normal file
106
main/course_description/index.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Template (front controller in MVC pattern) used for distpaching
|
||||
* to the controllers depend on the current action.
|
||||
*
|
||||
* @author Christian Fasanando <christian1827@gmail.com>
|
||||
*
|
||||
* @package chamilo.course_description
|
||||
*/
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
$current_course_tool = TOOL_COURSE_DESCRIPTION;
|
||||
|
||||
// defining constants
|
||||
define('ADD_BLOCK', 8);
|
||||
|
||||
// current section
|
||||
$this_section = SECTION_COURSES;
|
||||
|
||||
$action = !empty($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'listing';
|
||||
|
||||
$logInfo = [
|
||||
'tool' => TOOL_COURSE_DESCRIPTION,
|
||||
'tool_id' => 0,
|
||||
'tool_id_detail' => 0,
|
||||
'action' => $action,
|
||||
'info' => '',
|
||||
];
|
||||
Event::registerLog($logInfo);
|
||||
|
||||
// protect a course script
|
||||
api_protect_course_script(true);
|
||||
|
||||
$description_type = '';
|
||||
if (isset($_GET['description_type'])) {
|
||||
$description_type = intval($_GET['description_type']);
|
||||
}
|
||||
|
||||
$id = null;
|
||||
if (isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
}
|
||||
|
||||
if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
|
||||
$action = 'listing';
|
||||
}
|
||||
|
||||
// interbreadcrumb
|
||||
$interbreadcrumb[] = ["url" => "index.php?".api_get_cidreq(), "name" => get_lang('CourseProgram')];
|
||||
if ($description_type == 1) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('GeneralDescription')];
|
||||
}
|
||||
if ($description_type == 2) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('Objectives')];
|
||||
}
|
||||
if ($description_type == 3) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('Topics')];
|
||||
}
|
||||
if ($description_type == 4) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('Methodology')];
|
||||
}
|
||||
if ($description_type == 5) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('CourseMaterial')];
|
||||
}
|
||||
if ($description_type == 6) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('HumanAndTechnicalResources')];
|
||||
}
|
||||
if ($description_type == 7) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('Assessment')];
|
||||
}
|
||||
if ($description_type == 8) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('ThematicAdvance')];
|
||||
}
|
||||
if ($description_type >= 9) {
|
||||
$interbreadcrumb[] = ["url" => "#", "name" => get_lang('Others')];
|
||||
}
|
||||
|
||||
// course description controller object
|
||||
$descriptionController = new CourseDescriptionController();
|
||||
|
||||
// block access
|
||||
if (in_array($action, ['add', 'edit', 'delete']) &&
|
||||
!api_is_allowed_to_edit(null, true)
|
||||
) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
// Actions to controller
|
||||
switch ($action) {
|
||||
case 'history':
|
||||
$descriptionController->listing(true);
|
||||
break;
|
||||
case 'add':
|
||||
$descriptionController->add();
|
||||
break;
|
||||
case 'edit':
|
||||
$descriptionController->edit($id, $description_type);
|
||||
break;
|
||||
case 'delete':
|
||||
$descriptionController->destroy($id);
|
||||
break;
|
||||
case 'listing':
|
||||
default:
|
||||
$descriptionController->listing();
|
||||
}
|
||||
26
main/course_description/layout.php
Normal file
26
main/course_description/layout.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Layout (principal view) used for structuring other views.
|
||||
*
|
||||
* @author Christian Fasanando <christian1827@gmail.com>
|
||||
*/
|
||||
|
||||
// protect a course script
|
||||
api_protect_course_script(true);
|
||||
|
||||
// Header
|
||||
Display::display_header('');
|
||||
|
||||
// Introduction section
|
||||
Display::display_introduction_section(TOOL_COURSE_DESCRIPTION);
|
||||
|
||||
// Tracking
|
||||
Event::event_access_tool(TOOL_COURSE_DESCRIPTION);
|
||||
|
||||
// Display
|
||||
echo $content;
|
||||
|
||||
// Footer
|
||||
Display::display_footer();
|
||||
40
main/course_description/resources/js/main.js
Normal file
40
main/course_description/resources/js/main.js
Normal file
@@ -0,0 +1,40 @@
|
||||
function Proxy() {
|
||||
}
|
||||
|
||||
Proxy.prototype.root = function () {
|
||||
return www + '/main/inc/ajax/course_description.ajax.php';
|
||||
}
|
||||
|
||||
Proxy.prototype.post = function (data, f) {
|
||||
if (typeof(sec_token) !== 'undefined') {
|
||||
data.sec_token = sec_token;
|
||||
}
|
||||
$.post(this.root(), data, f, 'json');
|
||||
}
|
||||
|
||||
var CourseDescription = new Proxy();
|
||||
|
||||
CourseDescription.del = function (c_id, id, f) {
|
||||
var data = {
|
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'delete'
|
||||
};
|
||||
this.post(data, f);
|
||||
};
|
||||
|
||||
CourseDescription.delete_by_course = function (c_id, session_id, f) {
|
||||
var data = {
|
||||
c_id: c_id,
|
||||
session_id: session_id,
|
||||
action: 'delete_by_course'
|
||||
};
|
||||
this.post(data, f);
|
||||
};
|
||||
|
||||
var message = {};
|
||||
|
||||
message.update = function (data) {
|
||||
text = typeof(data) == 'string' ? data : data.message;
|
||||
$('#messages').html(text);
|
||||
}
|
||||
Reference in New Issue
Block a user