Processes filling element data

@param array|stdClass $data The data to insert as a filling
186572
public function process_gradinform_guide_filling($data) {
        global $DB;

        $data = (object)$data;
        $data->instanceid = $this->get_new_parentid('grading_instance');
        $data->criterionid = $this->get_mappingid('gradingform_guide_criterion', $data->criterionid);

        $DB->insert_record('gradingform_guide_fillings', $data);
    }
896746
protected function onInput($data)
    {
        //Process data here
        foreach ($this->params as $cName => $cParams) {
            $value = null;
            foreach ($cParams as $cValue => $criteria) {
                $from = Utility::get($criteria, 0);
                $to = Utility::get($criteria, 1);
                if (($from == null || $from <= $data[$cName]) && ($to == null || $data[$cName] < $to)) {
                    $value = $cValue;
                }
            }
            $data[$cName] = ($value) ? $value : null;
        }
        $this->next($data);
    }
231609
public function onInput($data)
    {
        //Process data here
        foreach ($this->params as $copy => $original) {
            $data[$copy] = $data[$original];
        }
        $this->next($data);
    }
544824
public function process_data($data) {
        global $DB;
        $warnings = array();

        $separategroups = false;
        $mygroups       = array();
        if ($this->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $this->context)) {
            $separategroups = true;
            $mygroups = groups_get_user_groups($this->course->id);
            $mygroups = $mygroups[0]; // ignore groupings
            // reorder the groups fro better perf below
            $current = array_search($this->currentgroup, $mygroups);
            if ($current !== false) {
                unset($mygroups[$current]);
                array_unshift($mygroups, $this->currentgroup);
            }
        }
        $viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);

        // always initialize all arrays
        $queue = array();

        $this->load_users();
        $this->load_final_grades();

        // Were any changes made?
        $changedgrades = false;
        $timepageload = clean_param($data->timepageload, PARAM_INT);

        foreach ($data as $varname => $students) {

            $needsupdate = false;

            // skip, not a grade nor feedback
            if (strpos($varname, 'grade') === 0) {
                $datatype = 'grade';
            } else if (strpos($varname, 'feedback') === 0) {
                $datatype = 'feedback';
            } else {
                continue;
            }

            foreach ($students as $userid => $items) {
                $userid = clean_param($userid, PARAM_INT);
                foreach ($items as $itemid => $postedvalue) {
                    $itemid = clean_param($itemid, PARAM_INT);

                    // Was change requested?
                    $oldvalue = $this->grades[$userid][$itemid];
                    if ($datatype === 'grade') {
                        // If there was no grade and there still isn't
                        if (is_null($oldvalue->finalgrade) && $postedvalue == -1) {
                            // -1 means no grade
                            continue;
                        }

                        // If the grade item uses a custom scale
                        if (!empty($oldvalue->grade_item->scaleid)) {

                            if ((int)$oldvalue->finalgrade === (int)$postedvalue) {
                                continue;
                            }
                        } else {
                            // The grade item uses a numeric scale

                            // Format the finalgrade from the DB so that it matches the grade from the client
                            if ($postedvalue === format_float($oldvalue->finalgrade, $oldvalue->grade_item->get_decimals())) {
                                continue;
                            }
                        }

                        $changedgrades = true;

                    } else if ($datatype === 'feedback') {
                        // If quick grading is on, feedback needs to be compared without line breaks.
                        if ($this->get_pref('quickgrading')) {
                            $oldvalue->feedback = preg_replace("/\r\n|\r|\n/", "", $oldvalue->feedback);
                        }
                        if (($oldvalue->feedback === $postedvalue) or ($oldvalue->feedback === null and empty($postedvalue))) {
                            continue;
                        }
                    }

                    if (!$gradeitem = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$this->courseid))) {
                        print_error('invalidgradeitemid');
                    }

                    // Pre-process grade
                    if ($datatype == 'grade') {
                        $feedback = false;
                        $feedbackformat = false;
                        if ($gradeitem->gradetype == GRADE_TYPE_SCALE) {
                            if ($postedvalue == -1) { // -1 means no grade
                                $finalgrade = null;
                            } else {
                                $finalgrade = $postedvalue;
                            }
                        } else {
                            $finalgrade = unformat_float($postedvalue);
                        }

                        $errorstr = '';
                        $skip = false;

                        $dategraded = $oldvalue->get_dategraded();
                        if (!empty($dategraded) && $timepageload < $dategraded) {
                            // Warn if the grade was updated while we were editing this form.
                            $errorstr = 'gradewasmodifiedduringediting';
                            $skip = true;
                        } else if (!is_null($finalgrade)) {
                            // Warn if the grade is out of bounds.
                            $bounded = $gradeitem->bounded_grade($finalgrade);
                            if ($bounded > $finalgrade) {
                                $errorstr = 'lessthanmin';
                            } else if ($bounded < $finalgrade) {
                                $errorstr = 'morethanmax';
                            }
                        }

                        if ($errorstr) {
                            $userfields = 'id, ' . get_all_user_name_fields(true);
                            $user = $DB->get_record('user', array('id' => $userid), $userfields);
                            $gradestr = new stdClass();
                            $gradestr->username = fullname($user, $viewfullnames);
                            $gradestr->itemname = $gradeitem->get_name();
                            $warnings[] = get_string($errorstr, 'grades', $gradestr);
                            if ($skip) {
                                // Skipping the update of this grade it failed the tests above.
                                continue;
                            }
                        }

                    } else if ($datatype == 'feedback') {
                        $finalgrade = false;
                        $trimmed = trim($postedvalue);
                        if (empty($trimmed)) {
                             $feedback = null;
                        } else {
                             $feedback = $postedvalue;
                        }
                    }

                    // group access control
                    if ($separategroups) {
                        // note: we can not use $this->currentgroup because it would fail badly
                        //       when having two browser windows each with different group
                        $sharinggroup = false;
                        foreach ($mygroups as $groupid) {
                            if (groups_is_member($groupid, $userid)) {
                                $sharinggroup = true;
                                break;
                            }
                        }
                        if (!$sharinggroup) {
                            // either group membership changed or somebody is hacking grades of other group
                            $warnings[] = get_string('errorsavegrade', 'grades');
                            continue;
                        }
                    }

                    $gradeitem->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE);

                    // We can update feedback without reloading the grade item as it doesn't affect grade calculations
                    if ($datatype === 'feedback') {
                        $this->grades[$userid][$itemid]->feedback = $feedback;
                    }
                }
            }
        }

        if ($changedgrades) {
            // If a final grade was overriden reload grades so dependent grades like course total will be correct
            $this->grades = null;
        }

        return $warnings;
    }
203025
public function update($data) {
        global $DB;
        $currentgrade = $this->get_guide_filling();
        parent::update($data);

        foreach ($data['criteria'] as $criterionid => $record) {
            if (!array_key_exists($criterionid, $currentgrade['criteria'])) {
                $newrecord = array('instanceid' => $this->get_id(), 'criterionid' => $criterionid,
                    'score' => $record['score'], 'remarkformat' => FORMAT_MOODLE);
                if (isset($record['remark'])) {
                    $newrecord['remark'] = $record['remark'];
                }
                $DB->insert_record('gradingform_guide_fillings', $newrecord);
            } else {
                $newrecord = array('id' => $currentgrade['criteria'][$criterionid]['id']);
                foreach (array('score', 'remark'/*, 'remarkformat' TODO */) as $key) {
                    if (isset($record[$key]) && $currentgrade['criteria'][$criterionid][$key] != $record[$key]) {
                        $newrecord[$key] = $record[$key];
                    }
                }
                if (count($newrecord) > 1) {
                    $DB->update_record('gradingform_guide_fillings', $newrecord);
                }
            }
        }
        foreach ($currentgrade['criteria'] as $criterionid => $record) {
            if (!array_key_exists($criterionid, $data['criteria'])) {
                $DB->delete_records('gradingform_guide_fillings', array('id' => $record['id']));
            }
        }
        $this->get_guide_filling(true);
    }
