60 $this->exc_id = $this->exc->getId();
65 $this->lng = (is_null(
$lng))
77 public function canBeActivated()
81 if ($ass->getPeerReview() || $ass->getAssignmentType()->usesTeams()) {
85 return !$this->hasAnySubmission();
93 public function getDeniedActivationReasons()
96 $lng->loadLanguageModule(
"exc");
97 $has_peer_reviews =
false;
101 if ($ass->getPeerReview()) {
102 $has_peer_reviews =
true;
104 if ($ass->getAssignmentType()->usesTeams()) {
109 if ($this->hasAnySubmission()) {
112 if ($has_peer_reviews) {
128 return !$this->hasAnySubmission();
139 $lng->loadLanguageModule(
"exc");
141 if ($this->hasAnySubmission()) {
174 return $this->exc->getNrMandatoryRandom();
180 protected function hasAnySubmission()
185 if ($this->submission_repo->hasSubmissions($ass->getId())) {
199 $ass_of_user = $this->rand_ass_repo->getAssignmentsOfUser($this->
user->getId(), $this->exc_id);
200 if (count($ass_of_user) == 0) {
215 return $this->rand_ass_repo->getAssignmentsOfUser($user_id, $this->exc_id);
225 $this->rand_ass_repo->saveAssignmentsOfUser(
226 $this->
user->getId(),
228 $this->getAssignmentSelection()
238 $ass_ids = array_map(
function (
$i) {
244 $j = rand(0, count($ass_ids) - 1);
245 $selected[] = current(array_splice($ass_ids, $j, 1));
An exception for terminatinating execution or to throw for unit testing.
static getInstancesByExercise($a_exc_id)
Stores info about random assignments for users in exercises.
Manages random mandatory assignments of an exercise.
getDeniedDeactivationReasons()
Get reasons for denied deactivation.
canBeDeactivated()
Checks if the random assignment can be activated (if no learner has already submitted stuff)
__construct(ilObjExercise $exc, ilExcRandomAssignmentDBRepository $rand_ass_repo, ilObjUser $user=null, ilLanguage $lng=null)
Constructor.
startExercise()
Start exercise.
isActivated()
Is random assignment activated?
getAssignmentSelection()
Get random assignment selection.
getTotalNumberOfAssignments()
Get total number of assignments.
needsStart()
Needs current user to start the exercise (by selecting the random assignments)?
getMandatoryAssignmentsOfUser($user_id)
Get mandatory assignments of user.
getNumberOfMandatoryAssignments()
Get total number of mandatory assignments.
const DENIED_TEAM_ASSIGNMENTS
isAssignmentVisible(int $ass_id, int $user_id)
Is assignment visible for user.
const DENIED_PEER_REVIEWS