Processes comments element data

@param array|stdClass $data The data to insert as a comment
765353
public function process_gradingform_guide_comment($data) {
        global $DB;

        $data = (object)$data;
        $data->definitionid = $this->get_new_parentid('grading_definition');

        $DB->insert_record('gradingform_guide_comments', $data);
    }
211132
protected function onRead($data)
    {
        if (!$this->remove || $this->autocomplete || $this->question->isHidden()) {
            return;
        }

        $this->output->captureUserInput($data);
    }
312772
public function process_essay($data) {
        global $DB;

        $data = (object)$data;
        $oldid = $data->id;

        if (!isset($data->responsetemplate)) {
            $data->responsetemplate = '';
        }
        if (!isset($data->responsetemplateformat)) {
            $data->responsetemplateformat = FORMAT_HTML;
        }
        if (!isset($data->responserequired)) {
            $data->responserequired = 1;
        }
        if (!isset($data->attachmentsrequired)) {
            $data->attachmentsrequired = 0;
        }

        // Detect if the question is created or mapped.
        $questioncreated = $this->get_mappingid('question_created',
                $this->get_old_parentid('question')) ? true : false;

        // If the question has been created by restore, we need to create its
        // qtype_essay too.
        if ($questioncreated) {
            $data->questionid = $this->get_new_parentid('question');
            $newitemid = $DB->insert_record('qtype_essay_options', $data);
            $this->set_mapping('qtype_essay', $oldid, $newitemid);
        }
    }
552793
public function process_gradinform_rubric_filling($data) {
        global $DB;

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

        if (!empty($data->criterionid)) {
            $DB->insert_record('gradingform_rubric_fillings', $data);
        }

    }
682589
public function processComment(File $phpcsFile, $stackPtr)
    {
        $tokens      = $phpcsFile->getTokens();
        $commentText = $tokens[$stackPtr]['content'];

        // Multi-line block comment.
        if (substr($commentText, 0, 2) !== '/*' || substr($commentText, -2) !== '*/') {
            return;
        }

        // Not a type comment.
        if ($this->isTypeComment($commentText) === false) {
            return;
        }

        // The "/**@var ...*/" comment isn't parsed as DocBlock and is fixed here.
        $error = 'Type comment must be in "/** %s ClassName $variable_name */" format';
        $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle', array(self::TYPE_TAG));
        if ($fix === true) {
            $phpcsFile->fixer->replaceToken($stackPtr, '/** '.trim($commentText, ' /*').' */');
        }
    }
59531
function class_export( $classname, array $commentData = array() ){
		echo 
		"/**\n * Auto-generated file containing class $classname";
		foreach( $commentData as $tag => $value ){
			echo "\n * @$tag $value";
		}
		echo 
		"\n */\n",
		"\n",
		"import('PLUG.parsing.LR.LRParseTable');\n",
		"\n",
		"/**\n * Auto-generated LRParseTable subclass";
		// unset page level doc block tags we don't want against the class
		unset (
			$commentData['author'], $commentData['version']
		);
		foreach( $commentData as $tag => $value ){
			echo "\n * @$tag $value";
		}
		echo 
		"\n */\n",
		"class $classname extends LRParseTable {\n",
		"\n",
		"/** @var array */\n",
		"protected \$table = ",var_export($this->table,1),";\n\n",
		"}\n";
	}
1025663
public function data_postprocessing($data) {
        parent::data_postprocessing($data);
        // Convert completionstatusrequired to a proper integer, if any.
        $total = 0;
        if (isset($data->completionstatusrequired) && is_array($data->completionstatusrequired)) {
            foreach (array_keys($data->completionstatusrequired) as $state) {
                $total |= $state;
            }
            $data->completionstatusrequired = $total;
        }

        if (!empty($data->completionunlocked)) {
            // Turn off completion settings if the checkboxes aren't ticked.
            $autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;

            if (!(isset($data->completionstatusrequired) && $autocompletion)) {
                $data->completionstatusrequired = null;
            }
            // Else do nothing: completionstatusrequired has been already converted
            //             into a correct integer representation.

            if (!empty($data->completionscoredisabled) || !$autocompletion) {
                $data->completionscorerequired = null;
            }
        }
    }
