Commit 4d87cf8b authored by Lea's avatar Lea
Browse files

edit css/template

parent 4dc7d49f
......@@ -41,15 +41,45 @@ function is_not_empty_string($str) {
echo "<div class='alert alert-danger'>Le parcours demandé n'existe pas ou a été supprimé. </div>";
echo $OUTPUT->footer();
} else {
$PAGE->set_title(get_string('title_plugin', 'block_career'));
}
else {
$PAGE->set_title(get_string('title_plugin', 'block_career'));
$headingtitle=$course->fullname.' - '.$requete->name;
$PAGE->set_heading($headingtitle);
echo $OUTPUT->header();
$request=$DB->get_record_sql('SELECT enrollment FROM {block_career} WHERE id=?',array($careerId));
$follow=false;
if ($request->enrollment=='student') {
$sql='SELECT mdl_groups.id
FROM {groups} JOIN {groups_members}
WHERE mdl_groups.id=groupid AND userid=? AND idnumber=?';
$request=$DB->get_record_sql($sql,array($USER->id,'GR'.$careerId));
if(!empty($request)){
$follow=get_string('unfollow','block_career');
}
else{
$follow=get_string('follow','block_career');
}
if (isset($_POST['action'])) {
if($_POST['action']==get_string('unfollow','block_career')&&!empty($request)){
$follow=get_string('follow','block_career');
$requete=$DB->execute("DELETE FROM {groups_members} WHERE userid = ? AND groupid", array($USER->id,$request->id));
}else{
$follow=get_string('unfollow','block_career');
$requete=$DB->get_record('groups',array('idnumber'=>'GR'.$careerId));
$groupid=$requete->id;
$record = new stdClass();
$record->groupid=$groupid;
$record->userid=$USER->id;
$record->timeadded=time();
$lastinsertid = $DB->insert_record('groups_members', $record);
}
}
}
$renderer = $PAGE->get_renderer('block_career');
$renderer->get_career_header($requete->id);
$renderer->get_career_section($requete->id);
$renderer->get_career_header($careerId,$follow);
$renderer->get_career_section($careerId);
echo $OUTPUT->footer();
}
\ No newline at end of file
......@@ -26,26 +26,43 @@ class block_career_renderer extends plugin_renderer_base {
else {
foreach ($request as $value){
$careerpath=$CFG->wwwroot.'/blocks/career/career_setting.php?courseid='.$_GET["courseid"].'&pathid='.$value->id;
array_push($careerlist,array('name'=>$value->name,'description'=>$value->description));
$enrolpath=$CFG->wwwroot.'/blocks/career/career_enrol.php?courseid='.$_GET["courseid"].'&pathid='.$value->id;
$enrol=true;
if($value->enrollment=='teacher'){
$enrol=false;
}
array_push($careerlist,array('name'=>$value->name,'description'=>$value->description,'enrol'=>$enrol));
}
$list=['list_title'=>$listtitle, 'heading_plugin'=>$headingplugin,'add_path'=>$addpath, 'path'=>$path,'career_path'=>$careerpath, 'course_id'=>$courseid,'career_list'=>$careerlist];
$list=['list_title'=>$listtitle, 'heading_plugin'=>$headingplugin,'add_path'=>$addpath, 'path'=>$path,'career_path'=>$careerpath, 'course_id'=>$courseid,'career_list'=>$careerlist,'enrol_path'=>$enrolpath];
}
//print_r($careerlist);
echo $this->render_from_template('block_career/career_list', $list);
}
function get_career_header($pathid){
function get_career_header($pathid,$follow){
global $DB, $CFG, $COURSE, $USER;
if($follow==get_string('follow','block_career')){
$class="btn-primary";
}
else {
$class="btn-danger";
}
$student=false;
$context = context_course::instance($COURSE->id);
$aboutcareer=get_string('about_this_career','block_career');
$request = $DB->get_record('block_career',array('id' => $pathid));
$description=$request->description;
$list=array('about_this_career'=>$aboutcareer,'description'=>$description);
$formlink=$CFG->wwwroot.'/blocks/career/career_unit.php?career='.$pathid.'&courseid='.$COURSE->id;
if (!has_capability('moodle/course:update', $context)&&$request->enrollment=='student') {
$student=true;
}
$list=array('about_this_career'=>$aboutcareer,'description'=>$description,'student'=>$student,'follow'=>$follow,'class'=>$class,'link'=>$formlink);
echo $this->render_from_template('block_career/career_header', $list);
}
function get_career_section($careerId){
global $DB, $CFG, $COURSE, $USER,$SITE;
$requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId));
$requete = $DB->get_record('block_career',array('id' => $careerId));
$courseid=$requete->course;
$elements = $requete->ressources;
$elements = explode(',', $elements);
......@@ -72,8 +89,175 @@ class block_career_renderer extends plugin_renderer_base {
for($i = 0; $i < count($ressources);$i++){
echo $this->render_from_template('block_career/section', $ressources[$i]);
}
$context = context_course::instance($COURSE->id);
if (has_capability('moodle/course:update', $context)){
$lien=true;
}else{
$lien=false;
}
$link=$CFG->wwwroot.'/blocks/career/career_setting.php?courseid='.$requete->course.'&pathid='.$requete->id;
$list =['lien'=>false,'edit_path_link'=>$link,'edit_path'=>get_string('edit_path', 'block_career')];
$list =['edit_lien'=>$lien,'edit_path_link'=>$link,'edit_path'=>get_string('edit_path', 'block_career')];
echo $this->render_from_template('block_career/section', $list);
}
function get_settings(){
$content = new view_career_setting();
$list=['content'=> $content->get_content()];
echo $this->render_from_template('block_career/settings', $list);
}
function get_career_enrol(){
global $DB, $CFG, $COURSE;
$groupList=array();
$check=true;
$currentGroup=array();
$requete=$DB->get_records_sql('SELECT * FROM {groups} WHERE courseid = ?', array($COURSE->id));
$request=$DB->get_records_sql('SELECT * FROM {block_career_groups} WHERE career = ?',array($_GET["pathid"]));
if (empty($requete)) {
$emptygroup=get_string('any_group', 'block_career');
}
else{
foreach($requete as $value){
foreach($request as $group){
if($group->group_id==$value->id){
$check=false;
}
else{
$check=true;
}
}
array_push($groupList,array('name'=>$value->name,'id'=>$value->id,'check'=>$check));
}
}
if (!empty($request)) {
foreach($request as $value){
$req=$DB->get_records('groups',array('id'=>$value->group_id));
foreach($req as $element){
array_push($currentGroup,array('name'=>$element->name,'id'=>$value->id));
}
}
}
$enrolpath=$CFG->wwwroot.'/block/career/career_list.php?courseid='.$COURSE->id;
$manageGroup=$CFG->wwwroot.'/group/index.php?id='.$COURSE->id;
$list=['manage_group'=> $manageGroup,'manage'=>get_string('manage','block_career'),'group_list'=>$groupList,'current_group'=>$currentGroup,'save'=>get_string('save','block_career')];
echo $this->render_from_template('block_career/career_enrol', $list);
}
}
class view_career_setting extends moodleform{
public function definition()
{
global $CFG;
$mform = $this->_form;
}
public function get_content(){
global $DB, $CFG;
$career_ressource=array();
$mform = $this->_form;
$careerId = optional_param('pathid', NULL, PARAM_INT);
$course = required_param('courseid', PARAM_INT);
$name = "";
$description = "";
$ressourcesId = "";
$contentButton = "Ajouter un parcours";
if (isset($careerId) && !empty($careerId))
{
$requete = $DB->get_record_sql('SELECT * FROM {block_career} WHERE id = ?', array($careerId));
$name = $requete->name;
$description = $requete->description;
$ressourcesId = explode(",", $requete->ressources);
$contentButton = "Modifier le parcours";
}
$mform->addElement('text','careerName',get_string('titleaddname_plugin', 'block_career'));
$mform->addRule('careerName', get_string('error'), 'required', null, null, false, false);
$mform->setDefault('careerName',$name);
$mform->addElement('editor', 'descriptionName', get_string('titleadddesc_plugin', 'block_career'));
$mform->setType('descriptionName', PARAM_RAW);
$mform->addRule('descriptionName', get_string('error'), 'required', null, null, false, false);
$mform->setDefault('descriptionName',array('text'=>$description));
$mform->addElement('select', 'enrollment', get_string('enroll','block_career'), array('student'=>get_string('student','block_career'), 'teacher'=>get_string('teacher','block_career')));
$content = "";
$content .= "<h2>Édition du parcours</h2>";
$content .= "<div class='alert alert-info'>" . get_string('heading_plugin', 'block_career') . "</div>";
$temp = $mform->toHtml();
$temp = substr($temp,(strpos($temp,'>')+1));
$temp = substr($temp,0, -7);
$sections = block_career_section::get_sections_by_id_course($course);
$content .= '<form class="col-12" action="'.$CFG->wwwroot.'/blocks/career/career_setting.php?courseid="'.$course.'&pathid="'.$careerId.'" method="POST">';
$content .= $temp;
foreach ($sections as $section) {
$section->ressources = block_career_ressource::get_ressources_by_id_section($section->id);
}
$content .= '<h2 style="margin-top: 1.5rem;">' . get_string('titleaddelem_plugin', 'block_career') . '</h2><div class="alert alert-info">' . get_string('titleaddelemdesc_plugin', 'block_career') . '</div>';
$content.='<div class="gauche">';
$content.='<div class="ressource-list" style ="overflow:auto; margin-bottom: 5px">';
$content=$this->print_ressources($content,$sections,$career_ressource,$ressourcesId);
$content.='</div>';
//if ($careerId != 0){
$content.='<div class="add_ressources">';
$content.='<input type="submit" class="btn btn-primary" name="action" value="Mettre à jour les ressources">';
$content.='</div>';
//}
$content.='</div>';
$content .='<div class="actual-ressource" style ="overflow:auto">';
$content .='<h3>'.get_string('actual_content','block_career').'</h3>';
$content .= '<ul class="career-ul">';
foreach($career_ressource as $ressource){
$content .= '<li style="list-style: none">
<label>
<span class="fancy--label">'. $ressource.'</span>
</label>
</li>';
}
$content.='</div>';
$content .= '
<div class="buttons">
<input type="hidden" name="careerId" value="'.$careerId.'">
<input type="hidden" name="courseid" value="'.$course.'">
<a href=' . $CFG->wwwroot . "/blocks/career/career_list.php?courseid=" . $course .' class="btn btn-secondary">Annuler</a>';
if ($careerId != 0) {
$content .= "<a href='".$CFG->wwwroot."/blocks/career/career_setting.php?courseid=".$course."&delete=1&id=".$careerId."' class='btn btn-danger'>Supprimer</a> ";
}
$content .= '<input type="submit" class="btn btn-primary" name="action" value="Enregistrer">';
$content .= '</div></form>';
return $content;
}
public function print_ressources($content, $sections, &$career_ressource,$ressourcesId){
foreach ($sections as $section) {
if ( count($section->ressources) > 0 ) {
$content .= '<h3 class="h4 career-edit-list-title">' . $section->name . '</h3>';
$content .= '<ul class="career-ul">';
foreach ($section->ressources as $ressource) {
$check = false;
if ($ressourcesId != "") {
foreach ($ressourcesId as $ress_id) {
if ( $ress_id == $ressource->id ) {
$check = true;
break;
}
}
}
if ( $check ) {
$content .= '<li>
<label>
<input type="checkbox" name="ressource[]" value="' . $ressource->id . '" label="'. $ressource->name .'" checked>
<span class="fancy--input"></span>
<span class="fancy--label">'. $ressource->name .'</span>
</label>
</li>';
array_push($career_ressource, $ressource->name);
} else {
$content .= '<li>
<label>
<input type="checkbox" name="ressource[]" value="' . $ressource->id . '" label="'. $ressource->name .'">
<span class="fancy--input"></span>
<span class="fancy--label">'. $ressource->name .'</span>
</label>
</li>';
}
}
$content .= '</ul>';
}
}
return $content;
}
}
\ No newline at end of file
......@@ -3,11 +3,14 @@
padding: 0 1rem ;
margin: 0 10px;
padding-bottom: 2rem;
font-weight: 450;
color:white;
margin-left:5px
}
.resource{
margin-top: 5px;
margin-left: 10px;
margin-bottom: 9px;
margin-left:30px;
margin-top:12px;
}
......@@ -169,3 +172,11 @@ ul.career-ul {
color: black;
user-select: none;
}
.career-section-title{
margin:6px;
margin-bottom:22px;
}
.section-background{
background-color:#6b6e71;
padding:4px;
}
{{^many}}<hr>
{{#section}}
<div class="career-section-title">
<div class="career-section-title">
<div class="section-background">
<h3>{{name}}</h3>
</div>
{{#summary}}
<div class="collapse" id="summary-section-collapse{{id}}" aria-expanded="false">
<div class="collapse" id="summary-section-collapse{{id}}" aria-expanded="false" style="background-color:#CECECE">
<div class="career-descr">{{{summary}}}</div>
</div>
<a role="button" class="collapsed" data-toggle="collapse" href="#summary-section-collapse{{id}}" aria-expanded="true" aria-controls="summary-collapse" style="margin:5px 18px">
<a role="button" class="collapsed" data-toggle="collapse" href="#summary-section-collapse{{id}}" aria-expanded="true" aria-controls="summary-collapse" style="margin-left:10px; color:#6b6e71">
Afficher / Masquer les infos de la section
</a>
{{/summary}}
</div>
</div>
{{/section}}
{{/many}}
<div class="resource">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment