-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
605 additions
and
5 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,46 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Add dynamic help when adding or editing an activity. | ||
* | ||
* @module local_apprenticeoffjob/activitytypes | ||
* @copyright 2024 Solent University {@link https://www.solent.ac.uk} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
export const init = (activitytypes) => { | ||
const activitytypediv = document.querySelector('#id_error_activitytype'); | ||
if (!activitytypediv) { | ||
return; | ||
} | ||
let activitydesc = document.createElement('div'); | ||
activitydesc.setAttribute('id', 'activitydesc'); | ||
activitydesc.style.width = '100%'; | ||
activitydesc.style.marginTop = '10px'; | ||
activitytypediv.after(activitydesc); | ||
let activity = document.querySelector('#id_activitytype').value; | ||
if (activity > 0) { | ||
activitydesc.innerHTML = activitytypes[activity] ?? ''; | ||
} | ||
document.addEventListener('change', e => { | ||
if (e.target.id == 'id_activitytype') { | ||
activity = e.target.value; | ||
if (activity > 0) { | ||
activitydesc.innerHTML = activitytypes[activity] ?? ''; | ||
} | ||
} | ||
}); | ||
}; |
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,54 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace local_apprenticeoffjob; | ||
|
||
use core\persistent; | ||
|
||
/** | ||
* Class activitytype | ||
* | ||
* @package local_apprenticeoffjob | ||
* @copyright 2024 Solent University {@link https://www.solent.ac.uk} | ||
* @author Mark Sharp <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class activitytype extends persistent { | ||
/** | ||
* Table name for activity types | ||
*/ | ||
const TABLE = 'local_apprenticeactivities'; | ||
|
||
/** | ||
* Define properties for model | ||
* | ||
* @return array | ||
*/ | ||
protected static function define_properties(): array { | ||
return [ | ||
'activityname' => [ | ||
'type' => PARAM_TEXT, | ||
], | ||
'description' => [ | ||
'type' => PARAM_RAW, | ||
], | ||
'status' => [ | ||
'type' => PARAM_BOOL, | ||
'default' => false, | ||
], | ||
]; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace local_apprenticeoffjob\forms; | ||
|
||
use context_system; | ||
use core\form\persistent as persistent_form; | ||
use lang_string; | ||
|
||
/** | ||
* Class activitytype | ||
* | ||
* @package local_apprenticeoffjob | ||
* @copyright 2024 Solent University {@link https://www.solent.ac.uk} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class activitytype_form extends persistent_form { | ||
/** | ||
* Cross reference for the object this form is working from. | ||
* | ||
* @var string | ||
*/ | ||
protected static $persistentclass = 'local_apprenticeoffjob\\activitytype'; | ||
|
||
/** | ||
* Activity type object editing form | ||
* | ||
* @return void | ||
*/ | ||
public function definition() { | ||
$mform = $this->_form; | ||
$required = new lang_string('required'); | ||
$mform->addElement('text', 'activityname', new lang_string('activityname', 'local_apprenticeoffjob')); | ||
$mform->addRule('activityname', $required, 'required', null, 'client'); | ||
|
||
$mform->addElement('textarea', 'description', new lang_string('description'), 'wrap="virtual" rows="20" cols="50"'); | ||
$mform->setType('description', PARAM_RAW); | ||
|
||
$mform->addElement('advcheckbox', 'status', new lang_string('enabled', 'local_apprenticeoffjob')); | ||
$mform->addElement('hidden', 'id'); | ||
|
||
$this->add_action_buttons(); | ||
} | ||
} |
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,126 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace local_apprenticeoffjob\tables; | ||
|
||
use core_user; | ||
use html_writer; | ||
use lang_string; | ||
use moodle_url; | ||
use table_sql; | ||
|
||
/** | ||
* Class activitytypes_table | ||
* | ||
* @package local_apprenticeoffjob | ||
* @copyright 2024 Solent University {@link https://www.solent.ac.uk} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class activitytypes_table extends table_sql { | ||
/** | ||
* Constructor to set up table | ||
* | ||
* @param string $uniqueid | ||
*/ | ||
public function __construct($uniqueid) { | ||
parent::__construct($uniqueid); | ||
$this->useridfield = 'modifiedby'; | ||
$columns = [ | ||
'id', | ||
'activityname', | ||
'description', | ||
'enabled', | ||
'usermodified', | ||
'timemodified', | ||
'actions', | ||
]; | ||
|
||
$columnheadings = [ | ||
'id', | ||
new lang_string('activityname', 'local_apprenticeoffjob'), | ||
new lang_string('description'), | ||
new lang_string('enabled', 'local_apprenticeoffjob'), | ||
new lang_string('modifiedby', 'local_apprenticeoffjob'), | ||
new lang_string('lastmodified', 'local_apprenticeoffjob'), | ||
new lang_string('actions', 'local_apprenticeoffjob'), | ||
]; | ||
|
||
$this->define_columns($columns); | ||
$this->define_headers($columnheadings); | ||
$this->no_sorting('actions'); | ||
$this->sortable(true, 'activityname', SORT_ASC); | ||
$this->collapsible(false); | ||
|
||
$this->define_baseurl(new moodle_url("/local/apprenticeoffjob/manageactivitytypes.php")); | ||
$where = '1=1'; | ||
$this->set_sql('*', "{local_apprenticeactivities}", $where); | ||
} | ||
|
||
/** | ||
* Output actions column | ||
* | ||
* @param stdClass $row | ||
* @return string HTML for row's column value | ||
*/ | ||
public function col_actions($row) { | ||
$params = ['action' => 'edit', 'id' => $row->id]; | ||
$edit = new moodle_url('/local/apprenticeoffjob/editactivitytype.php', $params); | ||
$html = html_writer::link($edit, get_string('edit')); | ||
|
||
return $html; | ||
} | ||
|
||
/** | ||
* Output enabled column | ||
* | ||
* @param stdClass $row | ||
* @return string HTML for row's column value | ||
*/ | ||
public function col_enabled($row) { | ||
return ($row->status) ? new lang_string('enabled', 'local_apprenticeoffjob') | ||
: new lang_string('notenabled', 'local_apprenticeoffjob'); | ||
} | ||
|
||
/** | ||
* Output usermodified column | ||
* | ||
* @param stdClass $row | ||
* @return string HTML for row's column value | ||
*/ | ||
public function col_usermodified($row) { | ||
if ($row->usermodified == 0) { | ||
return ''; | ||
} | ||
$modifiedby = core_user::get_user($row->usermodified); | ||
if (!$modifiedby || $modifiedby->deleted) { | ||
return get_string('deleteduser', 'local_apprenticeoffjob'); | ||
} | ||
return fullname($modifiedby); | ||
} | ||
|
||
/** | ||
* Output timemodified column | ||
* | ||
* @param stdClass $row | ||
* @return string HTML for row's column value | ||
*/ | ||
public function col_timemodified($row) { | ||
if ($row->timemodified == 0) { | ||
return ''; | ||
} | ||
return userdate($row->timemodified, get_string('strftimedatetimeshort', 'core_langconfig')); | ||
} | ||
} |
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
Oops, something went wrong.