Permalink
Browse files

- Multiwords concepts are now shown as a single link when they are di…

…nymically linked.

KNOWN BUG: When a concept is contained inside another concept (i.e. HOUSE and DOLL HOUSE) only the smaller concept is shown. Any help would be appreciated.
  • Loading branch information...
1 parent 4f5c5e1 commit 703f296be275e08e98a75ac7d918b57bfad748f8 willcast committed Sep 30, 2003
Showing with 19 additions and 11 deletions.
  1. +19 −11 mod/glossary/dynalink.php
View
@@ -2,28 +2,36 @@
function glossary_dynamic_link($courseid, $text,$glossaryid = NULL) {
global $CFG;
- static $entries;
- static $glossary;
- if ( !$glossary ) {
- $PermissionGranted = 1;
+ static $entries; // to avoid repeated calls to database
+ static $glossary; // even when dealing with the same glossary
+
+ if ( !$glossary and !$glossaryid ) {
+ $PermissionGranted = 1; // if it is the first call and no glossary was specify
} elseif ( $glossaryid ) {
- if ( $glossary->id != $glossaryid ) {
- $PermissionGranted = 1;
+ if ( $glossary ) { // if it is not the first call
+ if ( $glossary->id != $glossaryid ) { // ...and the specified glossary is different from the previous call
+ $PermissionGranted = 1;
+ }
} else {
+ $PermissionGranted = 1; // if it is the first call and a glossary was specify
}
- } else {
- $PermissionGranted = 1;
}
if ( $PermissionGranted ) {
- if ( !$glossaryid ) {
+ if ( !$glossaryid ) { // If no glossary was specify, fetch the main glossary of the course
$glossary = get_record("glossary","course",$courseid,"mainglossary",1);
- } else {
+ } else { // if a glossary as specify, fetch this one
$glossary = get_record("glossary","course",$courseid,"id",$glossaryid);
}
}
if ( $glossary ) {
if ( !$entries ) {
- // char_lenght is compatible with PostGreSQL and MySQL. Other DBMS must be implemented
+ // char_lenght is compatible with PostgreSQL and MySQL. Other DBMS must be implemented
+
+ /* I'm ordering the cursor by the lenght of the concept trying to avoid the bug that occurs
+ when a concept in contained in other entry's concept (i.e. HOUSE is in DOLL HOUSE).
+ However, I haven't find a solution yet.
+ Will (Sept. 30, 2003)
+ */
if ($CFG->dbtype == "postgres7" or $CFG->dbtype == "mysql") {
$ORDER_BY = "CHAR_LENGTH(concept) DESC";
} else {

0 comments on commit 703f296

Please sign in to comment.