See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * User profile set indicator. 19 * 20 * @package core_user 21 * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_user\analytics\indicator; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 /** 30 * User profile set indicator. 31 * 32 * @package core_user 33 * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class user_profile_set extends \core_analytics\local\indicator\linear { 37 38 /** 39 * Returns the name. 40 * 41 * If there is a corresponding '_help' string this will be shown as well. 42 * 43 * @return \lang_string 44 */ 45 public static function get_name() : \lang_string { 46 return new \lang_string('indicator:completeduserprofile'); 47 } 48 49 /** 50 * required_sample_data 51 * 52 * @return string[] 53 */ 54 public static function required_sample_data() { 55 return array('user'); 56 } 57 58 /** 59 * calculate_sample 60 * 61 * @param int $sampleid 62 * @param string $sampleorigin 63 * @param int $starttime 64 * @param int $endtime 65 * @return float 66 */ 67 protected function calculate_sample($sampleid, $sampleorigin, $starttime = false, $endtime = false) { 68 global $CFG; 69 70 $user = $this->retrieve('user', $sampleid); 71 72 // Nothing set results in -1. 73 $calculatedvalue = self::MIN_VALUE; 74 75 $sitepolicymanager = new \core_privacy\local\sitepolicy\manager(); 76 if ($sitepolicymanager->is_defined() && !$user->policyagreed) { 77 return self::MIN_VALUE; 78 } 79 80 if (!$user->confirmed) { 81 return self::MIN_VALUE; 82 } 83 84 if ($user->description != '') { 85 $calculatedvalue += 1; 86 } 87 88 if ($user->picture != '') { 89 $calculatedvalue += 1; 90 } 91 92 // 0.2 for any of the following fields being set (some of them may even be compulsory or have a default). 93 $fields = array('institution', 'department', 'address', 'city', 'country', 'url'); 94 foreach ($fields as $fieldname) { 95 if ($user->{$fieldname} != '') { 96 $calculatedvalue += 0.2; 97 } 98 } 99 100 return $this->limit_value($calculatedvalue); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body