Get the primary grade item for this assign instance.

@return grade_item The grade_item record
434433
public function get_grade_item() {
        if ($this->gradeitem) {
            return $this->gradeitem;
        }
        $instance = $this->get_instance();
        $params = array('itemtype' => 'mod',
                        'itemmodule' => 'assign',
                        'iteminstance' => $instance->id,
                        'courseid' => $instance->course,
                        'itemnumber' => 0);
        $this->gradeitem = grade_item::fetch($params);
        if (!$this->gradeitem) {
            throw new coding_exception('Improper use of the assignment class. ' .
                                       'Cannot load the grade item.');
        }
        return $this->gradeitem;
    }
382428
public function getChildren()
    {
		if (!$this->_children)
		{
			if ($this->getParam('iterator')) {
				$this->_children = $this->getParam('iterator');
			}
			else {
				try {
					$this->_children = $this->getCatalog()->getMaterials();
                    if ($this->getParam('order')) {
                        $this->_children->orderBy($this->getParam('order'), $this->getParam('sort'));
                    }
                    $this->_children->orderBy('id', 'ASC', true);
					if ($this->getParam('subfolders') || $this->getParam('subsections')) {
						$this->_children->subfolders();
					}
					if ($this->getParam('filter')) {
						list($filter) = explode(';',$this->getParam('filter'));
						eval('$this->_children->'.$filter.';');
					}
				}
				catch (\Exception $e) {
					return [];
				}					
			}
			if ($this->getParam('limit')) $this->_children->setItemCountPerPage($this->getParam('limit')); 
			if ($this->getParam('where')) $this->_children->where($this->getParam('where')); 
			$this->_children->setCurrentPageNumber( $this->getPage() ); 			
		}
		return $this->_children;
    }
842283
private function category($item) {
        global $DB;

        if (empty($item->categoryid)) {

            if ($item->itemtype == 'course') {
                return $this->course->fullname;
            }

            $params = array('id' => $item->iteminstance);
            $elem = $DB->get_record('grade_categories', $params);

            return $elem->fullname;
        }

        if (!isset($this->categories[$item->categoryid])) {
            $category = $item->get_parent_category();

            $this->categories[$category->id] = $category;
        }

        return $this->categories[$item->categoryid]->get_name();
    }
1175854
public Record getMainRecord()
    {
        Record record = null;
        if (this.size() > 0)
        {
            record = (Record)this.firstElement();
            if (record != null) if (record == this.getScreenRecord())
            {
                record = null;
                if (this.size() >= 2)
                    record = (Record)this.elementAt(1);
            }
        }
        return record;
    }
680177
protected function getPatchLevel()
    {
        if (isset($this->searchData['gpa_level']) && $this->searchData['gpa_level']) {
            return $this->searchData['gpa_level'];
        }

        return reset($this->patchLevels);
    }
729302
public function getPrimaryKey() {
        if ($this->primaryKey === null) {
            $schema = $this->getSchema();

            $pk = [];
            foreach ($schema->getSchemaArray()['properties'] as $column => $property) {
                if (!empty($property['primary'])) {
                    $pk[] = $column;
                }
            }
            $this->primaryKey = $pk;
        }
        return $this->primaryKey;
    }
1236477
public function get_label() {
        if (!isset($this->grade->label)) {
            $this->grade->label = '';
        }
        return $this->grade->label;
    }
936735
public function getGrade()
    {
        //Get the hidden value.
        $response = $this->buildGetRequest(self::ZF_GRADE_URI, [], $this->headers);
        $viewstate = $this->parserOthersHiddenValue($response->getBody());

        $post['__EVENTTARGET'] = '';
        $post['__EVENTARGUMENT'] = '';
        $post['__VIEWSTATE'] = $viewstate;
        $post['hidLanguage'] = '';
        $post['ddlXN'] = '';
        $post['ddlXQ'] = '';
        $post['ddl_kcxz'] = '';
        $post['btn_zcj'] = iconv('utf-8', 'gb2312', '历年成绩');

        $response = $this->buildPostRequest(self::ZF_GRADE_URI, [], $post, $this->headers);

        return $this->parserCommonTable($response->getBody(), '#Datagrid1');
    }
482935
public function getLevel()
    {
        if($this->level === null)
        {
            $this->level = count($this->getAncestors());
        }

        return $this->level;
    }
1251835
public function get_data() {
        $data = parent::get_data();
        if (!empty($data->saverubric)) {
            $data->status = gradingform_controller::DEFINITION_STATUS_READY;
        } else if (!empty($data->saverubricdraft)) {
            $data->status = gradingform_controller::DEFINITION_STATUS_DRAFT;
        }
        return $data;
    }
215913
protected function get_allgradeitems() {
        if (!empty($this->allgradeitems)) {
            return $this->allgradeitems;
        }
        $allgradeitems = grade_item::fetch_all(array('courseid' => $this->courseid));
        // But hang on - don't include ones which are set to not show the grade at all.
        $this->allgradeitems = array_filter($allgradeitems, function($item) {
            return $item->gradetype != GRADE_TYPE_NONE;
        });

        return $this->allgradeitems;
    }
759513
public function get_owning_activity() {
        global $DB;

        // Set some defaults.
        $result = new stdClass();
        $result->id = 0;

        if (empty($this->instance->parentcontextid)) {
            return $result;
        }
        $parentcontext = context::instance_by_id($this->instance->parentcontextid);
        if ($parentcontext->contextlevel != CONTEXT_MODULE) {
            return $result;
        }
        $cm = get_coursemodule_from_id($this->page->cm->modname, $parentcontext->instanceid);
        if (!$cm) {
            return $result;
        }
        // Get the grade_items id.
        $rec = $DB->get_record('grade_items', array('iteminstance' => $cm->instance, 'itemmodule' => $this->page->cm->modname));
        if (!$rec) {
            return $result;
        }
        // See if it is a gradable activity.
        if (($rec->gradetype != GRADE_TYPE_VALUE) && ($rec->gradetype != GRADE_TYPE_SCALE)) {
            return $result;
        }
        return $rec;
    }
13416
public function getSettingsRecord()
    {
        $record = $this->model
            ->where('item', $this->recordCode)
            ->remember(1440, $this->getCacheKey())
            ->first();

        return $record ?: null;
    }
628684
public function get_data() {
        if ($item = parent::get_data()) {
            if (!isset($item->dependvalue)) {
                $item->dependvalue = '';
            }
        }
        return $item;
    }
1076637
public function key()
    {
        if (($this->endItemIdx !== null) && isset($this->lastItems[$this->endItemIdx])) {
            return $this->lastItems[$this->endItemIdx][0];
        } else {
            if (isset($this->firstItems[$this->firstItemIdx])) {
                return $this->firstItems[$this->firstItemIdx][0];
            } else {
                return $this->extractValue($this->items->current(), $this->keyField);
            }
        }
    }
669632
public function getChildren()
    {
        uasort(
            $this->children,
            function (AdminMenuItem $first, AdminMenuItem $second) {
                if ($first->getPriority() <= $second->getPriority()) {
                    return 1;
                }

                return -1;
            }
        );

        return $this->children;
    }
526187
public function getItem()
    {
        $bib = Bib::make($this->client, $this->data->bib_data->mms_id);
        $holding = Holding::make($this->client, $bib, $this->data->holding_data->holding_id);

        return Item::make(
            $this->client,
            $bib,
            $holding,
            $this->data->item_data->pid
        )->init($this->data->item_data);
    }