529576
public function fillFromArray(array $data)
	{
		$data = $data + array(
				'style' 		=> null,
				'align' 		=> null,
				'alternate_text' 	=> null,
				'title' 		=> null,
				'description' 	=> null,

				'size_width' 	=> null,
				'size_name' 	=> null,
				'crop_top' 		=> null,
				'crop_left' 	=> null,
				'crop_width' 	=> null,
				'crop_height' 	=> null,

				'size_height' 	=> null,
			);

		$this->imageId = $data['id'];
		$this->align = $data['align'];
		$this->style = $data['style'];
		$this->alternateText = $data['alternate_text'];
		$this->title = $data['title'];
		$this->description = $data['description'];

		$this->sizeName = $data['size_name'];

		$this->setWidth($data['size_width']);
		$this->setHeight($data['size_height']);
		$this->setCropTop($data['crop_top']);
		$this->setCropLeft($data['crop_left']);
		$this->setCropWidth($data['crop_width']);
		$this->setCropHeight($data['crop_height']);
	}
911451
public function populate($data=array())
    {
    	foreach ($data as $k=>$v)
    	{
    		// Promise that if this is a new record, we aren't handling any end-user data for $data
    		if ($this->isNewRecord)
    			$this->$k = $v;
    		else
    		{
	    		if(isset($this->attributes[$k]))
	    			$this->$k = $v;
	    	}
    	}

    	return $this->attributes;
    }
930585
protected function onInput($data)
    {
        //Process data here
        foreach ($this->params as $column) {
            if ($this->character_mask) {
                $data[$column] = trim($data[$column], $this->character_mask);
            } else {
                $data[$column] = trim($data[$column]);
            }
        }
        $this->next($data);
    }
308768
public function populate($data = array())
    {
        if (isset($data['code']) && $data['code'] != null) {
            $this->code = $data['code'];
        }
         
        if (isset($data['label']) && $data['label'] != null) {
            $this->label = $data['label'];
        }
         
        if (isset($data['definition']) && $data['definition'] != null) {
            $this->definition = $data['definition'];
        }
        
        if (isset($data['parent']) && $data['parent'] != null) {
            $this->parent = $data['parent'];
        }
    }
600856
public function populate(\stdClass $data)
    {
        $this->CodEmpresa = $data->codEmpresa;
        $this->NumCnpj = $data->numCnpj;
        $this->RazaoSocial = $data->razaoSocial;
        $this->NomFantasia = $data->nomFantasia;
        $this->NumInscricaoEstadual = (isset($data->numInscricaoEstadual)) ? $data->numInscricaoEstadual : null;
        $this->NumInscricaoMunicipal = (isset($data->numInscricaoMunicipal)) ? $data->numInscricaoMunicipal : null;
        $this->NomLogradouro = (isset($data->nomLogradouro)) ? $data->nomLogradouro : null;
        $this->NumLogradouro = (isset($data->numLogradouro)) ? $data->numLogradouro : null;
        $this->DscComplemento = (isset($data->dscComplemento)) ? $data->dscComplemento : null;
        $this->NomBairro = (isset($data->nomBairro)) ? $data->nomBairro : null;
        $this->NomLocalidade = (isset($data->nomLocalidade)) ? $data->nomLocalidade : null;
        $this->SglPais = (isset($data->sglPais)) ? $data->sglPais : null;
        $this->SglUF = (isset($data->sglUf)) ? $data->sglUf : null;
        $this->NumCep = (isset($data->numCep)) ? $data->numCep : null;
        $this->NumDDD = (isset($data->numDdd)) ? $data->numDdd : null;
        $this->NumTelefone = (isset($data->numTelefone)) ? $data->numTelefone : null;
        $this->DscEmail = (isset($data->dscEmail)) ? $data->dscEmail : null;

        if (isset($data->dadosBancarios)) {
            $this->DadosBancarios = new Banco(
                $data->dadosBancarios->nomFavorecido,
                $data->dadosBancarios->numCpfCnpjFavorecido,
                $data->dadosBancarios->numBanco,
                $data->dadosBancarios->numAgencia,
                $data->dadosBancarios->numContaCorrente,
                $data->dadosBancarios->numDigitoContaCorrente
            );
        }
    }
853177
public function setData($data = array())
    {
        

    	//empty local data
    	$this->rows = array();
    	//fill the local data
		foreach($data as $rowId => $cells){
			if(is_array($cells)){
				$this->addRow($rowId, $cells);
			}else if(is_string($cells)){
				$this->addRow($cells);
			}
		}

        
    }
626483
public function addData($data) : void
    {
        Assert::isInstanceOfAny($data, [Chunk::class, X509Certificate::class]);
        $this->data[] = $data;
    }
54504
public function populate($data = array())
    {
        $this->question = (isset($data['question'])) ? $data['question'] : null;
        $this->answer = (isset($data['answer'])) ? $data['answer'] : null;
        $this->isActive = (isset($data['isActive'])) ? $data['isActive'] : 0;
        $this->position = (isset($data['position'])) ? $data['position'] : 0;
    }
479857
public function fill(array $data)
    {
        if (empty($data['url']) || !is_string($data['url']) || strpos($data['url'], $this->browser->getHost()) !== 0) {
            return;
        }

        $dom = $this->browser->getDom(substr($data['url'], strlen($this->browser->getHost())));
        if (!($dom instanceof \DOMDocument)) {
            return;
        }
        $xpath = new \DOMXPath($dom);
        $nodes = $xpath->query(self::XPATH_FOR_FILL);

        // get item type
        if (!($type = $this->getItemType($data['url']))) {
            return;
        }

        /* @var $body \DOMElement */
        if (!($body = $nodes->item(5))) {
            throw new \LogicException('Incorrect data structure at source');
        }

        // item id from source
        $id = 0;
        if (preg_match('/id=(?<id>\d+)/', $data['url'], $mat)) {
            $id = (int) $mat['id'];
        }

        $item = new Item();

        // add source link on world-art
        $item->addSource((new Source())->setUrl($data['url']));

        // add other source links
        /* @var $links \DOMNodeList */
        $links = $xpath->query('a', $nodes->item(1));
        for ($i = 0; $i < $links->length; ++$i) {
            $link = $this->getAttrAsArray($links->item($i));
            if (strpos($link['href'], 'http://') !== false &&
                strpos($link['href'], $this->browser->getHost()) === false
            ) {
                $item->addSource((new Source())->setUrl($link['href']));
            }
        }

        // add cover
        $this->setCover($item, $id, $type);

        // fill item studio
        if ($studio = $this->getStudio($xpath, $body)) {
            $item->setStudio($studio);
        }

        // fill main data
        if ($type == self::ITEM_TYPE_ANIMATION) {
            $head = $xpath->query('table[3]/tr[2]/td[3]', $body);
            if (!$head->length) {
                $head = $xpath->query('table[2]/tr[1]/td[3]', $body);
            }
        } else {
            $head = $xpath->query('table[3]/tr[1]/td[3]', $body);
        }

        if ($head->length) {
            switch ($type) {
                case self::ITEM_TYPE_ANIMATION:
                    $this->fillAnimationNames($item, $xpath, $head->item(0));
                    break;
                default:
                    $this->fillCinemaNames($item, $xpath, $head->item(0));
            }
        }
        $this->fillHeadData($item, $xpath, $head->item(0));

        // fill body data
        $this->fillBodyData($item, $xpath, $body, $id, !empty($data['frames']), $type);

        return $item;
    }
378536
private function setData(array $data)
    {
        $_documentClass = $this->_documentClass;
        $_edgeClass = $this->_edgeClass;

        if (isset($this->_options[self::ENTRY_FLAT]) && $this->_options[self::ENTRY_FLAT]) {
            $this->_result = $data;
        } else {
            $this->_result = [];

            if ($this->_options[self::ENTRY_TYPE] === Collection::TYPE_EDGE) {
                foreach ($data as $row) {
                    $this->_result[] = $_edgeClass::createFromArray($row, $this->_options);
                }
            } else {
                foreach ($data as $row) {
                    $this->_result[] = $_documentClass::createFromArray($row, $this->_options);
                }
            }
        }
    }
183322
public function populate($data = array())
    {
        $this->appId = (isset($data['appId'])) ? $data['appId'] : null;
        $this->appSecret = (isset($data['appSecret'])) ? $data['appSecret'] : null;

    }
976481
public function populate($data = array())
    {
        if (isset($data['title']) && $data['title'] != null) {
            $this->title = $data['title'];
        }

        if (isset($data['subtitle']) && $data['subtitle'] != null) {
            $this->subtitle = $data['subtitle'];
        }

        if (isset($data['active']) && $data['active'] != null) {
            $this->active = $data['active'];
        }
    }