ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExcRandomAssignmentDBRepository Class Reference

Stores info about random assignments for users in exercises. More...

+ Collaboration diagram for ilExcRandomAssignmentDBRepository:

Public Member Functions

 __construct (ilDBInterface $db=null)
 Constructor. More...
 
 getAssignmentsOfUser (int $user_id, int $exc_id)
 Get mandatory assignments of user. More...
 
 saveAssignmentsOfUser (int $user_id, int $exc_id, array $ass_ids)
 Save assignments of user. More...
 

Protected Attributes

 $db
 

Detailed Description

Stores info about random assignments for users in exercises.

(repository)

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 12 of file class.ilExcRandomAssignmentDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilExcRandomAssignmentDBRepository::__construct ( ilDBInterface  $db = null)

Constructor.

Definition at line 23 of file class.ilExcRandomAssignmentDBRepository.php.

References $db, and $DIC.

24  {
25  global $DIC;
26 
27  $this->db = (is_null($db))
28  ? $DIC->database()
29  : $db;
30  }
$DIC
Definition: xapitoken.php:46

Member Function Documentation

◆ getAssignmentsOfUser()

ilExcRandomAssignmentDBRepository::getAssignmentsOfUser ( int  $user_id,
int  $exc_id 
)

Get mandatory assignments of user.

Parameters
int$user_id
int$exc_id
Returns
int[]

Definition at line 39 of file class.ilExcRandomAssignmentDBRepository.php.

References $db, and ilExAssignment\isInExercise().

40  {
41  $db = $this->db;
42 
43  $set = $db->queryF(
44  "SELECT * FROM exc_mandatory_random " .
45  " WHERE usr_id = %s " .
46  " AND exc_id = %s ",
47  array("integer", "integer"),
48  array($user_id, $exc_id)
49  );
50  $ass_ids = [];
51  while ($rec = $db->fetchAssoc($set)) {
52  if (ilExAssignment::isInExercise($rec["ass_id"], $exc_id)) {
53  $ass_ids[] = $rec["ass_id"];
54  }
55  }
56  return $ass_ids;
57  }
static isInExercise($a_ass_id, $a_ex_id)
Is assignment in exercise?
+ Here is the call graph for this function:

◆ saveAssignmentsOfUser()

ilExcRandomAssignmentDBRepository::saveAssignmentsOfUser ( int  $user_id,
int  $exc_id,
array  $ass_ids 
)

Save assignments of user.

Parameters
int$user_id
int$exc_id
int[]$ass_ids

Definition at line 66 of file class.ilExcRandomAssignmentDBRepository.php.

References $db, and ilExAssignment\isInExercise().

67  {
68  $db = $this->db;
69 
70  $db->manipulateF(
71  "DELETE FROM exc_mandatory_random WHERE " .
72  " exc_id = %s" .
73  " AND usr_id = %s",
74  array("integer", "integer"),
75  array($exc_id, $user_id)
76  );
77 
78  foreach ($ass_ids as $ass_id) {
79  if (ilExAssignment::isInExercise((int) $ass_id, $exc_id)) {
80  $db->replace("exc_mandatory_random", array( // pk
81  "usr_id" => array("integer", $user_id),
82  "exc_id" => array("integer", $exc_id),
83  "ass_id" => array("integer", $ass_id)
84  ), []);
85  }
86  }
87  }
static isInExercise($a_ass_id, $a_ex_id)
Is assignment in exercise?
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilExcRandomAssignmentDBRepository::$db
protected

The documentation for this class was generated from the following file: