Skip to content
Snippets Groups Projects
view_career_unit.php 2.75 KiB
<?php

$careerId = required_param("career", PARAM_INT);
global $DB, $CFG, $COURSE;
$requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId));

$percent = 70;
$nb_pers = 5;
$titre = $requete->name;
$presence = "En présence";
$date = "24 nov";
$intro = $requete->description;
$img = '';
$titre_module = "Introduction";

$elements = $requete->ressources;
$elements = explode(',', $elements);
$sections = array();
$ressources = array();
$i = 0;
foreach ($elements as $value) {
	$ressource = new block_career_ressource();
	$ressource->get_ressource_by_id($value);
	$sections[$i] = $ressource->section;
	$ressources[$i] = $ressource;
	$i++;
}
//var_dump($sections);
//Supprime les doublons
for($i = 0; $i < count($sections);$i++)
{
	$temp = $i;
	$temp++;

	if ($temp != count($sections))
	{
		if ($sections[$i]->id == $sections[$temp]->id)
		{
			unset($sections[$i]);
		}
	}
}

//Met dans l'orde
$keys = array();
$i = 0;
foreach ($sections as $value){
	$keys[$i] = $value->orde;
	$i++;
}
$sections = array_combine($keys,$sections);
ksort($sections);

$cours_url = $CFG->wwwroot . "/course/view.php?id=" . $COURSE->id;

?>


<section class="section">
	<h2 class="display-4" style="float: left;"><?=$titre;?></h2>
	<a class="btn btn-primary" style="float: right;" href="<?php echo $cours_url; ?>">Retour au cours</a>
	<div class="career-descr" style="clear: both;">
		<?php echo $intro; ?>
	</div>
	<?php foreach ($sections as $section) : ?>
		<div style="margin-bottom: 0rem; margin-top: 1rem;">
			<div class="career-section-title">
				<h3><?php echo $section->name; ?></h3>
			</div>
			<div class="iena-career-description wrapper">
				<?php echo $section->intro; ?>
			</div>
			<div class="list-group">
				<?php foreach ($ressources as $value) : ?>
					<?php if($value->section->id == $section->id) : ?>
						<a href="<?php echo "$value->link&career=$careerId" ?>" class="list-group-item list-group-item-action flex-column align-items-start">
							<div class="d-flex w-100 justify-content-between">
								<h5 style="margin-bottom: 0;">
									<?php echo $value->name;?>
								</h5>
								<img class="" alt="" src="<?php echo $CFG->wwwroot ?>/theme/image.php/boost/<?php echo $value->type ?>/1/icon>">
							</div>
							<?php 
							$descr = $value->descrition;
							$to_delete = array('<p>', '</p>', '<br>', '</br>', ' ');
							$descr = str_replace($to_delete, '', $descr);
							$descr = preg_replace('/\s+/', '', $descr);
							if ( $descr != "" ) {
								echo "<div style='margin-top: 0.25rem;'>" . $value->descrition . "</div>";
							}
							?>
						</a>
					<?php endif;?>
				<?php endforeach;?>
			</div>
		</div>
	<?php endforeach;?>

</section>