forked from SAFeSEA/openEssayist-slim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug SAFeSEA#31, move 5 X Model classes to separate files [iet:10299536]
- Loading branch information
Showing
8 changed files
with
184 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Feedback model. | ||
* | ||
* @package OpenEssayist-slim | ||
* @copyright © 2013-2018 The Open University. (Institute of Educational Technology) | ||
*/ | ||
|
||
class Feedback extends Model | ||
{ | ||
/** | ||
* | ||
* @key Feedback/users_id | ||
* @return User | ||
* @see ORMWrapper | ||
*/ | ||
public function user() { | ||
return $this->belongs_to('Users'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* Group model. | ||
* | ||
* @package OpenEssayist-slim | ||
* @copyright © 2013-2018 The Open University. (Institute of Educational Technology) | ||
*/ | ||
|
||
class Group extends Model { | ||
/** | ||
* | ||
* @key Users/group_id | ||
* @return ORMWrapper | ||
*/ | ||
public function users() { | ||
return $this->has_many('Users'); | ||
} | ||
|
||
/** | ||
* @key Task/group_id | ||
* @return ORMWrapper | ||
*/ | ||
public function tasks() { | ||
return $this->has_many('Task'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* KWCategory model. | ||
* | ||
* @package OpenEssayist-slim | ||
* @copyright © 2013-2018 The Open University. (Institute of Educational Technology) | ||
*/ | ||
|
||
class KWCategory extends Model { | ||
|
||
/** | ||
* | ||
* @key KWCategory/draft_id | ||
* @return Task | ||
* @see ORMWrapper | ||
*/ | ||
public function task() { | ||
return $this->belongs_to('Draft'); | ||
} | ||
|
||
public function getGroups($assoc = true) | ||
{ | ||
$json = $this->category; | ||
$rr = json_decode($json, $assoc); | ||
return $rr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Note model. | ||
* | ||
* @package OpenEssayist-slim | ||
* @copyright © 2013-2018 The Open University. (Institute of Educational Technology) | ||
*/ | ||
|
||
class Note extends Model | ||
{ | ||
/** | ||
* | ||
* @key Note/users_id | ||
* @return User | ||
* @see ORMWrapper | ||
*/ | ||
public function user() { | ||
return $this->belongs_to('Users'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Task / assignment model. | ||
* | ||
* @package OpenEssayist-slim | ||
* @copyright © 2013-2018 The Open University. (Institute of Educational Technology) | ||
*/ | ||
|
||
/** | ||
* Default data model for the assignemnt (task) | ||
* @author Nicolas Van Labeke (https://github.com/vanch3d) | ||
* | ||
*/ | ||
class Task extends Model { | ||
|
||
/** | ||
* @key Draft/task_id | ||
* @return ORMWrapper | ||
*/ | ||
public function drafts() { | ||
return $this->has_many('Draft'); | ||
} | ||
|
||
/** | ||
* @key Task/group_id | ||
* @return ORMWrapper | ||
* @see Group | ||
*/ | ||
public function group() { | ||
return $this->belongs_to('Group'); | ||
} | ||
|
||
/** | ||
* Return the short version (first sentence) of the assignment question | ||
* @return string | ||
*/ | ||
public function short() | ||
{ | ||
$tt = preg_split('/(?<=[.?!;:])\s+/', $this->assignment); | ||
return "" . $tt[0]; | ||
} | ||
|
||
/** | ||
* Return the long version (all but first sentence) of the assignment question | ||
* @return string | ||
*/ | ||
public function long() | ||
{ | ||
$tt = preg_split('/(?<=[.?!;:])\s+/', $this->assignment); | ||
array_shift($tt); | ||
return "".join(" ", $tt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters