Return any files this plugin wishes to save to the gradebook.

@param stdClass $grade The assign_grades object from the db
@return array
970427
public function files_for_gradebook(stdClass $grade) : array {
        return [
            'contextid' => $this->assignment->get_context()->id,
            'component' => ASSIGNFEEDBACK_COMMENTS_COMPONENT,
            'filearea' => ASSIGNFEEDBACK_COMMENTS_FILEAREA,
            'itemid' => $grade->id
        ];
    }
346030
public function update_file_count($grade) {
        global $DB;

        $filefeedback = $this->get_file_feedback($grade->id);
        if ($filefeedback) {
            $filefeedback->numfiles = $this->count_files($grade->id, ASSIGNFEEDBACK_FILE_FILEAREA);
            return $DB->update_record('assignfeedback_file', $filefeedback);
        } else {
            $filefeedback = new stdClass();
            $filefeedback->numfiles = $this->count_files($grade->id, ASSIGNFEEDBACK_FILE_FILEAREA);
            $filefeedback->grade = $grade->id;
            $filefeedback->assignment = $this->assignment->get_instance()->id;
            return $DB->insert_record('assignfeedback_file', $filefeedback) > 0;
        }
    }
489926
private function getFiles($path)
    {
        $files = array();

        foreach (new \DirectoryIterator($path) as $file) {
            if ($file->isDot()
                || (null != $this->scriptName && sprintf('%s.php', $this->scriptName) != $file->getFilename())
            ) {
                continue;
            }

            $files[$file->getFilename()] = sprintf('%s/%s', $file->getPath(), $file->getFilename());
        }
        sort($files);

        return $files;
    }
215337
public function load_final_grades() {
        global $CFG, $DB;

        if (!empty($this->grades)) {
            return;
        }

        if (empty($this->users)) {
            return;
        }

        // please note that we must fetch all grade_grades fields if we want to construct grade_grade object from it!
        $params = array_merge(array('courseid'=>$this->courseid), $this->userselect_params);
        $sql = "SELECT g.*
                  FROM {grade_items} gi,
                       {grade_grades} g
                 WHERE g.itemid = gi.id AND gi.courseid = :courseid {$this->userselect}";

        $userids = array_keys($this->users);
        $allgradeitems = $this->get_allgradeitems();

        if ($grades = $DB->get_records_sql($sql, $params)) {
            foreach ($grades as $graderec) {
                $grade = new grade_grade($graderec, false);
                if (!empty($allgradeitems[$graderec->itemid])) {
                    // Note: Filter out grades which have a grade type of GRADE_TYPE_NONE.
                    // Only grades without this type are present in $allgradeitems.
                    $this->allgrades[$graderec->userid][$graderec->itemid] = $grade;
                }
                if (in_array($graderec->userid, $userids) and array_key_exists($graderec->itemid, $this->gtree->get_items())) { // some items may not be present!!
                    $this->grades[$graderec->userid][$graderec->itemid] = $grade;
                    $this->grades[$graderec->userid][$graderec->itemid]->grade_item = $this->gtree->get_item($graderec->itemid); // db caching
                }
            }
        }

        // prefil grades that do not exist yet
        foreach ($userids as $userid) {
            foreach ($this->gtree->get_items() as $itemid => $unused) {
                if (!isset($this->grades[$userid][$itemid])) {
                    $this->grades[$userid][$itemid] = new grade_grade();
                    $this->grades[$userid][$itemid]->itemid = $itemid;
                    $this->grades[$userid][$itemid]->userid = $userid;
                    $this->grades[$userid][$itemid]->grade_item = $this->gtree->get_item($itemid); // db caching

                    $this->allgrades[$userid][$itemid] = $this->grades[$userid][$itemid];
                }
            }
        }

        // Pre fill grades for any remaining items which might be collapsed.
        foreach ($userids as $userid) {
            foreach ($allgradeitems as $itemid => $gradeitem) {
                if (!isset($this->allgrades[$userid][$itemid])) {
                    $this->allgrades[$userid][$itemid] = new grade_grade();
                    $this->allgrades[$userid][$itemid]->itemid = $itemid;
                    $this->allgrades[$userid][$itemid]->userid = $userid;
                    $this->allgrades[$userid][$itemid]->grade_item = $gradeitem;
                }
            }
        }
    }
567469
public function get_grade_item() {
        if (empty($this->id)) {
            debugging("Attempt to obtain a grade_category's associated grade_item without the category's ID being set.");
            return false;
        }

        if (empty($this->parent)) {
            $params = array('courseid'=>$this->courseid, 'itemtype'=>'course', 'iteminstance'=>$this->id);

        } else {
            $params = array('courseid'=>$this->courseid, 'itemtype'=>'category', 'iteminstance'=>$this->id);
        }

        if (!$grade_items = grade_item::fetch_all($params)) {
            // create a new one
            $grade_item = new grade_item($params, false);
            $grade_item->gradetype = GRADE_TYPE_VALUE;
            $grade_item->insert('system');

        } else if (count($grade_items) == 1) {
            // found existing one
            $grade_item = reset($grade_items);

        } else {
            debugging("Found more than one grade_item attached to category id:".$this->id);
            // return first one
            $grade_item = reset($grade_items);
        }

        return $grade_item;
    }
