Lock the grade if needed. Make sure this is called only when final grades are valid
540930
public function check_locktime() {
        if (!empty($this->locked)) {
            return; // already locked
        }

        if ($this->locktime and $this->locktime < time()) {
            $this->locked = time();
            $this->update('locktime');
        }
    }
550032
protected synchronized void reset() {
		if (max == 0) {
			return;
		}
		for (int i = 0; i < timestamps.length; i++) {
			timestamps[i] = 0;
		}
		min = 0;
		max = 0;
		tested = 0;
		locked = false;
	}
148707
private void endWaitingForUsage() {
        synchronized (permanentUserReadWriteLock) {
            if (permissionWithoutUsageLimit != null)
                permissionWithoutUsageLimit = null;
            if (permissionWithoutUsageCloseThread != null) {
                permissionWithoutUsageCloseThread.cancel(true);
                permissionWithoutUsageLimit = null;
            }
        }
    }
155696
function() {
			if ( this.locked ) {
				// Decrease level of lock and check if equals 0, what means that undoM is completely unlocked.
				if ( !--this.locked.level ) {
					var update = this.locked.update;

					this.locked = null;

					// forceUpdate was passed to lock().
					if ( update === true )
						this.update();
					// update is instance of Image.
					else if ( update ) {
						var newImage = new Image( this.editor, true );

						if ( !update.equalsContent( newImage ) )
							this.update();
					}
				}
			}
		}
602266
public void unlockLastInode() {
    Preconditions.checkState(endsInInode());
    Preconditions.checkState(!mEntries.isEmpty());

    mLockedInodes.remove(mLockedInodes.size() - 1);
    mEntries.remove(mEntries.size() - 1).mLock.close();
    mLockMode = LockMode.READ;
  }
997889
@Override
    public void lock(Object entity, LockModeType lockMode)
    {
        ivEm.lock(entity, lockMode);
    }
312540
def _set_gradebook_view(self, session):
        """"""
        if self._gradebook_view == FEDERATED:
            try:
                session.use_federated_gradebook_view()
            except AttributeError:
                pass
        else:
            try:
                session.use_isolated_gradebook_view()
            except AttributeError:
                pass
1091120
private final Result lockForUpgradeInterruptibly_(L locker) throws InterruptedException {
        if (Thread.interrupted()) {
            throw new InterruptedException();
        }
        Result result;
        if ((result = tryLockForUpgrade_(locker)) == Result.FAILED) {
            result = lockForUpgradeQueuedInterruptibly(locker, addUpgradeWaiter());
        }
        return result;
    }
842866
public void locked (@Nonnull final Runnable aRunnable)
  {
    ValueEnforcer.notNull (aRunnable, "Runnable");

    lock ();
    try
    {
      aRunnable.run ();
    }
    finally
    {
      unlock ();
    }
  }
116058
private void unlock_data() {
    source.unlock(self());
    if( validation != null && source._key != null && validation._key != null && !source._key.equals(validation._key) )
      validation.unlock(self());
  }
962339
function lock(from, to) {
  from = fis.file.wrap(from).realpath;
  to = fis.file.wrap(to).realpath;

  lockedMap[to] = from;
}
1162295
def clear_score(self):
        
        if self._grade_system.is_based_on_grades():
            return  # do nothing, spec does not raise error
        if (self.get_score_metadata().is_read_only() or
                self.get_score_metadata().is_required()):
            raise errors.NoAccess()
        self._my_map['score'] = self._score_default
        self._my_map['gradingAgentId'] = ''
        self._my_map['timeGraded'] = None
605448
def on_lock(self, widget, data=None):
        """"""
        path_list = None
        if self.view is not None:
            model, path_list = self.tree_view.get_selection().get_selected_rows()
        models = [self.list_store[path][self.MODEL_STORAGE_ID] for path in path_list] if path_list else []
        if models:
            if len(models) > 1:
                self._logger.warning("Please select only one element to be locked.")
            try:
                self.model.global_variable_manager.lock_variable(models[0])
            except AttributeError as e:
                self._logger.warning("The respective core element of {1}.list_store couldn't be locked. -> {0}"
                                  "".format(e, self.__class__.__name__))
            return True
        else:
            self._logger.warning("Please select an element to be locked.")
983264
def use_isolated_gradebook_view(self):
        """"""
        self._gradebook_view = ISOLATED
        # self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked
        for session in self._get_provider_sessions():
            try:
                session.use_isolated_gradebook_view()
            except AttributeError:
                pass
1128193
private static void lockBoth(Lock sourceWriteLock, Lock destWriteLock) {
    while (true) {
      sourceWriteLock.lock();
      if (destWriteLock.tryLock()) {
        return;
      } else {
        sourceWriteLock.unlock();
      }

      destWriteLock.lock();
      if (sourceWriteLock.tryLock()) {
        return;
      } else {
        destWriteLock.unlock();
      }
    }
  }
1186290
private final Result lockForUpgrade_(L locker) {
        Result result;
        if ((result = tryLockForUpgrade_(locker)) == Result.FAILED) {
            result = lockForUpgradeQueued(locker, addUpgradeWaiter());
        }
        return result;
    }
1301778
public final void lockForReadInterruptibly(L locker) throws InterruptedException {
        if (Thread.interrupted()) {
            throw new InterruptedException();
        }
        if (!tryLockForRead(locker)) {
            lockForReadQueuedInterruptibly(locker, addReadWaiter());
        }
    }