Skip to content
Snippets Groups Projects
Commit a426125e authored by Thomas Fradet's avatar Thomas Fradet
Browse files

Initial commit

parents
Branches
Tags
No related merge requests found
Showing with 627 additions and 0 deletions
<?php
/**
* block_career
*
*
* @package block_career
* @category block
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille/ faouzi / Thomas Fradet
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_career extends block_base
{
/**
*
*/
public function init()
{
$this->title = get_string('title_plugin', 'block_career');
}
/**
* @return bool
*/
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 stdClass
*/
public function get_content()
{
global $CFG;
global $COURSE;
global $DB;
if ($this->content !== null) {
return $this->content;
}
if (empty($this->config)) {
$this->config = new stdClass();
}
$request = $DB->get_records_sql('SELECT * FROM {block_career} WHERE course = ?', array($COURSE->id));
// var_dump($request);
$careerId = optional_param("career", NULL, PARAM_INT);
$active = "";
$this->content = new stdClass;
$this->content->text .= '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . '" class="btn btn-success btn-career-block mb-3">Accueil du cours</a>';
// $image = "";
$this->content->text .= '<div class="list-group">';
foreach ($request as $value) {
// if (file_get_contents("$CFG->wwwroot/blocks/career/$value->image") != null) {
// $image = "<img src='$CFG->wwwroot/blocks/career/$value->image' class='img_moodle_list'/>";
// }
if ($careerId != null && $careerId == $value->id) {
$active = "active";
} else {
$active = "";
}
$this->content->text .= "<a href='" . $CFG->wwwroot . "/blocks/career/career_unit.php?career=" . $value->id . "' class='list-group-item $active'>$value->name</a>";
// $this->content->text .= "<a href='" . $CFG->wwwroot . "/blocks/career/career_unit.php?career=" . $value->id . "' class='full list-group-item list-group-item-action $active'><div class=' left img_center'>$image</div>
// &nbsp&nbsp $value->name</a><br>";
}
$this->content->text .= '</div>';
if (empty($request)) {
$this->content->text .= "<p>" . get_string('any_carrer', 'block_career') . "</p>";
}
$this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/career/career_list.php?course=' . $COURSE->id . '" type="button " class="btn btn-primary btn-career-block mt-3">Gérer les parcours</a>';
// $this->content->text .= "<p></p>";
return $this->content;
}
}
?>
\ No newline at end of file
<?php
define('NO_OUTPUT_BUFFERING', true);
require_once('../../config.php');
require_once('entity/block_career_ressource.php');
require_once('entity/block_career_section.php');
require_once('view/view_career_list.php');
global $COURSE;
global $USER;
global $DB;
global $CFG;
require_once($CFG->libdir . '/adminlib.php');
$id_course = required_param('course', PARAM_INT);
$url = new moodle_url('/blocks/career/career_list.php', array('course' => $id_course));
//Check if the user has capability to update course
if (!has_capability('moodle/course:update', $context = context_course::instance($id_course), $USER->id)) {
header("Location: {$_SERVER['HTTP_REFERER']}");
exit;
}
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
$course = $DB->get_record('course', array('id' => $id_course), '*', MUST_EXIST);
require_login($course, false, NULL);
$PAGE->set_title(get_string('title_plugin', 'block_career'));
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
$ressource = new block_career_ressource();
$section = new block_career_section();
echo $OUTPUT->header();
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">";
$content = new view_career_list();
echo $content->get_content();
echo $OUTPUT->footer();
\ No newline at end of file
<?php
ob_start();
require_once('../../config.php');
global $COURSE, $DB, $CFG;
require_once("$CFG->libdir/formslib.php");
require_once('entity/block_career_ressource.php');
require_once('entity/block_career_section.php');
require_once('view/view_career_setting.php');
$id_course = required_param('course', PARAM_INT);
$url = new moodle_url('/blocks/career/career_setting.php', array('course' => $id_course));
$PAGE->set_pagelayout('course');
$PAGE->set_url($url);
$course = $DB->get_record('course', array('id' => $id_course), '*', MUST_EXIST);
require_login($course, false, NULL);
$PAGE->set_title(get_string('title_plugin', 'block_career'));
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
echo $OUTPUT->header();
$PAGE->requires->js("/blocks/career/js/jquery.min.js");
$PAGE->requires->js("/blocks/career/js/file.js");
// echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">";
$content = new view_career_setting();
echo $content->get_content();
// Delete career
if (isset($_GET["delete"]) && $_GET["delete"] == 1) {
$DB->execute("DELETE FROM {block_career} WHERE id = ?", array($_GET["id"]));
header("Location: $CFG->wwwroot/blocks/career/career_list.php?course=" . $_GET["course"]);
}
if (!empty($_POST["careerName"])) {
$ressourses = "";
foreach ($_POST["ressource"] as $value) {
if ($value === end($_POST["ressource"])) {
$ressourses .= "$value";
} else {
$ressourses .= "$value,";
}
}
//$record is use for insert/update in database
$record = new stdClass();
$record->course = intval($_GET["course"]);
$record->name = $_POST["careerName"];
$record->description = $_POST["descriptionName"]["text"];
// if (isset($_FILES['imageName']['tmp_name'])) {
// $pathDir = "img/";
// $pathFile = $pathDir . basename($_FILES["imageName"]["name"]);
// move_uploaded_file($_FILES['imageName']['tmp_name'], $pathFile);
// $record->image = $pathFile;
// } else {
// $record->image = $_POST["imagePath"];
// }
$record->image = "";
$record->ressources = $ressourses;
if ($_POST["careerId"] != 0) {
$record->id = intval($_POST["careerId"]);
$lastinsertid = $DB->update_record('block_career', $record);
} else {
$lastinsertid = $DB->insert_record('block_career', $record);
}
if ($lastinsertid != 0) {
header("Location: $CFG->wwwroot/blocks/career/career_list.php?course=" . $_GET["course"]);
}
}
echo $OUTPUT->footer();
<?php
require_once('../../config.php');
require_once('entity/block_career_ressource.php');
require_once('entity/block_career_section.php');
global $COURSE, $DB;
$careerId = required_param('career', PARAM_INT);
$url = new moodle_url('/blocks/career/career_unit.php', array('career' => $careerId));
$requete = $DB->get_record_sql('SELECT course FROM {block_career} WHERE id = ?', array($careerId));
$PAGE->set_pagelayout('course');
$PAGE->set_url($url);
// Getting DB data for the course
$course = $DB->get_record('course', array('id' => $requete->course), '*', MUST_EXIST);
// Must be logged in
require_login($course, false, NULL);
$PAGE->set_title(get_string('title_plugin', 'block_career'));
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
echo $OUTPUT->header();
$PAGE->requires->js("/blocks/career/js/jquery.min.js");
$PAGE->requires->js("/blocks/career/js/file.js");
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">";
require_once('view/view_career_unit.php');
echo $OUTPUT->footer();
<?php
$capabilities = array(
'block/career:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/career:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
?>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/career/db" VERSION="20180212" COMMENT="XMLDB file for Moodle blocks/career"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="block_career" COMMENT="Table du block parcours">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="8" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="name" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="description" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="ressources" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="image" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
<?php
if (!defined('MOODLE_INTERNAL'))
die('Direct access to this script is forbidden.');
class block_career_edit_form extends block_edit_form
{
/**
* @param $mform
*/
function specific_definition($mform)
{
// Adding an element to the form
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
}
}
?>
<?php
/**
* The iena filter plugin transforms the moodle resource links
* into a button that opens the resource in a modal
*
* @package block_career
* @category block
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille/ faouzi
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* block_career_ressource
*
*
* @package filter_iena
* @copyright 2018 Softia/Université lorraine
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_career_ressource
{
/** @var int Id of ressource */
public $id;
/** @var string name of ressource */
public $name;
/** @var string link of ressource */
public $link;
/** @var string type of ressource */
public $type;
/** @var int module id of ressource */
public $module;
/** @var string intro of ressource */
public $descrition;
/** @var block_career_section section of ressource */
public $section;
/**
* Set $id, $name, $type
* @param array $id_course_modules
*
* @return void
*/
public function get_ressource_by_id($id_course_modules)
{
global $DB;
if ($id_course_modules) {
$this->id = $id_course_modules;
$requete = $DB->get_record_sql('SELECT * FROM {course_modules} WHERE id = ? AND deletioninprogress = 0', array($id_course_modules));
$id_instance = $requete->instance;
$id_module = $requete->module;
if ($id_module) {
$modules = $DB->get_record_sql('SELECT * FROM {modules} WHERE id = ?', array($id_module));
}
if ($modules->name) {
$instance = $DB->get_record_sql('SELECT * FROM {' . $modules->name . '} WHERE id = ?', array($id_instance));
}
if ($instance->name) {
$this->name = $instance->name;
}
$this->descrition = $instance->intro;
$this->type = $modules->name;
$this->module = $modules->id;
$this->section = new block_career_section();
$this->section->get_section_by_id_section($requete->section);
$this->create_link();
}
}
/**
* Get all ressources in a section
* return a array
* @param array $id_section
*
* @return array<block_career_ressource> $ressources
*/
public function get_ressources_by_id_section($id_section)
{
global $DB;
$requete = $DB->get_records_sql('SELECT id FROM {course_modules} WHERE section = ? AND deletioninprogress = 0', array($id_section));
$ressources = array();
$i = 0;
foreach ($requete as $value) {
$ressource = new block_career_ressource();
$ressource->get_ressource_by_id($value->id);
$ressources[$i] = $ressource;
$i++;
}
return $ressources;
}
/**
* Create and SET ($link) a correct link with $CFG->wwwroot, $type and $id
* @param void
*
* @return void
*/
private function create_link()
{
global $CFG;
$this->link = $CFG->wwwroot . '/mod/' . $this->type . '/view.php?id=' . $this->id;
}
}
<?php
/**
* block_career_section
*
*
* @package block_career
* @category block
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille/ faouzi / Thomas Fradet
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_career_section
{
/** @var int Id of section */
public $id;
/** @var string name of section */
public $name;
/** @var int id of course */
public $id_course;
/** @var block_career_ressources array<Object> ressources */
public $ressources;
/** @var string summary */
public $summary;
/** @var int order of section */
public $orde;
/** @var string intro of section */
public $intro;
/**
* Set $id, $name, $id_course and $summary
* @param array $id_section
*
* @return void
*/
public function get_section_by_id_section($id_section)
{
global $DB;
$requete = $DB->get_record_sql('SELECT * FROM {course_sections} WHERE id = ?', array($id_section));
$this->id = $requete->id;
$this->name = $requete->name;
$this->id_course = $requete->course;
$this->summary = $requete->summary;
$this->orde = $requete->section;
$this->intro = $requete->summary;
if (!$this->name) {
$this->name = "Section " . $requete->section;
}
}
/**
* Get all sections in a course
* return a array
* @param array $id_course
*
* @return array<block_career_section> $sections
*/
public function get_sections_by_id_course($id_course)
{
global $DB;
$requete = $DB->get_records_sql('SELECT * FROM {course_sections} WHERE course = ? ORDER BY section', array($id_course));
// $numsection = $DB->get_record_sql('SELECT value FROM {course_format_options} WHERE courseid = ? AND name = ?', array($id_course,"numsections"));
$sections = array();
$i = 0;
foreach ($requete as $value) {
// if ($value->section > $numsection->value){
// continue;
// }
$section = new block_career_section();
$section->get_section_by_id_section($value->id);
$sections[$i] = $section;
$i++;
}
return $sections;
}
}
img/Capture d’écran 2018-06-19 à 18.18.32.png