73431
protected function getPhpFiles($path)
    {
        if (is_dir($path)) {
            return new RegexIterator(
                new RecursiveIteratorIterator(
                    new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
                    RecursiveIteratorIterator::SELF_FIRST,
                    RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
                ),
                '/^.+\.php$/i',
                RecursiveRegexIterator::GET_MATCH
            );
        }
        else {
            return [];
        }
    }
268236
protected static function export_grade_data(\stdClass $grade, \context $context, array $currentpath) {
        $gradedata = (object)[
            'timecreated' => transform::datetime($grade->timecreated),
            'timemodified' => transform::datetime($grade->timemodified),
            'grader' => transform::user($grade->grader),
            'grade' => $grade->grade,
            'attemptnumber' => ($grade->attemptnumber + 1)
        ];
        writer::with_context($context)
                ->export_data(array_merge($currentpath, [get_string('privacy:gradepath', 'mod_assign')]), $gradedata);
    }
34265
private function getData(string $file): array
  {
    static $RESULT_STOP_WORDS_CACHE = array();

    if (isset($RESULT_STOP_WORDS_CACHE[$file])) {
      return $RESULT_STOP_WORDS_CACHE[$file];
    }

    $file = __DIR__ . '/stopwords/' . $file . '.php';
    if (file_exists($file)) {
      /** @noinspection PhpIncludeInspection */
      $RESULT_STOP_WORDS_CACHE[$file] = require $file;
    } else {
      $RESULT_STOP_WORDS_CACHE[$file] = array();
    }

    return $RESULT_STOP_WORDS_CACHE[$file];
  }
780664
public function findFile($class)
    {
        return $this->finder->findFile($class, $this->prefixPaths, $this->basePaths, $this->useIncludePath);
    }
1001386
public function get_grade() {
        $grade = $this->get_guide_filling();

        if (!($scores = $this->get_controller()->get_min_max_score()) || $scores['maxscore'] <= $scores['minscore']) {
            return -1;
        }

        $graderange = array_keys($this->get_controller()->get_grade_range());
        if (empty($graderange)) {
            return -1;
        }
        sort($graderange);
        $mingrade = $graderange[0];
        $maxgrade = $graderange[count($graderange) - 1];

        $curscore = 0;
        foreach ($grade['criteria'] as $record) {
            $curscore += $record['score'];
        }
        $gradeoffset = ($curscore-$scores['minscore'])/($scores['maxscore']-$scores['minscore'])*
            ($maxgrade-$mingrade);
        if ($this->get_controller()->get_allow_grade_decimals()) {
            return $gradeoffset + $mingrade;
        }
        return round($gradeoffset, 0) + $mingrade;
    }
128873
public function findClasses($directory)
    {
        $classes = [];
        foreach (Finder::create()->in($directory)->name('*.php') as $file) {
            $classes[] = $this->findClass($file->getRealPath());
        }
        return array_filter($classes);
    }
151161
public function getDivision($division): ?array
    {
        return ! empty($this->getDivisions()) && isset($this->getDivisions()[$division])
            ? $this->getDivisions()[$division] : null;
    }
201399
public function getAllPClasses()
    {
        if (!$this->pclasses) {
            $this->pclasses = $this->getPCStorage();
            $this->pclasses->load($this->pcURI);
        }
        return $this->pclasses->getAllPClasses();
    }
122081
public function is_empty(stdClass $grade) {
        global $DB;

        $comments = $DB->count_records('assignfeedback_editpdf_cmnt', array('gradeid'=>$grade->id, 'draft'=>0));
        $annotations = $DB->count_records('assignfeedback_editpdf_annot', array('gradeid'=>$grade->id, 'draft'=>0));
        return $comments == 0 && $annotations == 0;
    }
244349
public static function create_from_grade(\assign $assign, \stdClass $grade) {
        $data = array(
            'objectid' => $grade->id,
            'relateduserid' => $grade->userid,
            'context' => $assign->get_context(),
            'other' => array(
                'assignid' => $assign->get_instance()->id,
            ),
        );
        /** @var feedback_viewed $event */
        $event = self::create($data);
        $event->set_assign($assign);
        $event->add_record_snapshot('assign_grades', $grade);
        return $event;
    }
1327460
private function getFiles(): array
	{
		$result = [];
		$files = Finder::find('*')
			->in($this->getFullPath());
		foreach ($files as $file) {
			$result[] = new FileInfo($file);
		}
		usort($result, function ($a, $b) {
			if ($a->isDir == $b->isDir) {
				return strcmp($a->name, $b->name);
			} else {
				if ($a->isDir) {
					return -1;
				} else {
					return 1;
				}
			}
		});
		return $result;
	}
1353331
public function getStagedFiles()
    {
        $base = $this->getProjectBase();

        $files = new FileCollection();

        foreach ($this->getFiles() as $file) {
            $fileData = explode("\t", $file);
            $status = reset($fileData);
            $relativePath = end($fileData);

            $fullPath = rtrim($base . DIRECTORY_SEPARATOR . $relativePath);

            $file = new File($status, $fullPath, $base);
            $this->saveFileToCache($file);
            $files->append($file);
        }

        return $files;
    }