block_competency_iena.php 3.38 KB
Newer Older
Thomas Fradet's avatar
folder  
Thomas Fradet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<?php

require_once('entity/block_competency_iena_competency.php');

class block_competency_iena extends block_base
{
	public function init()
	{
		$this->title = get_string('title_plugin', 'block_competency_iena');
	}

	function instance_allow_multiple()
	{
		return false;
	}

	/**
		 * Set the applicable formats for this block to all
		 * @return array
		 */
	function applicable_formats()
	{
		return array('course' => true);
	}
	
		/**
		 * Allow the user to configure a block instance
		 * @return bool Returns true
		 */
		function instance_allow_config()
		{
			return true;
		}
		
		function has_config()
		{
			return true;
		}
		
		public function get_content()
		{
			global $CFG;
			global $COURSE;
			global $USER;
			
			if ($this->content !== null) {
				return $this->content;
			}
			if (empty($this->config)) {
				$this->config = new stdClass();
			}
			
			$this->content = new stdClass;
Thomas Fradet's avatar
Thomas Fradet committed
54
			$this->content->text = "";
Thomas Fradet's avatar
folder  
Thomas Fradet committed
55 56
			if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)) {
				$this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/competency_iena/competency_iena_competencies.php?courseid=' . $COURSE->id . '"  class="btn btn-primary w-100 mb-3" style="white-space: normal;">Acquisition des compétences</a>';
Thomas Fradet's avatar
Thomas Fradet committed
57
				$this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/competency_iena/competency_iena_competencies_2.php?courseid=' . $COURSE->id . '"  class="btn btn-warning w-100 mb-3" style="white-space: normal;">Acquisition des compétences 2</a>';
Thomas Fradet's avatar
folder  
Thomas Fradet committed
58 59 60 61 62
				$this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/competency_iena/competency_iena_competencies_mgmt.php?courseid=' . $COURSE->id . '" type="button " class="btn btn-success w-100 mb-3" style="white-space: normal;">Gérer les compétences</a>';
				$this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/competency_iena/competency_iena_competency_mgmt.php?courseid=' . $COURSE->id . '" type="button " class="btn btn-secondary w-100 mb-3" style="white-space: normal;">Informations sur l\'APC</a>';
			} else {
				$this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/competency_iena/competency_iena_competencies.php?courseid=' . $COURSE->id . '"  class="btn btn-primary w-100 mb-3">Mes Compétences</a>';
			}
Thomas Fradet's avatar
Thomas Fradet committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

			// $competenceI = new block_competency_iena_competency();
			// $competences = $competenceI->get_competencies_by_userID($USER->id);
			// $nb_ok = 0;
			// $nb_total = count($competences);
			// foreach ($competences as $comp) {
			// 	if ($comp->proficiency == 1) {
			// 		$nb_ok++;
			// 	}
			// }
			// // $this->content->text .= "<p></p>";
			// if ($nb_total > 0) {
			// 	$progress_percentage = ceil($nb_ok*100/$nb_total);
			// 	$this->content->text .= "
			// 	<div class=\"progress\">
			// 	<div class=\"progress-bar\" role=\"progressbar\" style=\"width: $progress_percentage%;\" aria-valuenow=\"$nb_ok\" aria-valuemin=\"0\" aria-valuemax=\"$nb_total\">$nb_ok/$nb_total</div>
			// 	</div>
			// 	";
			// } else {
			// 	$progress_percentage = 0;
			// 	$this->content->text .= "
			// 	<div class=\"progress\">
			// 	<div class=\"progress-bar\" role=\"progressbar\" style=\"width: $progress_percentage%;\" aria-valuenow=\"$nb_ok\" aria-valuemin=\"0\" aria-valuemax=\"$nb_total\"></div>
			// 	</div>
			// 	";
			// }
Thomas Fradet's avatar
folder  
Thomas Fradet committed
89 90 91 92 93 94
			
			return $this->content;
		}
	}

	?>