173 KiB

img/numoc-16-9-blanc.png

84.9 KiB

img/rose-rose.jpg

44.5 KiB

<?php
header('HTTP/1.0 403 Forbidden');
require_once('../../config.php');
$PAGE->set_url($_SERVER['PHP_SELF']);
$PAGE->set_pagelayout('admin');
$PAGE->set_context(context_system::instance());
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('error'));
echo '<center>' . get_string('nopermissiontoshow', 'core_error') . '</center>';
?>
\ No newline at end of file
(function () {
$('#btnRight').click(function (e) {
var selectedOpts = $('#lstBox1 option:selected');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
$('#lstBox2').append($(selectedOpts).clone());
// $(selectedOpts).remove();
e.preventDefault();
});
$('#btnAllRight').click(function (e) {
var selectedOpts = $('#lstBox1 option');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
$('#lstBox2').append($(selectedOpts).clone());
// $(selectedOpts).remove();
e.preventDefault();
});
$('#btnLeft').click(function (e) {
var selectedOpts = $('#lstBox2 option:selected');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
// $('#lstBox1').append($(selectedOpts).clone());
$(selectedOpts).remove();
e.preventDefault();
});
$('#btnAllLeft').click(function (e) {
var selectedOpts = $('#lstBox2 option');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
// $('#lstBox1').append($(selectedOpts).clone());
$(selectedOpts).remove();
e.preventDefault();
});
$('.wrapper').find('a[href="#"]').on('click', function (e) {
e.preventDefault();
this.expand = !this.expand;
$(this).text(this.expand?"Réduire":"Voir la description compléte");
$(this).closest('.wrapper').find('.small, .big').toggleClass('small big');
});
}(jQuery));
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
$string['date_release'] = '{$a->month}.{$a->date}.{$a->year}';
$string['career'] = 'Moodle Version';
$string['career:addinstance'] = 'Ajouter un block Parcours';
$string['career:myaddinstance'] = 'Ajouter un block Parcours sur ma page';
$string['pluginname'] = 'Path block';
$string['release'] = 'Release: ';
$string['title_plugin'] = 'Path';
$string['titleadd_plugin'] = 'New Path';
$string['titleaddname_plugin'] = 'Name';
$string['titleadddesc_plugin'] = 'Description';
$string['titleaddimg_plugin'] = 'Course picture';
$string['titleaddelem_plugin'] = 'Course elements';
$string['titleaddelemdesc_plugin'] = 'Drag and drop the elements of the course you want to add to this course';
$string['heading_plugin'] = 'The path allow you to group some course resources in a particular sequence.';
$string['add_path'] = 'Add a path';
$string['any_carrer'] = 'No Path in this course';
?>
\ No newline at end of file
<?php
$string['date_release'] = '{$a->month}.{$a->date}.{$a->year}';
$string['career'] = 'Version Moodle';
$string['career:addinstance'] = 'Ajouter un block Parcours';
$string['career:myaddinstance'] = 'Ajouter un block Parcours sur ma page';
$string['pluginname'] = 'Bloc Parcours';
$string['title_plugin'] = 'Parcours';
$string['titleadd_plugin'] = 'Ajouter un parcours';
$string['titleaddname_plugin'] = 'Nom';
$string['titleadddesc_plugin'] = 'Description';
$string['titleaddimg_plugin'] = 'Image du parcours';
$string['titleaddelem_plugin'] = 'Elements du parcours';
$string['titleaddelemdesc_plugin'] = 'Glissez-déposez les élements du cours que vous souhaitez ajouter à ce parcours';
$string['heading_plugin'] = 'Les parcours permettent de regrouper certaines ressources du cours dans un enchaînement particulier.';
$string['add_path'] = 'Ajouter un parcours';
$string['any_carrer'] = 'Pas de parcours';
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment