From d0cd349f5114953e17510df21876d17af9ae2864 Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Thu, 29 Jun 2017 12:48:50 +0300 Subject: [PATCH] In mod_form.php checks if the selected category corresponds to selected glossary --- mod_form.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mod_form.php b/mod_form.php index ba0c187..8f1ef9b 100644 --- a/mod_form.php +++ b/mod_form.php @@ -118,7 +118,13 @@ class mod_game_mod_form extends moodleform_mod { $select = 'g.id IN ('.substr( $select, 1).')'; } $a = array(); - $a[ ] = ''; + $sql = "SELECT g.id, g.name, COUNT(*) as c ". + "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary g ". + "WHERE $select AND ge.glossaryid=g.id"; + $recs = $DB->get_records_sql( $sql); + foreach( $recs as $rec) { + $a[ -$rec->id] = $rec->name.' -> ('.$rec->c.')'; + } $sql2 = "SELECT COUNT(*) ". " FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec". " WHERE gec.categoryid=gc.id AND gec.entryid=ge.id";