first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+147
View File
@@ -0,0 +1,147 @@
<?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/>.
/**
* Block displaying information about current logged-in user.
*
* This block can be used as anti cheating measure, you
* can easily check the logged-in user matches the person
* operating the computer.
*
* @package block_myprofile
* @copyright 2010 Remote-Learner.net
* @author Olav Jordan <olav.jordan@remote-learner.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Displays the current user's profile information.
*
* @copyright 2010 Remote-Learner.net
* @author Olav Jordan <olav.jordan@remote-learner.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_myprofile extends block_base {
/**
* block initializations
*/
public function init() {
$this->title = get_string('pluginname', 'block_myprofile');
}
/**
* block contents
*
* @return object
*/
public function get_content() {
if ($this->content !== NULL) {
return $this->content;
}
if (!isloggedin() or isguestuser()) {
// Only real users can access myprofile block.
return;
}
$renderable = new \block_myprofile\output\myprofile($this->config);
$renderer = $this->page->get_renderer('block_myprofile');
$this->content = new stdClass();
$this->content->text = $renderer->render($renderable);
$this->content->footer = '';
return $this->content;
}
/**
* allow the block to have a configuration page
*
* @return boolean
*/
public function has_config() {
return false;
}
/**
* allow more than one instance of the block on a page
*
* @return boolean
*/
public function instance_allow_multiple() {
//allow more than one instance on a page
return false;
}
/**
* allow instances to have their own configuration
*
* @return boolean
*/
function instance_allow_config() {
//allow instances to have their own configuration
return false;
}
/**
* instance specialisations (must have instance allow config true)
*
*/
public function specialization() {
}
/**
* locations where block can be displayed
*
* @return array
*/
public function applicable_formats() {
return array('all'=>true);
}
/**
* post install configurations
*
*/
public function after_install() {
}
/**
* post delete configurations
*
*/
public function before_delete() {
}
/**
* Return the plugin config settings for external functions.
*
* @return stdClass the configs for both the block instance and plugin
* @since Moodle 3.8
*/
public function get_config_for_external() {
// Return all settings for all users since it is safe (no private keys, etc..).
$configs = !empty($this->config) ? $this->config : new stdClass();
return (object) [
'instance' => $configs,
'plugin' => new stdClass(),
];
}
}
@@ -0,0 +1,129 @@
<?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/>.
/**
* Class containing data for myprofile block.
*
* @package block_myprofile
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_myprofile\output;
defined('MOODLE_INTERNAL') || die();
use renderable;
use renderer_base;
use templatable;
/**
* Class containing data for myprofile block.
*
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class myprofile implements renderable, templatable {
/**
* @var object An object containing the configuration information for the current instance of this block.
*/
protected $config;
/**
* Constructor.
*
* @param object $config An object containing the configuration information for the current instance of this block.
*/
public function __construct($config) {
$this->config = $config;
}
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param \renderer_base $output
* @return \stdClass
*/
public function export_for_template(renderer_base $output) {
global $USER, $OUTPUT;
$data = new \stdClass();
if (!isset($this->config->display_picture) || $this->config->display_picture == 1) {
$data->userpicture = $OUTPUT->user_picture($USER, array('class' => 'userpicture'));
}
$data->userfullname = fullname($USER);
if (!isset($this->config->display_country) || $this->config->display_country == 1) {
$countries = get_string_manager()->get_list_of_countries(true);
if (isset($countries[$USER->country])) {
$data->usercountry = $countries[$USER->country];
}
}
if (!isset($this->config->display_city) || $this->config->display_city == 1) {
$data->usercity = $USER->city;
}
if (!isset($this->config->display_email) || $this->config->display_email == 1) {
$data->useremail = obfuscate_mailto($USER->email, '');
}
if (!empty($this->config->display_phone1) && !empty($USER->phone1)) {
$data->userphone1 = s($USER->phone1);
}
if (!empty($this->config->display_phone2) && !empty($USER->phone2)) {
$data->userphone2 = s($USER->phone2);
}
if (!empty($this->config->display_institution) && !empty($USER->institution)) {
$data->userinstitution = format_string($USER->institution);
}
if (!empty($this->config->display_address) && !empty($USER->address)) {
$data->useraddress = format_string($USER->address);
}
if (!empty($this->config->display_idnumber) && !empty($USER->idnumber)) {
$data->useridnumber = s($USER->idnumber);
}
if (!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) {
$data->userfirstaccess = userdate($USER->firstaccess);
}
if (!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) {
$data->userlastaccess = userdate($USER->lastaccess);
}
if (!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) {
$data->usercurrentlogin = userdate($USER->currentlogin);
}
if (!empty($this->config->display_lastip) && !empty($USER->lastip)) {
$data->userlastip = $USER->lastip;
}
if (!empty($this->config->display_lastlogin) && !empty($USER->lastlogin)) {
$data->userlastlogin = userdate($USER->lastlogin);
}
return $data;
}
}
@@ -0,0 +1,49 @@
<?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/>.
/**
* myprofile block rendrer
*
* @package block_myprofile
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_myprofile\output;
defined('MOODLE_INTERNAL') || die;
use plugin_renderer_base;
/**
* myprofile block renderer
*
* @package block_myprofile
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends plugin_renderer_base {
/**
* Return the main content for the block myprofile.
*
* @param myprofile $myprofile The myprofile renderable
* @return string HTML string
*/
public function render_myprofile(myprofile $myprofile) {
return $this->render_from_template('block_myprofile/myprofile', $myprofile->export_for_template($this));
}
}
@@ -0,0 +1,46 @@
<?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/>.
/**
* Privacy Subsystem implementation for block_myprofile.
*
* @package block_myprofile
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_myprofile\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_myprofile implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+51
View File
@@ -0,0 +1,51 @@
<?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/>.
/**
* My profile block caps.
*
* @package block_myprofile
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/myprofile:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/myprofile:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
+130
View File
@@ -0,0 +1,130 @@
<?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/>.
defined('MOODLE_INTERNAL') || die();
/**
* Form for editing profile block settings
*
* @package block_myprofile
* @copyright 2010 Remote-Learner.net
* @author Olav Jordan <olav.jordan@remote-learner.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_myprofile_edit_form extends block_edit_form {
protected function specific_definition($mform) {
global $CFG;
$mform->addElement('header', 'configheader', get_string('myprofile_settings', 'block_myprofile'));
$mform->addElement('selectyesno', 'config_display_picture', get_string('display_picture', 'block_myprofile'));
if (isset($this->block->config->display_picture)) {
$mform->setDefault('config_display_picture', $this->block->config->display_picture);
} else {
$mform->setDefault('config_display_picture', '1');
}
$mform->addElement('selectyesno', 'config_display_country', get_string('display_country', 'block_myprofile'));
if (isset($this->block->config->display_country)) {
$mform->setDefault('config_display_country', $this->block->config->display_country);
} else {
$mform->setDefault('config_display_country', '1');
}
$mform->addElement('selectyesno', 'config_display_city', get_string('display_city', 'block_myprofile'));
if (isset($this->block->config->display_city)) {
$mform->setDefault('config_display_city', $this->block->config->display_city);
} else {
$mform->setDefault('config_display_city', '1');
}
$mform->addElement('selectyesno', 'config_display_email', get_string('display_email', 'block_myprofile'));
if (isset($this->block->config->display_email)) {
$mform->setDefault('config_display_email', $this->block->config->display_email);
} else {
$mform->setDefault('config_display_email', '1');
}
$mform->addElement('selectyesno', 'config_display_phone1', get_string('display_phone1', 'block_myprofile'));
if (isset($this->block->config->display_phone1)) {
$mform->setDefault('config_display_phone1', $this->block->config->display_phone1);
} else {
$mform->setDefault('config_display_phone1', '0');
}
$mform->addElement('selectyesno', 'config_display_phone2', get_string('display_phone2', 'block_myprofile'));
if (isset($this->block->config->display_phone2)) {
$mform->setDefault('config_display_phone2', $this->block->config->display_phone2);
} else {
$mform->setDefault('config_display_phone2', '0');
}
$mform->addElement('selectyesno', 'config_display_institution', get_string('display_institution', 'block_myprofile'));
if (isset($this->block->config->display_institution)) {
$mform->setDefault('config_display_institution', $this->block->config->display_institution);
} else {
$mform->setDefault('config_display_institution', '0');
}
$mform->addElement('selectyesno', 'config_display_address', get_string('display_address', 'block_myprofile'));
if (isset($this->block->config->display_address)) {
$mform->setDefault('config_display_address', $this->block->config->display_address);
} else {
$mform->setDefault('config_display_address', '0');
}
$mform->addElement('selectyesno', 'config_display_idnumber', get_string('display_idnumber', 'block_myprofile'));
if (isset($this->block->config->display_idnumber)) {
$mform->setDefault('config_display_idnumber', $this->block->config->display_idnumber);
} else {
$mform->setDefault('config_display_idnumber', '0');
}
$mform->addElement('selectyesno', 'config_display_firstaccess', get_string('display_firstaccess', 'block_myprofile'));
if (isset($this->block->config->display_firstaccess)) {
$mform->setDefault('config_display_firstaccess', $this->block->config->display_firstaccess);
} else {
$mform->setDefault('config_display_firstaccess', '0');
}
$mform->addElement('selectyesno', 'config_display_lastaccess', get_string('display_lastaccess', 'block_myprofile'));
if (isset($this->block->config->display_lastaccess)) {
$mform->setDefault('config_display_lastaccess', $this->block->config->display_lastaccess);
} else {
$mform->setDefault('config_display_lastaccess', '0');
}
$mform->addElement('selectyesno', 'config_display_currentlogin', get_string('display_currentlogin', 'block_myprofile'));
if (isset($this->block->config->display_currentlogin)) {
$mform->setDefault('config_display_currentlogin', $this->block->config->display_currentlogin);
} else {
$mform->setDefault('config_display_currentlogin', '0');
}
$mform->addElement('selectyesno', 'config_display_lastip', get_string('display_lastip', 'block_myprofile'));
if (isset($this->block->config->display_lastip)) {
$mform->setDefault('config_display_lastip', $this->block->config->display_lastip);
} else {
$mform->setDefault('config_display_lastip', '0');
}
$mform->addElement('selectyesno', 'config_display_lastlogin', get_string('display_lastlogin', 'block_myprofile'));
if (isset($this->block->config->display_lastlogin)) {
$mform->setDefault('config_display_lastlogin', $this->block->config->display_lastlogin);
} else {
$mform->setDefault('config_display_lastlogin', '0');
}
}
}
@@ -0,0 +1,45 @@
<?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/>.
/**
* Strings for component 'block_myprofile', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_myprofile
* @copyright 2010 Remote-Learner.net
* @author Olav Jordan <olav.jordan@remote-learner.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['contentsettings'] = 'Display settings for content region';
$string['display_picture'] = 'Display picture';
$string['display_country'] = 'Display country';
$string['display_city'] = 'Display city';
$string['display_email'] = 'Display email';
$string['display_phone1'] = 'Display phone';
$string['display_phone2'] = 'Display mobile phone';
$string['display_idnumber'] = 'Display ID number';
$string['display_institution'] = 'Display institution';
$string['display_address'] = 'Display address';
$string['display_firstaccess'] = 'Display first access';
$string['display_lastaccess'] = 'Display last access';
$string['display_currentlogin'] = 'Display current login';
$string['display_lastip'] = 'Display last IP';
$string['display_lastlogin'] = 'Display last login';
$string['myprofile:addinstance'] = 'Add a new logged in user block';
$string['myprofile:myaddinstance'] = 'Add a new logged in user block to Dashboard';
$string['myprofile_settings'] = 'Visible user information';
$string['pluginname'] = 'Logged in user';
$string['privacy:metadata'] = 'The Logged in user block only shows information about the logged in user and does not store data itself.';
+28
View File
@@ -0,0 +1,28 @@
.block_myprofile img.profilepicture {
height: 50px;
width: 50px;
}
.block_myprofile .myprofileitem.fullname {
font-size: 1.5em;
font-weight: bold;
margin-bottom: 0.5rem;
}
.block_myprofile .myprofileitem.edit {
text-align: right;
}
.block_myprofile .content {
display: flex;
}
.block_myprofile .myprofileitem.picture img {
width: 50px;
height: 50px;
margin-right: 1rem;
}
.block_myprofile .myprofileitem span {
font-weight: bold;
}
@@ -0,0 +1,155 @@
{{!
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/>.
}}
{{!
@template block_myprofile/myprofile
This template renders the content of the myprofile block.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* userfullname
Optional context variables for this template:
* userpicture
* usercountry
* usercity
* useremail
* userphone1
* userphone2
* userinstitution
* useraddress
* useridnumber
* userfirstaccess
* userlastaccess
* usercurrentlogin
* userlastip
* userlastlogin
Example context (json):
{
"userpicture": "<img src='http://example.com/image.png' title='Picture of John Doe'>",
"userfullname": "John Doe",
"usercountry": "Australia",
"usercity": "Perth",
"useremail": "<a href=''>john.doe@example.com</a>",
"userphone1": "123456789",
"userphone2": "123456789",
"userinstitution": "Institution",
"useraddress": "Address",
"useridnumber": "12345",
"userfirstaccess": "Friday, 6 July 2018, 9:03 AM",
"userlastaccess": "Wednesday, 26 September 2018, 8:05 AM",
"usercurrentlogin": "Wednesday, 26 September 2018, 7:17 AM",
"userlastip": "0:0:0:0:0:0:0:1",
"userlastlogin": "Wednesday, 25 September 2018, 9:01 AM"
}
}}
<div>
{{#userpicture}}
<div class="myprofileitem picture">
{{{ userpicture }}}
</div>
{{/userpicture}}
</div>
<div class="w-100 no-overflow">
<div class="myprofileitem fullname">
{{ userfullname }}
</div>
{{#usercountry}}
<div class="myprofileitem country">
<span>{{#str}} country {{/str}}:</span>
{{ usercountry }}
</div>
{{/usercountry}}
{{#usercity}}
<div class="myprofileitem city">
<span>{{#str}} city {{/str}}:</span>
{{ usercity }}
</div>
{{/usercity}}
{{#useremail}}
<div class="myprofileitem city">
<span>{{#str}} email {{/str}}:</span>
{{{ useremail }}}
</div>
{{/useremail}}
{{#userphone1}}
<div class="myprofileitem phone1">
<span>{{#str}} phone1 {{/str}}:</span>
{{ userphone1 }}
</div>
{{/userphone1}}
{{#userphone2}}
<div class="myprofileitem phone2">
<span>{{#str}} phone2 {{/str}}:</span>
{{ userphone2 }}
</div>
{{/userphone2}}
{{#userinstitution}}
<div class="myprofileitem institution">
<span>{{#str}} institution {{/str}}:</span>
{{ userinstitution }}
</div>
{{/userinstitution}}
{{#useraddress}}
<div class="myprofileitem address">
<span>{{#str}} address {{/str}}:</span>
{{ useraddress }}
</div>
{{/useraddress}}
{{#useridnumber}}
<div class="myprofileitem idnumber">
<span>{{#str}} idnumber {{/str}}:</span>
{{{ useridnumber }}}
</div>
{{/useridnumber}}
{{#userfirstaccess}}
<div class="myprofileitem firstaccess">
<span>{{#str}} firstaccess {{/str}}: </span>
{{ userfirstaccess }}
</div>
{{/userfirstaccess}}
{{#userlastaccess}}
<div class="myprofileitem lastaccess">
<span>{{#str}} lastaccess {{/str}}:</span>
{{ userlastaccess }}
</div>
{{/userlastaccess}}
{{#usercurrentlogin}}
<div class="myprofileitem currentlogin">
<span>{{#str}} login {{/str}}:</span>
{{ usercurrentlogin }}
</div>
{{/usercurrentlogin}}
{{#userlastlogin}}
<div class="myprofileitem lastlogin">
<span>{{#str}} lastlogin {{/str}}:</span>
{{ userlastlogin }}
</div>
{{/userlastlogin}}
{{#userlastip}}
<div class="myprofileitem lastip">
<span>IP:</span>
{{ userlastip }}
</div>
{{/userlastip}}
</div>
@@ -0,0 +1,254 @@
@block @block_myprofile
Feature: The logged in user block allows users to view their profile information
In order to enable the logged in user block
As a user
I can add the logged in user block and configure it to show my information
Scenario: Configure the logged in user block to show / hide the users country
Given the following "users" exist:
| username | firstname | lastname | email | country |
| teacher1 | Teacher | One | teacher1@example.com | AU |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display country | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "Australia" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display country | Yes |
And I press "Save changes"
And I should see "Australia" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users city
Given the following "users" exist:
| username | firstname | lastname | email | city |
| teacher1 | Teacher | One | teacher1@example.com | Perth |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display city | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "Perth" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display city | Yes |
And I press "Save changes"
And I should see "Perth" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users email
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display email | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "teacher1@example.com" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display email | Yes |
And I press "Save changes"
And I should see "teacher1@example.com" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users phone
Given the following "users" exist:
| username | firstname | lastname | email | phone1 |
| teacher1 | Teacher | One | teacher1@example.com | 555-5555 |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display phone | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "555-5555" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display phone | Yes |
And I press "Save changes"
And I should see "555-5555" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users mobile phone
Given the following "users" exist:
| username | firstname | lastname | email | phone2 |
| teacher1 | Teacher | One | teacher1@example.com | 555-5555 |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display mobile phone | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "555-5555" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display mobile phone | Yes |
And I press "Save changes"
And I should see "555-5555" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users Institution
Given the following "users" exist:
| username | firstname | lastname | email | institution |
| teacher1 | Teacher | One | teacher1@example.com | myinstitution |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display institution | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "myinstitution" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display institution | Yes |
And I press "Save changes"
And I should see "myinstitution" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users address
Given the following "users" exist:
| username | firstname | lastname | email | address |
| teacher1 | Teacher | One | teacher1@example.com | myaddress |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display address | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "myaddress" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display address | Yes |
And I press "Save changes"
And I should see "myaddress" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users first access
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display first access | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "First access:" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display first access | Yes |
And I press "Save changes"
And I should see "First access:" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users last access
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display last access | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "Last access:" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display last access | Yes |
And I press "Save changes"
And I should see "Last access:" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users current login
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display current login | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "Log in:" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display current login | Yes |
And I press "Save changes"
And I should see "Log in:" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users last ip
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display last IP | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "IP:" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display last IP | Yes |
And I press "Save changes"
And I should see "IP:" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users idnumber
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | One | teacher1@example.com | ID12345 |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display ID number | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "ID number:" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display ID number | Yes |
And I press "Save changes"
And I should see "ID number:" in the "Logged in user" "block"
Scenario: Configure the logged in user block to show / hide the users last login
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display last login | No |
And I press "Save changes"
Then I should see "Teacher One" in the "Logged in user" "block"
And I should not see "Last login:" in the "Logged in user" "block"
And I configure the "Logged in user" block
And I set the following fields to these values:
| Display last login | Yes |
And I press "Save changes"
And I log out
And I log in as "teacher1"
And I should see "Last login:" in the "Logged in user" "block"
@@ -0,0 +1,24 @@
@block @block_myprofile
Feature: The logged in user block allows users to view their profile information in an activity
In order to enable the logged in user block in an activity
As a teacher
I can add the logged in user block to an activity and view my information
Scenario: View the logged in user block by a user in an activity
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | One | teacher1@example.com | T1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | course | idnumber | name | intro |
| page | C1 | page1 | Test page name | Test page description |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| myprofile | Activity module | page1 | mod-page-* | side-pre |
When I am on the "Test page name" "page activity" page logged in as teacher1
Then I should see "Teacher One" in the "Logged in user" "block"
@@ -0,0 +1,20 @@
@block @block_myprofile
Feature: The logged in user block allows users to view their profile information in a course
In order to enable the logged in user block in a course
As a teacher
I can add the logged in user block to a course and view my information
Scenario: View the logged in user block by a user in a course
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | One | teacher1@example.com | T1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Logged in user" block
Then I should see "Teacher One" in the "Logged in user" "block"
@@ -0,0 +1,14 @@
@block @block_myprofile
Feature: The logged in user block allows users to view their profile information in on the dashboard
In order to enable the logged in user block on the dashboard
As a user
I can add the logged in user block to a the dashboard and view my information
Scenario: View the logged in user block by a user on the dashboard
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
And I log in as "teacher1"
And I turn editing mode on
When I add the "Logged in user" block
Then I should see "Teacher One" in the "Logged in user" "block"
@@ -0,0 +1,23 @@
@block @block_myprofile
Feature: The logged in user block allows users to view their profile information on the front page
In order to enable the logged in user block on the frontpage
As an admin
I can add the logged in user block to the frontpage and view my information
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | One | teacher1@example.com | T1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| myprofile | System | 1 | site-index | side-pre |
Scenario: Try to view the logged in user block as a guest
Given I log in as "guest"
When I am on site homepage
Then I should not see "Logged in user"
Scenario: View the logged in user block by a logged in user
Given I log in as "teacher1"
When I am on site homepage
Then I should see "Teacher One" in the "Logged in user" "block"
+30
View File
@@ -0,0 +1,30 @@
<?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/>.
/**
* Current user info block.
*
* @package block_myprofile
* @copyright 2010 Remote-Learner.net
* @author Olav Jordan <olav.jordan@remote-learner.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'block_myprofile'; // Full name of the plugin (used for diagnostics)