Lock the grade if needed. Make sure this is called only when final grades are valid

@param array $items array of all grade item ids
@return void
339397
public static function check_locktime_all($items) {
        global $CFG, $DB;

        $now = time(); // no rounding needed, this is not supposed to be called every 10 seconds
        list($usql, $params) = $DB->get_in_or_equal($items);
        $params[] = $now;
        $rs = $DB->get_recordset_select('grade_grades', "itemid $usql AND locked = 0 AND locktime > 0 AND locktime < ?", $params);
        foreach ($rs as $grade) {
            $grade_grade = new grade_grade($grade, false);
            $grade_grade->locked = time();
            $grade_grade->update('locktime');
        }
        $rs->close();
    }
922814
public function setEnabledLevels(array $levels)
    {
        $enabledLevels = array();

        foreach ($levels as $value) {
            if ($this->validLevel($value)) {
                array_push($enabledLevels, $value);
            }
        }

        $this->_enabledLevels = $enabledLevels;
    }
938308
public function assign(array $items): bool
    {
        foreach ($items as $name) {
            $item = $this->manager->getRole($name);
            $item = $item ?: $this->manager->getPermission($name);
            $this->manager->assign($item, $this->userId);
        }

        return true;
    }
608691
protected function processItems(array $items)
    {
        $processedItems = [];

        foreach ($items as $entry) {
            if (isset($entry['metadata']) && is_array($entry['metadata'])) {
                $processedItems[] = new SearchResult($entry);
            }
        }

        $this->items = new ModelCollection($processedItems);
    }
1197095
public function check(array $items, array $rules)
    {
        $this->_items = $items;
        foreach ($items as $item => $value) {
            if (array_key_exists($item, $rules)) {
                $this->validate($item, $value, $rules[$item]);
            }
        }
        
        return $this;
    }
1050743
public function is_locked() {
        $this->load_grade_item();
        if (empty($this->grade_item)) {
            return !empty($this->locked);
        } else {
            return !empty($this->locked) or $this->grade_item->is_locked();
        }
    }
1351738
public function setObjects(array $objects)
    {
        foreach ($objects as $object) {
            $this->checkType(ObjectDataInterface::class, $object);
        }

        $this->objects = $objects;
    }
497361
public function setItems($items)
    {
        $this->items = array();

        foreach ($items as $item) {
            $this->addItem($item);
        }

        return $this;
    }
716429
public function remove($item)
    {
        $renumberKeys = false;
        foreach ($this->items as $key => $value) {
            if ($item === $value) {
                $renumberKeys = true;
                unset($this->items[$key]);
            }
        }
        if ($renumberKeys) {
            $this->items = array_values($this->items);
        }
    }
200694
protected function add(array $items)
    {
        array_walk($items, function ($value, string $key) {
            add_theme_support($key, $value);
        });
    }
544939
public function add(array $items, $allowNumericitem = false)
    {
        foreach ($items as $item => $_deps) {
            if (! $allowNumericitem and is_int($item)) {
                $this->addItem($_deps);
            } else {
                $this->addItem($item, $_deps);
            }
        }
    }
684178
public function setChildren(array $children)
    {
        foreach ($children as $child) {
            $this->checkType(ObjectInFolderContainerInterface::class, $child);
        }

        $this->children = $children;
    }
540839
public function setItems(iterable $items): void
    {
        if ($items instanceof ItemList) {
            $this->items = clone $items;
        } else {
            $this->items = new ItemList();
            foreach ($items as $item) {
                $this->items->insert($item);
            }
        }
    }
1334808
function save( array $items ) {

		foreach ( $items as $item ) {
			if ( isset( $item['blogs_id'] ) ) {
				$this->saveBook( $this->userId, $item );
			}
		}
	}
652779
public function setItems(array $items)
    {
        $this->items = $items;
        $this->names = array_keys($items);

        return $this;
    }
1115986
public function setLevel($level)
    {
        parent::setLevel($level);

        foreach ($this->items as $item) {
            $item->setLevel($level + 1);
        }
    }
1258251
public function add($items = [])
    {
        if (!is_array($items) || func_num_args() > 1) {
            $items = func_get_args();
        }

        $this->push($this->formatInnerField(null, $items));
    }