You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					163 lines
				
				4.8 KiB
			
		
		
			
		
	
	
					163 lines
				
				4.8 KiB
			| 
								 
											15 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								/* For licensing terms, see /license.txt */
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								/**
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								 * This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @author Patrick Cool
							 | 
						||
| 
								 | 
							
								 * @author Denes Nagy
							 | 
						||
| 
								 | 
							
								 * @author Roan Embrechts, refactoring and code cleaning
							 | 
						||
| 
								 | 
							
								 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
							 | 
						||
| 
								 | 
							
								 * @package chamilo.learnpath
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								$_SESSION['whereami'] = 'lp/build';
							 | 
						||
| 
								 | 
							
								$this_section = SECTION_COURSES;
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								api_protect_course_script();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								include 'learnpath_functions.inc.php';
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								/* Constants and variables */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
							 | 
						||
| 
								 | 
							
								$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
							 | 
						||
| 
								 | 
							
								$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$isStudentView  = (int) $_REQUEST['isStudentView'];
							 | 
						||
| 
								 | 
							
								$learnpath_id   = (int) $_REQUEST['lp_id'];
							 | 
						||
| 
								 | 
							
								$submit			= $_POST['submit_button'];
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								/* MAIN CODE */
							 | 
						||
| 
								 | 
							
								if ((!$is_allowed_to_edit) || ($isStudentView)) {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    error_log('New LP - User not authorized in lp_build.php');
							 | 
						||
| 
								 | 
							
								    header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								// From here on, we are admin because of the previous condition, so don't check anymore.
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								/* The learnpath has been just created, go get the last id. */
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								$is_new = false;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								$course_id = api_get_course_int_id();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								if ($learnpath_id == 0) {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    $is_new = true;
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    $sql        = "SELECT id FROM " . $tbl_lp . " WHERE c_id = $course_id ORDER BY id DESC LIMIT 0, 1";
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    $result     = Database::query($sql);
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    $row        = Database::fetch_array($result);
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    $learnpath_id = $row['id'];
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								$sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								$result = Database::query($sql_query);
							 | 
						||
| 
								 | 
							
								$therow = Database::fetch_array($result);
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								/* SHOWING THE ADMIN TOOLS */
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
							 | 
						||
| 
								 | 
							
								    $gradebook = $_SESSION['gradebook'];
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								} elseif (empty($_GET['gradebook'])) {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    unset($_SESSION['gradebook']);
							 | 
						||
| 
								 | 
							
								    $gradebook = '';
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								if (!empty($gradebook) && $gradebook == 'view') {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    $interbreadcrumb[] = array (
							 | 
						||
| 
								 | 
							
								        'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
							 | 
						||
| 
								 | 
							
								        'name' => get_lang('ToolGradebook')
							 | 
						||
| 
								 | 
							
								    );
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								$interbreadcrumb[] = array('url' => '#', "name" => $therow['name']);
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								// Theme calls.
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								$lp_theme_css=$_SESSION['oLP']->get_theme();
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								$show_learn_path = true;
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								Display::display_header('', 'Path');
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								$suredel = trim(get_lang('AreYouSureToDeleteJS'));
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								?>
							 | 
						||
| 
								 | 
							
								<script type='text/javascript'>
							 | 
						||
| 
								 | 
							
								/* <![CDATA[ */
							 | 
						||
| 
								 | 
							
								function stripslashes(str) {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    str=str.replace(/\\'/g,'\'');
							 | 
						||
| 
								 | 
							
								    str=str.replace(/\\"/g,'"');
							 | 
						||
| 
								 | 
							
								    str=str.replace(/\\\\/g,'\\');
							 | 
						||
| 
								 | 
							
								    str=str.replace(/\\0/g,'\0');
							 | 
						||
| 
								 | 
							
								    return str;
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								function confirmation(name) {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    name=stripslashes(name);
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								        return true;
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    } else {
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								        return false;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 | 
							
								</script>
							 | 
						||
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								/* DISPLAY SECTION */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								echo $_SESSION['oLP']->build_action_menu();
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											11 years ago
										 
									 | 
							
								echo '<div class="row">';
							 | 
						||
| 
								 | 
							
								echo '<div class="col-md-4">';
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								// Build the tree with the menu items in it.
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								echo $_SESSION['oLP']->return_new_tree();
							 | 
						||
| 
								 | 
							
								echo '</div>';
							 | 
						||
| 
								 
											11 years ago
										 
									 | 
							
								echo '<div class="col-md-8">';
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								if (isset($is_success) && $is_success === true) {
							 | 
						||
| 
								 | 
							
								    Display::display_confirmation_message(get_lang('ItemRemoved'));
							 | 
						||
| 
								 | 
							
								} else {
							 | 
						||
| 
								 | 
							
								    if ($is_new) {
							 | 
						||
| 
								 | 
							
								        Display::display_normal_message(get_lang('LearnpathAdded'), false);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    // Display::display_normal_message(get_lang('LPCreatedAddChapterStep'), false);
							 | 
						||
| 
								 | 
							
								    $gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    echo Display::page_subheader(get_lang('LearnPathAddedTitle'));
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    echo '<ul id="lp_overview" class="thumbnails">';
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								    echo show_block(
							 | 
						||
| 
								 | 
							
								        'lp_controller.php?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=add_item&type=step&lp_id='.$_SESSION['oLP']->lp_id,
							 | 
						||
| 
								 | 
							
								        get_lang("NewStep"),
							 | 
						||
| 
								 | 
							
								        get_lang('NewStepComment'),
							 | 
						||
| 
								 | 
							
								        'tools.png'
							 | 
						||
| 
								 | 
							
								    );
							 | 
						||
| 
								 | 
							
								    echo show_block(
							 | 
						||
| 
								 | 
							
								        'lp_controller.php?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=view&lp_id='.$_SESSION['oLP']->lp_id,
							 | 
						||
| 
								 | 
							
								        get_lang("Display"),
							 | 
						||
| 
								 | 
							
								        get_lang('DisplayComment'),
							 | 
						||
| 
								 | 
							
								        'view.png'
							 | 
						||
| 
								 | 
							
								    );
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								    echo '</ul>';
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								echo '</div>';
							 | 
						||
| 
								 | 
							
								echo '</div>';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								function show_block($link, $title, $subtitle, $icon) {
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								    $html = '<li class="col-md-4">';
							 | 
						||
| 
								 
											10 years ago
										 
									 | 
							
								    $html .=  '<div class="thumbnail">';
							 | 
						||
| 
								 | 
							
								    $html .=  '<a href="'.$link.'" title="'.$title.'">';
							 | 
						||
| 
								 | 
							
								    $html .=  Display::return_icon($icon, $title, array(), ICON_SIZE_BIG);
							 | 
						||
| 
								 | 
							
								    $html .=  '</a>';
							 | 
						||
| 
								 | 
							
								    $html .=  '<div class="caption">';
							 | 
						||
| 
								 | 
							
								    $html .=  '<strong>'.$title.'</strong></a> '.$subtitle;
							 | 
						||
| 
								 | 
							
								    $html .=  '</div>';
							 | 
						||
| 
								 | 
							
								    $html .=  '</div>';
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								    $html .=  '</li>';
							 | 
						||
| 
								 | 
							
								    return $html;
							 | 
						||
| 
								 
											14 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								/* FOOTER */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								Display::display_footer();
							 |