Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iena-path-block
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iena
iena-path-block
Commits
4d87cf8b
Commit
4d87cf8b
authored
3 years ago
by
Lea
Browse files
Options
Downloads
Patches
Plain Diff
edit css/template
parent
4dc7d49f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
career_unit.php
+35
-5
35 additions, 5 deletions
career_unit.php
renderer.php
+190
-6
190 additions, 6 deletions
renderer.php
styles.css
+13
-2
13 additions, 2 deletions
styles.css
templates/section.mustache
+6
-4
6 additions, 4 deletions
templates/section.mustache
with
244 additions
and
17 deletions
career_unit.php
+
35
−
5
View file @
4d87cf8b
...
@@ -41,15 +41,45 @@ function is_not_empty_string($str) {
...
@@ -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
"<div class='alert alert-danger'>Le parcours demandé n'existe pas ou a été supprimé. </div>"
;
echo
$OUTPUT
->
footer
();
echo
$OUTPUT
->
footer
();
}
else
{
}
else
{
$PAGE
->
set_title
(
get_string
(
'title_plugin'
,
'block_career'
));
$PAGE
->
set_title
(
get_string
(
'title_plugin'
,
'block_career'
));
$headingtitle
=
$course
->
fullname
.
' - '
.
$requete
->
name
;
$headingtitle
=
$course
->
fullname
.
' - '
.
$requete
->
name
;
$PAGE
->
set_heading
(
$headingtitle
);
$PAGE
->
set_heading
(
$headingtitle
);
echo
$OUTPUT
->
header
();
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
=
$PAGE
->
get_renderer
(
'block_career'
);
$renderer
->
get_career_header
(
$
requete
->
id
);
$renderer
->
get_career_header
(
$
careerId
,
$follow
);
$renderer
->
get_career_section
(
$
requete
->
i
d
);
$renderer
->
get_career_section
(
$
careerI
d
);
echo
$OUTPUT
->
footer
();
echo
$OUTPUT
->
footer
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
renderer.php
+
190
−
6
View file @
4d87cf8b
...
@@ -26,26 +26,43 @@ class block_career_renderer extends plugin_renderer_base {
...
@@ -26,26 +26,43 @@ class block_career_renderer extends plugin_renderer_base {
else
{
else
{
foreach
(
$request
as
$value
){
foreach
(
$request
as
$value
){
$careerpath
=
$CFG
->
wwwroot
.
'/blocks/career/career_setting.php?courseid='
.
$_GET
[
"courseid"
]
.
'&pathid='
.
$value
->
id
;
$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);
//print_r($careerlist);
echo
$this
->
render_from_template
(
'block_career/career_list'
,
$list
);
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
;
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'
);
$aboutcareer
=
get_string
(
'about_this_career'
,
'block_career'
);
$request
=
$DB
->
get_record
(
'block_career'
,
array
(
'id'
=>
$pathid
));
$request
=
$DB
->
get_record
(
'block_career'
,
array
(
'id'
=>
$pathid
));
$description
=
$request
->
description
;
$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
);
echo
$this
->
render_from_template
(
'block_career/career_header'
,
$list
);
}
}
function
get_career_section
(
$careerId
){
function
get_career_section
(
$careerId
){
global
$DB
,
$CFG
,
$COURSE
,
$USER
,
$SITE
;
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
;
$courseid
=
$requete
->
course
;
$elements
=
$requete
->
ressources
;
$elements
=
$requete
->
ressources
;
$elements
=
explode
(
','
,
$elements
);
$elements
=
explode
(
','
,
$elements
);
...
@@ -72,8 +89,175 @@ class block_career_renderer extends plugin_renderer_base {
...
@@ -72,8 +89,175 @@ class block_career_renderer extends plugin_renderer_base {
for
(
$i
=
0
;
$i
<
count
(
$ressources
);
$i
++
){
for
(
$i
=
0
;
$i
<
count
(
$ressources
);
$i
++
){
echo
$this
->
render_from_template
(
'block_career/section'
,
$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
;
$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
);
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
This diff is collapsed.
Click to expand it.
styles.css
+
13
−
2
View file @
4d87cf8b
...
@@ -3,11 +3,14 @@
...
@@ -3,11 +3,14 @@
padding
:
0
1rem
;
padding
:
0
1rem
;
margin
:
0
10px
;
margin
:
0
10px
;
padding-bottom
:
2rem
;
padding-bottom
:
2rem
;
font-weight
:
450
;
color
:
white
;
margin-left
:
5px
}
}
.resource
{
.resource
{
margin-top
:
5px
;
margin-left
:
10px
;
margin-bottom
:
9px
;
margin-bottom
:
9px
;
margin-left
:
30px
;
margin-top
:
12px
;
}
}
...
@@ -169,3 +172,11 @@ ul.career-ul {
...
@@ -169,3 +172,11 @@ ul.career-ul {
color
:
black
;
color
:
black
;
user-select
:
none
;
user-select
:
none
;
}
}
.career-section-title
{
margin
:
6px
;
margin-bottom
:
22px
;
}
.section-background
{
background-color
:
#6b6e71
;
padding
:
4px
;
}
This diff is collapsed.
Click to expand it.
templates/section.mustache
+
6
−
4
View file @
4d87cf8b
{{^
many
}}
<hr>
{{^
many
}}
<hr>
{{#
section
}}
{{#
section
}}
<div
class=
"career-section-title"
>
<div
class=
"career-section-title"
>
<div
class=
"section-background"
>
<h3>
{{
name
}}
</h3>
<h3>
{{
name
}}
</h3>
</div>
{{#
summary
}}
{{#
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
class=
"career-descr"
>
{{{
summary
}}}
</div>
</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
Afficher / Masquer les infos de la section
</a>
</a>
{{/
summary
}}
{{/
summary
}}
</div>
</div>
{{/
section
}}
{{/
section
}}
{{/
many
}}
{{/
many
}}
<div
class=
"resource"
>
<div
class=
"resource"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment