ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.RandomAssignmentsDBRepository.php
Go to the documentation of this file.
1<?php
2
20
22
28{
29 protected \ilDBInterface $db;
31
32 public function __construct(
35 ) {
36 $this->db = $db;
37 $this->data = $data;
38 }
39
47 public function getAssignmentsOfUser(
48 int $user_id,
49 int $exc_id
50 ): array {
51 $db = $this->db;
52
53 $set = $db->queryF(
54 "SELECT * FROM exc_mandatory_random " .
55 " WHERE usr_id = %s " .
56 " AND exc_id = %s ",
57 array("integer", "integer"),
58 array($user_id, $exc_id)
59 );
60 $ass_ids = [];
61 while ($rec = $db->fetchAssoc($set)) {
62 if (\ilExAssignment::isInExercise($rec["ass_id"], $exc_id)) {
63 $ass_ids[] = $rec["ass_id"];
64 }
65 }
66 return $ass_ids;
67 }
68
76 public function saveAssignmentsOfUser(
77 int $user_id,
78 int $exc_id,
79 array $ass_ids
80 ): void {
81 $db = $this->db;
82
83 $db->manipulateF(
84 "DELETE FROM exc_mandatory_random WHERE " .
85 " exc_id = %s" .
86 " AND usr_id = %s",
87 array("integer", "integer"),
88 array($exc_id, $user_id)
89 );
90
91 foreach ($ass_ids as $ass_id) {
93 $db->replace("exc_mandatory_random", array( // pk
94 "usr_id" => array("integer", $user_id),
95 "exc_id" => array("integer", $exc_id),
96 "ass_id" => array("integer", $ass_id)
97 ), []);
98 }
99 }
100 }
101}
Stores info about random assignments for users in exercises.
getAssignmentsOfUser(int $user_id, int $exc_id)
Get mandatory assignments of user.
saveAssignmentsOfUser(int $user_id, int $exc_id, array $ass_ids)
Save assignments of user.
Internal factory for data objects.
static isInExercise(int $a_ass_id, int $a_ex_id)
Interface ilDBInterface.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...