From: willcast Date: Wed, 15 Oct 2003 16:12:38 +0000 (+0000) Subject: - Solving bug 817 (adding a glossary overview) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7dd8844764f693a49d2d8b50355e32d9424ceb59;p=moodle.git - Solving bug 817 (adding a glossary overview) - Minor changes adopting moodle's naming and coding conventions (perhaps not fully adopted yet) - Solving bug that traspose All Categories with Not Categorised view. --- diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 7d0cdffb57..7ce7d0d725 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -42,7 +42,7 @@ $string['mainglossary'] = "Main glossary"; $string['modulename'] = "Glossary"; $string['modulenameplural'] = "Glossaries"; $string['newglossaryentries'] = "New glossary entries:"; -$string['nocategorized'] = "Not categorised"; +$string['notcategorised'] = "Not categorised"; $string['noentries'] = "No entries found in this section"; $string['noentry'] = "No entry found."; $string['searchindefinition'] = "Search definitions too"; diff --git a/lang/en/help/glossary/description.html b/lang/en/help/glossary/description.html new file mode 100644 index 0000000000..cd98ad58f5 --- /dev/null +++ b/lang/en/help/glossary/description.html @@ -0,0 +1,3 @@ +

Description

+ +

It should describe the purpouse of this glossary, who will be able to post new entries, etc. diff --git a/mod/glossary/backuplib.php b/mod/glossary/backuplib.php index 0b0fe07552..9a406ab200 100644 --- a/mod/glossary/backuplib.php +++ b/mod/glossary/backuplib.php @@ -37,6 +37,7 @@ fwrite ($bf,full_tag("ID",4,false,$glossary->id)); fwrite ($bf,full_tag("MODTYPE",4,false,"glossary")); fwrite ($bf,full_tag("NAME",4,false,$glossary->name)); + fwrite ($bf,full_tag("INTRO",4,false,$glossary->INTRO)); fwrite ($bf,full_tag("STUDENTCANPOST",4,false,$glossary->studentcanpost)); fwrite ($bf,full_tag("ALLOWDUPLICATEDENTRIES",4,false,$glossary->allowduplicatedentries)); fwrite ($bf,full_tag("DISPLAYFORMAT",4,false,$glossary->displayformat)); diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 2fb33b28b9..17a69aeb7e 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -65,6 +65,12 @@ function glossary_upgrade($oldversion) { "ADD `sourceglossaryid` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `attachment` " ); } + + if ( $oldversion < 2003101500 ) { + execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " . + "ADD `intro` text NOT NULL DEFAULT '' AFTER `name` " ); + + } return true; } diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 71e9d6e8e7..d6196acb98 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -12,6 +12,7 @@ CREATE TABLE prefix_glossary ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0', name varchar(255) NOT NULL default '', + intro text NOT NULL, studentcanpost tinyint(2) unsigned NOT NULL default '0', allowduplicatedentries tinyint(2) unsigned NOT NULL default '0', displayformat tinyint(2) unsigned NOT NULL default '0', diff --git a/mod/glossary/db/oci8po.sql b/mod/glossary/db/oci8po.sql index 231af02231..d18e06be51 100755 --- a/mod/glossary/db/oci8po.sql +++ b/mod/glossary/db/oci8po.sql @@ -13,6 +13,7 @@ CREATE TABLE prefix_glossary ( id number(10) primary key, course number(10) default '0' not null, name varchar2(255) default '' not null, + intro varchar2(255) default '' not null, studentcanpost number(2) default '0' not null, allowduplicatedentries number(2) default '0' not null, displayformat number(2) default '0' not null, @@ -39,10 +40,10 @@ create or replace trigger p_glossary_trig . / -insert into prefix_glossary(course,name,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(1,'1',1,1,1,1,1,1,1,1,1); -insert into prefix_glossary(course,name,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(2,'2',2,2,2,2,2,2,2,2,2); -insert into prefix_glossary(course,name,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(3,'3',3,3,3,3,3,3,3,3,3); -insert into prefix_glossary(course,name,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(4,'4',4,4,4,4,4,4,4,4,4); +insert into prefix_glossary(course,name,intro,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(1,'1','1',1,1,1,1,1,1,1,1,1); +insert into prefix_glossary(course,name,intro,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(2,'2','2',2,2,2,2,2,2,2,2,2); +insert into prefix_glossary(course,name,intro,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(3,'3','3',3,3,3,3,3,3,3,3,3); +insert into prefix_glossary(course,name,intro,studentcanpost,allowduplicatedentries,displayformat,mainglossary,showspecial,showall,showalphabet,timecreated,timemodified) values(4,'4','4',4,4,4,4,4,4,4,4,4); select * from prefix_glossary order by 1,2; diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql index 81631aaeee..0c1746c09c 100644 --- a/mod/glossary/db/postgres7.sql +++ b/mod/glossary/db/postgres7.sql @@ -12,6 +12,7 @@ CREATE TABLE prefix_glossary ( id SERIAL, course int4 NOT NULL default '0', name varchar(255) NOT NULL default '', + intro text NOT NULL default '', studentcanpost int2 NOT NULL default '0', allowduplicatedentries int2 NOT NULL default '0', displayformat int2 NOT NULL default '0', diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html index c173ac0f07..1324a230fe 100644 --- a/mod/glossary/edit.html +++ b/mod/glossary/edit.html @@ -1,6 +1,7 @@

action="edit.php" enctype="multipart/form-data"> @@ -16,7 +17,7 @@ id); echo "
+
\n"; - if ( $row != $CurrentRow ) { - for ($col = 0; $col < $TabsPerRow; $col++) { - if ( $TabProccessed < $Tabs ) { + if ( $row != $currentrow ) { + for ($col = 0; $col < $tabsperrow; $col++) { + if ( $tabproccessed < $tabs ) { if ( $col == 0 ) { - echo ""; + echo ""; } - if ($TabProccessed == $CurrentTab) { - $CurrentColor = $CurrentTabColor; + if ($tabproccessed == $currenttab) { + $currentcolor = $currenttabcolor; } else { - $CurrentColor = $TabColor; + $currentcolor = $tabcolor; } - - echo ""; - if ( $col < $TabsPerRow ) { - echo ""; + if ( $col < $tabsperrow ) { + echo ""; } } else { - $CurrentColor = ""; + $currentcolor = ""; } - $TabProccessed++; + $tabproccessed++; } } else { - $FirstTabInCurrentRow = $TabProccessed; - $TabProccessed += $TabsPerRow; + $firsttabincurrentrow = $tabproccessed; + $tabproccessed += $tabsperrow; } - echo "\n"; + echo "\n"; } echo "\n"; - $TabProccessed = $FirstTabInCurrentRow; - for ($col = 0; $col < $TabsPerRow; $col++) { - if ( $TabProccessed < $Tabs ) { + $tabproccessed = $firsttabincurrentrow; + for ($col = 0; $col < $tabsperrow; $col++) { + if ( $tabproccessed < $tabs ) { if ( $col == 0 ) { - echo ""; + echo ""; } - if ($TabProccessed == $CurrentTab) { - $CurrentColor = $CurrentTabColor; + if ($tabproccessed == $currenttab) { + $currentcolor = $currenttabcolor; } else { - $CurrentColor = $TabColor; + $currentcolor = $tabcolor; } - echo ""; - if ($col < $TabsPerRow) { - echo ""; + if ($col < $tabsperrow) { + echo ""; } } else { - if ($NumRows > 1) { - $CurrentColor = $TabColor; + if ($numrows > 1) { + $currentcolor = $tabcolor; } else { - $CurrentColor = ""; + $currentcolor = ""; } - echo ""; - $col = $TabsPerRow; + $col = $tabsperrow; } - $TabProccessed++; + $tabproccessed++; } echo "\n"; ?> @@ -636,10 +651,10 @@ for ($row = 0; $row < $NumRows; $row++) { - + - "; diff --git a/mod/glossary/mod.html b/mod/glossary/mod.html index 951173a9fa..ca0238dff0 100644 --- a/mod/glossary/mod.html +++ b/mod/glossary/mod.html @@ -10,6 +10,23 @@ + + + +course); diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index ba812beb44..085ed792ea 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -41,6 +41,7 @@ //Now, build the glossary record structure $glossary->course = $restore->course_id; $glossary->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); + $glossary->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']); $glossary->studentcanpost = backup_todb($info['MOD']['#']['STUDENTCANPOST']['0']['#']); $glossary->allowduplicatedentries = backup_todb($info['MOD']['#']['ALLOWDUPLICATEDENTRIES']['0']['#']); $glossary->displayformat = backup_todb($info['MOD']['#']['DISPLAYFORMAT']['0']['#']); diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 75cec4a16d..de38c6f75f 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,9 +5,9 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2003092400; // The current module version (Date: YYYYMMDDXX) +$module->version = 2003101500; // The current module version (Date: YYYYMMDDXX) $module->cron = 0; // Period for cron to check this module (secs) -$release = "0.4 development"; // User-friendly version number +$release = "0.5 development"; // User-friendly version number ?> diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 105eb0f7b3..92186b368f 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -3,7 +3,6 @@ /// This page prints a particular instance of glossary require_once("../../config.php"); require_once("lib.php"); - require_once("dynalink.php"); require_variable($id); // Course Module ID optional_variable($l); // letter to look for @@ -34,7 +33,7 @@ add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id"); - $search = trim(strip_tags($search)); + $search = trim(strip_tags($search)); if ($search and !$entryid) { $l = ""; $searchterms = explode(" ", $search); // Search for words independently @@ -49,8 +48,9 @@ $search = ""; } + $alphabet = explode("|", get_string("alphabet","glossary")); if ($l == "" and $search == "" and ($eid == "" or $eid == 0)) { - $l = "A"; + $l = $alphabet[0]; } elseif ($eid) { $l = ""; } @@ -90,6 +90,16 @@ print_heading($glossary->name); +/// Info box + + if ( $glossary->intro ) { + print_simple_box_start("center","70%"); + echo '

'; + echo $glossary->intro; + echo '

'; + print_simple_box_end(); + } + /// Add button if (isteacher($course->id) or ($glossary->studentcanpost) and !isguest($course->id)) { @@ -125,12 +135,20 @@ $data[1]->caption = get_string("categoryview", "glossary"); if ($currentview) { - $CurrentTab = 1; + $currenttab = GLOSSARY_CATEGORY_VIEW; //1; } else { - $CurrentTab = 0; + $currenttab = GLOSSARY_STANDARD_VIEW; //0; } + $glossary_tCFG->TabTableBGColor = $THEME->cellheading; + $glossary_tCFG->ActiveTabColor = $THEME->cellheading; + $glossary_tCFG->InactiveTabColor = $THEME->cellcontent2; + $glossary_tCFG->InactiveFontColor= $THEME->hidden; + + $glossary_tCFG->TabTableWidth = "70%"; + $glossary_tCFG->TabsPerRow = 5; + $glossary_tCFG->TabSeparation = 4; - glossary_print_tabbed_table_start($data, $CurrentTab, $tCFG); + glossary_print_tabbed_table_start($data, $currenttab, $glossary_tCFG); echo "
"; if ($currentview) { glossary_print_categories_menu($course, $cm, $glossary, $cat, $category); @@ -139,7 +157,7 @@ } else { glossary_print_alphabet_menu($cm, $glossary, $l); if ($l) { - $CurrentLetter = ""; + $currentletter = ""; } elseif ($search) { echo "