202622
private function _processComment($token) {
		// Count the lines of comment
		if ($token->id === T_COMMENT) {
			$this->_ncssTotalSingleComment ++;
			$this->_ncssFileSingleComment ++;
		} else if ($token->id === T_ML_COMMENT) {
			$this->_ncssTotalMultiComment ++;
			$this->_ncssFileMultiComment ++;
		} else if ($token->id === T_DOC_COMMENT) {
			$this->_ncssTotalPhpdoc ++;
			$this->_ncssFilePhpdoc ++;
			$this->_ncssTotalLinesPhpdoc ++;
			$this->_ncssFileLinesPhpdoc ++;
			if ($this->_isFileDocComment()) {
				$this->_processAnnotation(T_FILE, $token->text);
			}
		}

		// Count the @params, @returns and @throw
		if (stripos($token->text, '/**') !== false) {
			// Reset the count of elements if it's a new docblock
			$this->statementStack->getCurrentStackItem()->docblocNbParams = 0;
			$this->statementStack->getCurrentStackItem()->docblocNbReturns = 0;
			$this->statementStack->getCurrentStackItem()->docblocNbThrows = 0;
		}
		if (stripos($token->text, '@param') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbParams ++;
		}
		if (stripos($token->text, '@return') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbReturns ++;
		}
		if (stripos($token->text, '@throw') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbThrows ++;
		}
		if (stripos($token->text, '@inheritdoc') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocInheritDoc = true;
		}

		// Check if the comment starts with '#'
		if ($this->_isActive('noShellComments')) {
			$todoStr = strpos($token->text, '#');
			if ($todoStr === 0) {
				$this->_writeError('noShellComments', $this->_getMessage('NO_SHELL_COMMENTS'));
			}
		}

		// Check if the comment contains a TO DO
		$this->_processTODO($token);
	}
1076950
function appendComments(comments, ul) {
    $.each(comments, function() {
      var div = createCommentDiv(this);
      ul.append($(document.createElement('li')).html(div));
      appendComments(this.children, div.find('ul.comment-children'));
      // To avoid stagnating data, don't store the comments children in data.
      this.children = null;
      div.data('comment', this);
    });
  }
1091655
public function process($data) {
        $bulk = new bulk_insert($this->item);
        // Bulk insert messages the data to be passed in
        // ie: for all grades of empty grades apply the specified value.
        if ($bulk->is_applied($data)) {
            $filter = $bulk->get_type($data);
            $insertvalue = $bulk->get_insert_value($data);

            $userid = $this->item->id;
            foreach ($this->items as $gradeitemid => $gradeitem) {
                $null = $gradeitem->gradetype == GRADE_TYPE_SCALE ? -1 : '';
                $field = "finalgrade_{$gradeitem->id}_{$this->itemid}";
                if (isset($data->$field)) {
                    continue;
                }

                $oldfinalgradefield = "oldfinalgrade_{$gradeitem->id}_{$this->itemid}";
                // Bulk grade changes for all grades need to be processed and shouldn't be skipped if they had a previous grade.
                if ($gradeitem->is_course_item() || ($filter != 'all' && !empty($data->$oldfinalgradefield))) {
                    if ($gradeitem->is_course_item()) {
                        // The course total should not be overridden.
                        unset($data->$field);
                        unset($data->oldfinalgradefield);
                        $oldoverride = "oldoverride_{$gradeitem->id}_{$this->itemid}";
                        unset($data->$oldoverride);
                        $oldfeedback = "oldfeedback_{$gradeitem->id}_{$this->itemid}";
                        unset($data->$oldfeedback);
                    }
                    continue;
                }
                $grade = grade_grade::fetch(array(
                    'itemid' => $gradeitemid,
                    'userid' => $userid
                ));

                $data->$field = empty($grade) ? $null : $grade->finalgrade;
                $data->{"old$field"} = $data->$field;
            }

            foreach ($data as $varname => $value) {
                if (preg_match('/^oldoverride_(\d+)_(\d+)/', $varname, $matches)) {
                    // If we've selected overriding all grades.
                    if ($filter == 'all') {
                        $override = "override_{$matches[1]}_{$matches[2]}";
                        $data->$override = '1';
                    }
                }
                if (!preg_match('/^finalgrade_(\d+)_(\d+)/', $varname, $matches)) {
                    continue;
                }

                $gradeitem = grade_item::fetch(array(
                    'courseid' => $this->courseid,
                    'id' => $matches[1]
                ));

                $isscale = ($gradeitem->gradetype == GRADE_TYPE_SCALE);

                $empties = (trim($value) === '' or ($isscale and $value == -1));

                if ($filter == 'all' or $empties) {
                    $data->$varname = ($isscale and empty($insertvalue)) ?
                        -1 : $insertvalue;
                }
            }
        }
        return parent::process($data);
    }
754401
public function process($data) {
        $warnings = array();

        $fields = $this->definition();

        // Avoiding execution timeouts when updating
        // a large amount of grades.
        $progress = 0;
        $progressbar = new \core\progress\display_if_slow();
        $progressbar->start_html();
        $progressbar->start_progress(get_string('savegrades', 'gradereport_singleview'), count((array) $data) - 1);
        $changecount = array();
        // This array is used to determine if the override should be excluded from being counted as a change.
        $ignorevalues = [];

        foreach ($data as $varname => $throw) {
            $progressbar->progress($progress);
            $progress++;
            if (preg_match("/(\w+)_(\d+)_(\d+)/", $varname, $matches)) {
                $itemid = $matches[2];
                $userid = $matches[3];
            } else {
                continue;
            }

            $gradeitem = grade_item::fetch(array(
                'id' => $itemid, 'courseid' => $this->courseid
            ));

            if (preg_match('/^old[oe]{1}/', $varname)) {
                $elementname = preg_replace('/^old/', '', $varname);
                if (!isset($data->$elementname)) {
                    // Decrease the progress because we've increased the
                    // size of the array we are iterating through.
                    $progress--;
                    $data->$elementname = false;
                }
            }

            if (!in_array($matches[1], $fields)) {
                continue;
            }

            if (!$gradeitem) {
                continue;
            }

            $grade = $this->fetch_grade_or_default($gradeitem, $userid);

            $classname = '\\gradereport_singleview\\local\\ui\\' . $matches[1];
            $element = new $classname($grade);

            $name = $element->get_name();
            $oldname = "old$name";

            $posted = $data->$name;

            $format = $element->determine_format();

            if ($format->is_textbox() and trim($data->$name) === '') {
                $data->$name = null;
            }

            // Same value; skip.
            if (isset($data->$oldname) && $data->$oldname == $posted) {
                continue;
            }

            // If the user submits Exclude grade elements without the proper.
            // permissions then we should refuse to update.
            if ($matches[1] === 'exclude' && !has_capability('moodle/grade:manage', $this->context)){
                $warnings[] = get_string('nopermissions', 'error', get_string('grade:manage', 'role'));
                continue;
            }

            $msg = $element->set($posted);
            // Value to check against our list of matchelements to ignore.
            $check = explode('_', $varname, 2);

            // Optional type.
            if (!empty($msg)) {
                $warnings[] = $msg;
                if ($element instanceof \gradereport_singleview\local\ui\finalgrade) {
                    // Add this value to this list so that the override object that is coming next will also be skipped.
                    $ignorevalues[$check[1]] = $check[1];
                    // This item wasn't changed so don't add to the changecount.
                    continue;
                }
            }
            // Check to see if this value has already been skipped.
            if (array_key_exists($check[1], $ignorevalues)) {
                continue;
            }
            if (preg_match('/_(\d+)_(\d+)/', $varname, $matchelement)) {
                $changecount[$matchelement[0]] = 1;
            }
        }

        // Some post-processing.
        $eventdata = new stdClass;
        $eventdata->warnings = $warnings;
        $eventdata->post_data = $data;
        $eventdata->instance = $this;
        $eventdata->changecount = $changecount;

        $progressbar->end_html();

        return $eventdata;
    }
925355
public function populate(\stdClass $data)
    {
        $this->CodEmpresa = $data->codEmpresa;
        $this->CodIntegracaoContaCorrente = $data->codIntegracaoContaCorrente;
        $this->CodTipoMovto = $data->codTipoMovto;
        $this->DatMovimento = $data->datMovimento;
        $this->VlrMovimento = $data->vlrMovimento;
        $this->DscComplemento = $data->dscComplemento;
        $this->CodIntegracaoTipoMovtoCc = $data->codIntegracaoTipoMovtoCc;
        $this->CodIntegracaoMovtoCc = $data->codIntegracaoMovtoCc;
        $this->CodIntegracaoFilial = $data->codIntegracaoFilial;
    }
863157
static function processElementTransformationList( $tpl, &$node, $elements, &$privateData )
    {
        $useComments = $privateData['use-comments'];
        $php =& $privateData['php-creator'];
        $resourceData =& $privateData['resource-data'];
        $elementTree = $elements;
        $newElements = eZTemplateCompiler::processElementTransformationChild( $useComments, $php, $tpl, $node,
                                                                              $elementTree, $elements, $resourceData );
        if ( $newElements )
            return $newElements;
        return $elements;
    }
1322441
public function is_feedback_modified(stdClass $grade, stdClass $data) {
        $commenttext = '';
        if ($grade) {
            $feedbackcomments = $this->get_feedback_comments($grade->id);
            if ($feedbackcomments) {
                $commenttext = $feedbackcomments->commenttext;
            }
        }

        $formtext = $data->assignfeedbackcomments_editor['text'];

        // Need to convert the form text to use @@PLUGINFILE@@ and format it so we can compare it with what is stored in the DB.
        if (isset($data->assignfeedbackcomments_editor['itemid'])) {
            $formtext = file_rewrite_urls_to_pluginfile($formtext, $data->assignfeedbackcomments_editor['itemid']);
            $formtext = format_text($formtext, FORMAT_HTML);
        }

        if ($commenttext == $formtext) {
            return false;
        } else {
            return true;
        }
    }
231609
public function onInput($data)
    {
        //Process data here
        foreach ($this->params as $copy => $original) {
            $data[$copy] = $data[$original];
        }
        $this->next($data);
    }
815662
protected function add_field(\stdClass $data) {
        foreach ($data->fields as $field) {
            $this->_form->addElement($field);
        }

        if (!empty($data->helps)) {
            foreach ($data->helps as $fieldname => $helpdata) {
                $help = array_merge([$fieldname], $helpdata);
                call_user_func_array([$this->_form, 'addHelpButton'], $help);
            }
        }

        if (!empty($data->types)) {
            foreach ($data->types as $fieldname => $type) {
                $this->_form->setType($fieldname, $type);
            }
        }

        if (!empty($data->rules)) {
            foreach ($data->rules as $fieldname => $ruledata) {
                $rule = array_merge([$fieldname], $ruledata);
                call_user_func_array([$this->_form, 'addRule'], $rule);
            }
        }

        if (!empty($data->defaults)) {
            foreach ($data->defaults as $fieldname => $default) {
                $this->_form($fieldname, $default);
            }
        }
    }
761988
public void writeComment(final String data) throws SAXException {
        processStartElement();
        final char[] ch = data.toCharArray();
        transformer.comment(ch, 0, ch.length);
    }