From: willcast Date: Tue, 21 Oct 2003 20:45:53 +0000 (+0000) Subject: - Sorting entries by the length of the concept so large concepts could be linked... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=841d317f4a503210380eaf5126f340418a1a6223;p=moodle.git - Sorting entries by the length of the concept so large concepts could be linked first if they exist in the text to parse (avoiding that smaller concepts "gain control" over the larges one). - Setting hard=coded default settings to glossary (will be replaced soon by global default settings) --- diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index c6b71eeec4..4cba386706 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -20,17 +20,32 @@ } $glossaries=substr($glossaries,0,-1); - $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0","glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch"); - $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch"); +/// sorting by the lenght of the concept in order to assure that large concepts +/// could be linked first, if they exist in the text to parse + switch ($CFG->dbtype) { + case "postgres7": + case "mysql": + $ebylenght = "CHAR_LENGTH(concept) desc,"; + $cbylenght = "CHAR_LENGTH(name) desc,"; + break; + default: + $ebylenght = ""; + $cbylenght = ""; + break; + } + + $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch"); + $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch"); if ( $entries and $categories ) { $concepts = array_merge($entries, $categories); + usort($concepts,glossary_sort_entries_by_lenght); } elseif ( $categories ) { $concepts = $categories; } elseif ( $entries ) { $concepts = $entries; } - if ( $concepts ) { + if ( isset($concepts) ) { $lastglossary = 0; $lastcategory = 0; foreach ( $concepts as $concept ) { diff --git a/mod/glossary/mod.html b/mod/glossary/mod.html index 5716431e9e..b9da7ff092 100644 --- a/mod/glossary/mod.html +++ b/mod/glossary/mod.html @@ -1,6 +1,44 @@ - +allowcomments)) { + $form->allowcomments = 1; +} +if (!isset($form->mainglossary)) { + $form->mainglossary = 0; +} +if (!isset($form->allowduplicatedentries)) { + $form->allowduplicatedentries = 0; +} +if (!isset($form->defaultapproval)) { + $form->defaultapproval = 1; +} +if (!isset($form->displayformat)) { + $form->displayformat = 0; +} +if (!isset($form->intro)) { + $form->intro = ""; +} +if (!isset($form->name)) { + $form->name = ""; +} +if (!isset($form->showall)) { + $form->showall = 1; +} +if (!isset($form->showalphabet)) { + $form->showalphabet = 1; +} +if (!isset($form->showspecial)) { + $form->showspecial = 1; +} +if (!isset($form->studentcanpost)) { + $form->studentcanpost = 0; +} +if (!isset($form->usedynalink)) { + $form->usedynalink = 1; +} +?>