diff --git a/classes/associationservice.php b/classes/associationservice.php index 488520e..fe471f6 100644 --- a/classes/associationservice.php +++ b/classes/associationservice.php @@ -161,7 +161,7 @@ class associationservice extends \external_api { $params = ["pattern_nm" => $pattern, "pattern_id" => $pattern, ]; - $sql = "SELECT c.* from {cohort} c LEFT JOIN {local_treestudyplan_cohort} j ON c.id = j.cohort_id + $sql = "SELECT DISTINCT c.* from {cohort} c LEFT JOIN {local_treestudyplan_cohort} j ON c.id = j.cohort_id WHERE c.visible = 1 AND(name LIKE :pattern_nm OR idnumber LIKE :pattern_id)"; if (isset($excludeid) && is_numeric($excludeid)) { $sql .= " AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)"; @@ -220,7 +220,7 @@ class associationservice extends \external_api { "pattern_ln" => $pattern, "pattern_un" => $pattern, ]; - $sql = "SELECT u.* from {user} u LEFT JOIN {local_treestudyplan_user} j ON u.id = j.user_id + $sql = "SELECT DISTINCT u.* from {user} u LEFT JOIN {local_treestudyplan_user} j ON u.id = j.user_id WHERE u.deleted != 1 AND (firstname LIKE :pattern_fn OR lastname LIKE :pattern_ln OR username LIKE :pattern_un)"; if (isset($excludeid) && is_numeric($excludeid)) { $sql .= " AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)"; diff --git a/edit-plan.php b/edit-plan.php index 45de976..b61d6fa 100644 --- a/edit-plan.php +++ b/edit-plan.php @@ -106,10 +106,10 @@ print $OUTPUT->header();