$strsearch: $search

"; } @@ -152,7 +170,7 @@ $allentries = glossary_search_entries($searchterms, $glossary, $includedefinition); } elseif ($eid) { // looking for an entry $allentries = get_records("glossary_entries", "id", $eid); - } elseif ($currentview and $cat == -1) { // Browsing all categories + } elseif ($currentview and $cat == GLOSSARY_SHOW_ALL_CATEGORIES) { // Browsing all categories $sql = "SELECT gec.id gecid, gc.name, gc.id CID, ge.* FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec, @@ -177,53 +195,53 @@ } if ($allentries) { - $DumpedDefinitions = 0; + $dumpeddefinitions = 0; foreach ($allentries as $entry) { - $DumpToScreen = 0; - $FirstLetter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l))); + $dumptoscreen = 0; + $firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l))); if ($l) { - if ($l == "ALL" or $FirstLetter == $l) { - if ($CurrentLetter != $FirstLetter[0]) { - $CurrentLetter = $FirstLetter[0]; + if ($l == "ALL" or $firstletter == $l) { + if ($currentletter != $firstletter[0]) { + $currentletter = $firstletter[0]; if ($glossary->displayformat == 0) { - if ($DumpedDefinitions > 0) { + if ($dumpeddefinitions > 0) { echo "
  "; - if ($TabProccessed != $CurrentTab) { - echo "link . "\">"; + echo ""; + if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) { + echo "link . "\">"; } - echo $data[$TabProccessed]->caption; - if ($TabProccessed != $CurrentTab) { + + if ( !$data[$tabproccessed]->link ) { + echo ""; + } + echo $data[$tabproccessed]->caption; + if ( !$data[$tabproccessed]->link ) { + echo ""; + } + + if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) { echo ""; } echo "  
  "; - if ($TabProccessed != $CurrentTab) { - echo "link . "\">"; + echo ""; + if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) { + echo "link . "\">"; } - echo $data[$TabProccessed]->caption; - if ($TabProccessed != $CurrentTab) { + + if ( !$data[$tabproccessed]->link ) { + echo ""; + } + echo $data[$tabproccessed]->caption; + if ( !$data[$tabproccessed]->link ) { + echo ""; + } + + if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) { echo ""; } echo "  "; + echo ""; echo "


+
"; echo ""; - $menu["-1"] = get_string("allcategories","glossary"); - $menu["0"] = get_string("nocategorized","glossary"); + $menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary"); + $menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary"); $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC"); if ( $categories ) { @@ -727,18 +742,22 @@ global $CFG, $THEME; } } if ( !$selected ) { - $selected = "0"; + $selected = GLOSSARY_SHOW_NOT_CATEGORISED; } if ( $category ) { echo $category->name; } else { - if ( $cat < 0 ) { - echo get_string("allcategories","glossary"); - $selected = "-1"; - } elseif ( $cat == 0 ) { + if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) { + echo get_string("entrieswithoutcategory","glossary"); - $selected = "0"; + $selected = GLOSSARY_SHOW_NOT_CATEGORISED; + + } elseif ( $cat == GLOSSARY_SHOW_ALL_CATEGORIES ) { + + echo get_string("allcategories","glossary"); + $selected = GLOSSARY_SHOW_ALL_CATEGORIES; + } } echo "

:

+ + "; + helpbutton("writing", get_string("helpwriting"), "moodle", true, true); + echo "
"; + helpbutton("text", get_string("helptext"), "moodle", true, true); + ?> +
+
+
+ +

"; } echo "\n

cellheading2\">"; } if ($l == "ALL") { - echo "$CurrentLetter"; + echo "$currentletter"; } if ($glossary->displayformat == 0) { echo "\n
"; - if ($DumpedDefinitions > 0) { + if ($dumpeddefinitions > 0) { echo "\n
"; } } } - $DumpToScreen = 1; - } elseif ($l == "SPECIAL" and ord($FirstLetter) != ord("Ñ") and - (ord($FirstLetter) < ord("A") or ord($FirstLetter) > ord("Z"))) { - $DumpToScreen = 1; + $dumptoscreen = 1; + } elseif ($l == "SPECIAL" and ord($firstletter) != ord("Ñ") and + (ord($firstletter) < ord("A") or ord($firstletter) > ord("Z"))) { + $dumptoscreen = 1; } } else { if ($currentview) { - if ($category) { + if ($category) { // if we are browsing a category if (record_exists("glossary_entries_categories", "entryid", $entry->id, "categoryid", $category->id)) { - $DumpToScreen = 1; + $dumptoscreen = 1; } - } else { - if ($cat < 0) { // No categorized + } else { + if ($cat == GLOSSARY_SHOW_NOT_CATEGORISED) { // Not categorized if (! record_exists("glossary_entries_categories", "entryid", $entry->id)) { - $DumpToScreen = 1; + $dumptoscreen = 1; } } else { // All categories if ($currentcategory != $entry->CID) { $currentcategory = $entry->CID; if ($glossary->displayformat == 0) { - if ($DumpedDefinitions > 0) { + if ($dumpeddefinitions > 0) { echo "

"; } echo "\n

cellheading2\">"; @@ -233,26 +251,26 @@ if ($glossary->displayformat == 0) { echo "\n
"; - if ($DumpedDefinitions > 0) { + if ($dumpeddefinitions > 0) { echo "\n
"; } } - $DumpToScreen = 1; + $dumptoscreen = 1; } } } else { - $DumpToScreen = 1; + $dumptoscreen = 1; } } - if ($DumpToScreen) { - $DumpedDefinitions++; + if ($dumptoscreen) { + $dumpeddefinitions++; $concept = $entry->concept; $definition = $entry->definition; - if ($DumpedDefinitions == 1) { + if ($dumpeddefinitions == 1) { if ($glossary->displayformat == 0) { echo "\n
"; } @@ -261,9 +279,6 @@ $entry->concept = highlight($search, $concept); $entry->definition = highlight($search, $definition); } - if (!$glossary->mainglossary) { - $entry->definition = glossary_dynamic_link($course->id, $definition); - } glossary_print_entry($course, $cm, $glossary, $entry, $currentview, $cat); @@ -273,7 +288,7 @@ } } } - if (! $DumpedDefinitions) { + if (! $dumpeddefinitions) { print_simple_box_start("center", "70%", "$THEME->cellheading"); if (!$search) { echo "
$strnoentries
";