Browse Source

New: support for global glossaries

MOODLE_20_STABLE
Vasilis Daloukas 8 years ago
parent
commit
44acd8201d
  1. 2
      check.php
  2. 6
      cross/cross_class.php
  3. 3
      hangman/play.php
  4. 6
      locallib.php
  5. 9
      mod_form.php
  6. 2
      showanswers.php
  7. 4
      snakes/play.php
  8. 2
      version.php

2
check.php

@ -245,7 +245,7 @@ function game_check_common_problems_shortanswer_allowspaces( $game, &$warnings,
} }
if (count( $ret) != 0) { if (count( $ret) != 0) {
$warnings[] = get_string( 'common_problems_allowspaces', 'game').': '.count($ret).' ('.implode( ', ', $ret); $warnings[] = get_string( 'common_problems_allowspaces', 'game').': '.count($ret).' ('.implode( ', ', $ret).')';
} }
} }

6
cross/cross_class.php

@ -770,6 +770,8 @@ class Cross
* @param stdClass $game * @param stdClass $game
*/ */
public function showhtml_base( $crossm, $crossd, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game) { public function showhtml_base( $crossm, $crossd, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game) {
global $CFG, $DB;
$this->mLegendh = array(); $this->mLegendh = array();
$this->mLegendv = array(); $this->mLegendv = array();
@ -790,7 +792,9 @@ class Cross
$legendh = array(); $legendh = array();
if ($game->glossaryid) { if ($game->glossaryid) {
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course); $sql = "SELECT id,course FROM {$CFG->prefix}glossary WHERE id={$game->glossaryid}";
$glossary = $DB->get_record_sql( $sql);
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $glossary->course);
$contextglossary = game_get_context_module_instance( $cmglossary->id); $contextglossary = game_get_context_module_instance( $cmglossary->id);
} }
foreach ($crossd as $rec) { foreach ($crossd as $rec) {

3
hangman/play.php

@ -366,7 +366,8 @@ function hangman_showpage(&$done, &$correct, &$wrong, $max, &$wordline, &$wordli
$questiontext = str_replace( array("\'", '\"'), array("'", '"'), $query->questiontext); $questiontext = str_replace( array("\'", '\"'), array("'", '"'), $query->questiontext);
$query->questiontext = game_filterquestion($questiontext, $query->questionid, $context->id, $game->course); $query->questiontext = game_filterquestion($questiontext, $query->questionid, $context->id, $game->course);
} else { } else {
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course); $glossary = $DB->get_record_sql( "SELECT id,course FROM {$CFG->prefix}glossary WHERE id={$game->glossaryid}");
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $glossary->course);
$contextglossary = game_get_context_module_instance( $cmglossary->id); $contextglossary = game_get_context_module_instance( $cmglossary->id);
$query->questiontext = game_filterglossary(str_replace( '\"', '"', $query->questiontext = game_filterglossary(str_replace( '\"', '"',
$query->questiontext), $query->glossaryentryid, $contextglossary->id, $game->course); $query->questiontext), $query->glossaryentryid, $contextglossary->id, $game->course);

6
locallib.php

@ -2534,8 +2534,12 @@ function game_strpos( $haystack, $needle, $offset = 0) {
* @param string $text * @param string $text
*/ */
function game_show_query( $game, $query, $text) { function game_show_query( $game, $query, $text) {
global $CFG, $DB;
if ($game->glossaryid) { if ($game->glossaryid) {
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course); $sql = "SELECT id,course FROM {$CFG->prefix}glossary WHERE id={$game->glossaryid}";
$glossary = $DB->get_record_sql( $sql);
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $glossary->course);
$contextglossary = game_get_context_module_instance( $cmglossary->id); $contextglossary = game_get_context_module_instance( $cmglossary->id);
return game_filterglossary(str_replace( '\"', '"', $text), $query->glossaryentryid, $contextglossary->id, $game->course); return game_filterglossary(str_replace( '\"', '"', $text), $query->glossaryentryid, $contextglossary->id, $game->course);
} else if ($query->questionid) { } else if ($query->questionid) {

9
mod_form.php

@ -98,8 +98,13 @@ class mod_game_mod_form extends moodleform_mod {
if ($hasglossary) { if ($hasglossary) {
$a = array(); $a = array();
if ($recs = $DB->get_records('glossary', array( 'course' => $COURSE->id), 'id,name')) { $sql = "SELECT id,name,globalglossary,course FROM {$CFG->prefix}glossary ".
"WHERE course={$COURSE->id} OR globalglossary=1 ORDER BY globalglossary DESC,name";
if ($recs = $DB->get_records_sql($sql)) {
foreach ($recs as $rec) { foreach ($recs as $rec) {
if( ($rec->globalglossary != 0) and ($rec->course != $COURSE->id)) {
$rec->name = '*'.$rec->name;
}
$a[$rec->id] = $rec->name; $a[$rec->id] = $rec->name;
} }
} }
@ -429,7 +434,7 @@ class mod_game_mod_form extends moodleform_mod {
$sql2 = "SELECT COUNT(*) ". $sql2 = "SELECT COUNT(*) ".
" FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec". " FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec".
" WHERE gec.categoryid=gc.id AND gec.entryid=ge.id"; " WHERE gec.categoryid=gc.id AND gec.entryid=ge.id";
$sql = "SELECT gc.id,gc.name,g.name as name2, ($sql2) as c ". $sql = "SELECT gc.id,gc.name,g.name as name2,g.globalglossary,g.course, ($sql2) as c ".
" FROM {$CFG->prefix}glossary_categories gc, {$CFG->prefix}glossary g". " FROM {$CFG->prefix}glossary_categories gc, {$CFG->prefix}glossary g".
" WHERE $select AND gc.glossaryid=g.id". " WHERE $select AND gc.glossaryid=g.id".
" ORDER BY g.name, gc.name"; " ORDER BY g.name, gc.name";

2
showanswers.php

@ -475,7 +475,7 @@ function game_showanswers_glossary( $game) {
if ($game->param8 == 0) { // Not allowed -. if ($game->param8 == 0) { // Not allowed -.
if (!( strpos( $question->concept, '-') === false)) { if (!( strpos( $question->concept, '-') === false)) {
continue; continue;
} }
} }
echo '<tr>'; echo '<tr>';

4
snakes/play.php

@ -353,7 +353,9 @@ function game_snakes_showquestion_glossary( $id, $snakes, $query, $game) {
// Add a hidden field with glossaryentryid. // Add a hidden field with glossaryentryid.
echo '<input type="hidden" name="glossaryentryid" value="'.$query->glossaryentryid."\" />\n"; echo '<input type="hidden" name="glossaryentryid" value="'.$query->glossaryentryid."\" />\n";
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course); $sql = "SELECT id,course FROM {$CFG->prefix}glossary WHERE id={$game->glossaryid}";
$glossary = $DB->get_record_sql( $sql);
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $glossary->course);
$contextglossary = game_get_context_module_instance( $cmglossary->id); $contextglossary = game_get_context_module_instance( $cmglossary->id);
$s = game_filterglossary(str_replace( '\"', '"', $entry->definition), $query->glossaryentryid, $s = game_filterglossary(str_replace( '\"', '"', $entry->definition), $query->glossaryentryid,
$contextglossary->id, $game->course); $contextglossary->id, $game->course);

2
version.php

@ -35,7 +35,7 @@ if (!isset( $plugin)) {
} }
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics).
$plugin->version = 2017070601; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2017070602; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->requires = 2010112400; // Requires Moodle 2.0.
$plugin->cron = 0; // Period for cron to check this module (secs). $plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->release = '2017-07-06'; $plugin->release = '2017-07-06';

Loading…
Cancel
Save