mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-63058 block_myoverview: starring and storing preferences
This commit is contained in:
parent
b81722e22f
commit
3cfff88516
39 changed files with 1403 additions and 101 deletions
|
@ -35,12 +35,26 @@ use moodle_url;
|
|||
*/
|
||||
class course_summary_exporter extends \core\external\exporter {
|
||||
|
||||
/**
|
||||
* Constructor - saves the persistent object, and the related objects.
|
||||
*
|
||||
* @param mixed $data - Either an stdClass or an array of values.
|
||||
* @param array $related - An optional list of pre-loaded objects related to this object.
|
||||
*/
|
||||
public function __construct($data, $related = array()) {
|
||||
if (!array_key_exists('isfavourite', $related)) {
|
||||
$related['isfavourite'] = false;
|
||||
}
|
||||
parent::__construct($data, $related);
|
||||
}
|
||||
|
||||
protected static function define_related() {
|
||||
// We cache the context so it does not need to be retrieved from the course.
|
||||
return array('context' => '\\context');
|
||||
return array('context' => '\\context', 'isfavourite' => 'bool?');
|
||||
}
|
||||
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
|
||||
$courseimage = self::get_course_image($this->data);
|
||||
if (!$courseimage) {
|
||||
$courseimage = self::get_course_pattern($this->data);
|
||||
|
@ -56,7 +70,8 @@ class course_summary_exporter extends \core\external\exporter {
|
|||
'viewurl' => (new moodle_url('/course/view.php', array('id' => $this->data->id)))->out(false),
|
||||
'courseimage' => $courseimage,
|
||||
'progress' => $progress,
|
||||
'hasprogress' => $hasprogress
|
||||
'hasprogress' => $hasprogress,
|
||||
'isfavourite' => $this->related['isfavourite']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -119,6 +134,9 @@ class course_summary_exporter extends \core\external\exporter {
|
|||
),
|
||||
'hasprogress' => array(
|
||||
'type' => PARAM_BOOL
|
||||
),
|
||||
'isfavourite' => array(
|
||||
'type' => PARAM_BOOL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue