Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
bae7c178
Commit
bae7c178
authored
Feb 18, 2016
by
Vassilis Kanellopoulos
Browse files
use full dependencies name; minor update to schema; phpCS
parent
8b650692
Changes
5
Hide whitespace changes
Inline
Side-by-side
module/schools/bootstrap.php
View file @
bae7c178
...
...
@@ -52,17 +52,17 @@ return function (Slim\App $app) {
);
};
$container
[
GrEduLabs\Schools\
Action\Lab\ListAll
::
class
]
=
function
(
$c
)
{
$container
[
Action\Lab\ListAll
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Action\Lab\ListAll
(
$c
->
get
(
'view'
),
$c
->
get
(
'l
ab
s
ervice
'
),
$c
->
get
(
's
taff
s
ervice
'
)
$c
->
get
(
Service\L
ab
S
ervice
Interface
::
class
),
$c
->
get
(
Service\S
taff
S
ervice
Interface
::
class
)
);
};
$container
[
GrEduLabs\Schools\
Action\Lab\PersistLab
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Action\Lab\
PersistLab
(
$c
->
get
(
'l
ab
s
ervice
'
)
$container
[
Action\Lab\PersistLab
::
class
]
=
function
(
$c
)
{
return
new
PersistLab
(
$c
->
get
(
Service\L
ab
S
ervice
Interface
::
class
)
);
};
...
...
@@ -175,8 +175,8 @@ return function (Slim\App $app) {
->
add
(
Middleware\InputFilterTeacher
::
class
);
$this
->
delete
(
'/staff'
,
Action\Staff\DeleteTeacher
::
class
);
$this
->
get
(
'/labs'
,
GrEduLabs\Schools\
Action\Lab\ListAll
::
class
)
->
setName
(
'school.labs'
);
$this
->
post
(
'/labs'
,
GrEduLabs\Schools\
Action\Lab\PersistLab
::
class
)
->
setName
(
'school.labcreate'
);
$this
->
get
(
'/labs'
,
Action\Lab\ListAll
::
class
)
->
setName
(
'school.labs'
);
$this
->
post
(
'/labs'
,
Action\Lab\PersistLab
::
class
)
->
setName
(
'school.labcreate'
);
$this
->
get
(
'/assets'
,
Action\Assets\ListAssets
::
class
)
->
setName
(
'school.assets'
);
$this
->
post
(
'/assets'
,
Action\Assets\PersistAsset
::
class
)
...
...
module/schools/data/schema.mysql.sql
View file @
bae7c178
...
...
@@ -149,7 +149,7 @@ CREATE TABLE `school` (
`registry_no`
varchar
(
25
)
COLLATE
utf8mb4_unicode_ci
NOT
NULL
,
`name`
varchar
(
255
)
COLLATE
utf8mb4_unicode_ci
NOT
NULL
,
`street_address`
varchar
(
255
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`postal_code`
int
(
11
)
unsigned
DEFAULT
NULL
,
`postal_code`
varchar
(
20
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`phone_number`
varchar
(
20
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`fax_number`
varchar
(
20
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`email`
varchar
(
255
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
...
...
@@ -245,17 +245,22 @@ UNLOCK TABLES;
-- Table structure for table `course`
--
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`course`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
3
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
--
-- Table structure for table `lab`
--
DROP
TABLE
IF
EXISTS
`lab`
;
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`lab`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`school_id`
int
(
11
)
unsigned
NOT
NULL
,
...
...
@@ -273,8 +278,7 @@ CREATE TABLE `lab` (
KEY
`index_foreignkey_lab_teacher`
(
`teacher_id`
),
CONSTRAINT
`c_fk_lab_teacher_id`
FOREIGN
KEY
(
`teacher_id`
)
REFERENCES
`teacher`
(
`id`
),
CONSTRAINT
`lab_ibfk_1`
FOREIGN
KEY
(
`school_id`
)
REFERENCES
`school`
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
15
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
...
...
@@ -282,6 +286,8 @@ CREATE TABLE `lab` (
-- Table structure for table `course_lab`
--
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`course_lab`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`course_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
...
...
@@ -292,12 +298,9 @@ CREATE TABLE `course_lab` (
KEY
`index_foreignkey_course_lab_lab`
(
`lab_id`
),
CONSTRAINT
`c_fk_course_lab_lab_id`
FOREIGN
KEY
(
`lab_id`
)
REFERENCES
`lab`
(
`id`
)
ON
DELETE
CASCADE
ON
UPDATE
CASCADE
,
CONSTRAINT
`c_fk_course_lab_course_id`
FOREIGN
KEY
(
`course_id`
)
REFERENCES
`course`
(
`id`
)
ON
DELETE
CASCADE
ON
UPDATE
CASCADE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
3
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
--
-- Table structure for table `course`
--
--
-- Table structure for table `schoolasset`
...
...
@@ -322,7 +325,6 @@ CREATE TABLE `schoolasset` (
/*!40101 SET character_set_client = @saved_cs_client */
;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */
;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */
;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */
;
...
...
module/schools/src/Action/Lab/ListAll.php
View file @
bae7c178
...
...
@@ -12,21 +12,20 @@ namespace GrEduLabs\Schools\Action\Lab;
use
GrEduLabs\Schools\Service\LabServiceInterface
;
use
GrEduLabs\Schools\Service\StaffServiceInterface
;
use
RedBeanPHP\R
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
use
Slim\Views\Twig
;
use
RedBeanPHP\R
;
class
ListAll
{
protected
$view
;
public
function
__construct
(
Twig
$view
,
Twig
$view
,
LabServiceInterface
$labservice
,
StaffServiceInterface
$staffservice
)
{
)
{
$this
->
view
=
$view
;
$this
->
labservice
=
$labservice
;
$this
->
staffservice
=
$staffservice
;
...
...
@@ -53,27 +52,28 @@ class ListAll
// R::store($lab);
$labs
=
$this
->
labservice
->
getLabsBySchoolId
(
$school
->
id
);
$staff
=
$this
->
staffservice
->
getTeachersBySchoolId
(
$school
->
id
);
$labs
=
$this
->
labservice
->
getLabsBySchoolId
(
$school
->
id
);
$staff
=
$this
->
staffservice
->
getTeachersBySchoolId
(
$school
->
id
);
$clean_staff
=
[];
foreach
(
$staff
as
$obj
)
{
if
(
$obj
[
'is_responsible'
]){
if
(
$obj
[
'is_responsible'
])
{
$clean_staff
[]
=
[
'value'
=>
$obj
[
'id'
],
'label'
=>
$obj
[
'name'
]
.
" "
.
$obj
[
'surname'
]
'label'
=>
$obj
[
'name'
]
.
" "
.
$obj
[
'surname'
]
,
];
}
}
$courses
=
$this
->
labservice
->
getCourses
();
$lessons
=
[];
foreach
(
$courses
as
$lesson
){
foreach
(
$courses
as
$lesson
)
{
$lessons
[]
=
[
'value'
=>
$lesson
->
id
,
'label'
=>
$lesson
->
name
];
}
error_log
(
print_r
(
$courses
,
TRUE
));
error_log
(
print_r
(
'courses'
,
TRUE
));
error_log
(
print_r
(
$courses
,
TRUE
));
error_log
(
print_r
(
'courses'
,
TRUE
));
return
$this
->
view
->
render
(
$res
,
'schools/labs.twig'
,
[
'labs'
=>
$labs
,
'staff'
=>
$clean_staff
,
'labs'
=>
$labs
,
'staff'
=>
$clean_staff
,
'lab_types'
=>
[
[
'value'
=>
1
,
...
...
module/schools/src/Action/Lab/PersistLab.php
View file @
bae7c178
...
...
@@ -18,7 +18,7 @@ use Slim\Http\Response;
class
PersistLab
{
private
$labservice
;
public
function
__construct
(
LabServiceInterface
$labservice
)
{
$this
->
labservice
=
$labservice
;
...
...
@@ -48,11 +48,10 @@ class PersistLab
if
(
isset
(
$lab
))
{
return
$res
->
withJson
(
$lab
->
export
())
->
withStatus
(
201
);
}
}
catch
(
Exception
$ex
){
}
catch
(
Exception
$ex
)
{
$res
=
$res
->
withStatus
(
500
,
$ex
->
getMessage
());
}
return
$res
->
withStatus
(
400
);
}
}
module/schools/src/Service/LabService.php
View file @
bae7c178
...
...
@@ -71,23 +71,29 @@ class LabService implements LabServiceInterface
return
array_map
([
$this
,
'export'
],
$labs
);
}
public
function
getCourses
(){
public
function
getCourses
()
{
$courses
=
R
::
findAll
(
'course'
);
return
$courses
;
}
public
function
getCoursesByLabId
(
$id
){
$lab
=
R
::
load
(
'lab'
,
$id
);
public
function
getCoursesByLabId
(
$id
)
{
$lab
=
R
::
load
(
'lab'
,
$id
);
$courses
=
$lab
->
sharedCourse
;
return
$courses
;
}
private
function
getCoursesById
(
array
$ids
){
private
function
getCoursesById
(
array
$ids
)
{
$courses
=
[];
foreach
(
$ids
as
$id
){
$course
=
R
::
load
(
'course'
,
$id
);
foreach
(
$ids
as
$id
)
{
$course
=
R
::
load
(
'course'
,
$id
);
$courses
[]
=
$course
;
}
return
$courses
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment