From: jpuntd Date: Sun, 10 Oct 2004 03:55:58 +0000 (+0000) Subject: fixed some typos X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f9aa73d1b94fce6f274c9388f07f573d5f98caf5;p=moodle.git fixed some typos --- diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php new file mode 100644 index 0000000000..89ddb892d8 --- /dev/null +++ b/blocks/glossary_random/block_glossary_random.php @@ -0,0 +1,124 @@ +title = get_string('blockname','block_glossary_random'); + $this->content_type = BLOCK_TYPE_TEXT; + $this->course = $course; + $this->version = 2004100700; + if(!empty($course)) { + if ($prefs=get_record("block_glossary_random","course",$course->id)) { + $this->title = $prefs->title; + } + } + } + function get_content() { + global $USER, $CFG, $THEME; + + if($this->content !== NULL) { + return $this->content; + } + + + $this->content = New object; + $this->content->text = ''; + $this->content->footer = ''; + + if ($prefs=get_record("block_glossary_random","course",$this->course->id)) { + + $glossaryid = $prefs->glossary; + $glossary=get_record("glossary", "id", $glossaryid); + $studentcanpost = $glossary->studentcanpost; //needed to decide on which footer + + //check if it's time to put a new entry in cache + if (time() > $prefs->nexttime) + { + // place glossary concept and definition in $pref->cache + $numberofentries = count_records("glossary_entries","glossaryid",$glossaryid,"approved",1)-1; + switch ($prefs->type) { + case RANDOMLY: + $i = rand(0,$numberofentries); + break; + case NEXTONE: + $i = 1 + $prefs->previous; + if ($i < $numberofentries) { + break; + } + //otherwise fall through + case LASTMODIFIED: + $i=$numberofentries; + break; + + } + + if ($entries = get_records_sql("SELECT concept, definition, format + FROM {$CFG->prefix}glossary_entries + WHERE glossaryid = {$glossaryid} and approved = 1 + ORDER BY timemodified LIMIT {$i},1")) { + + foreach ($entries as $entry) { //normally only on entry + $text = " $entry->concept
"; + $text .= clean_text($entry->definition, $entry->format); + } + + + $prefs->nexttime = usergetmidnight(time())+60*60*24*$prefs->refresh; + $prefs->cache = addslashes($text); + $prefs->previous = $i; + if (!(update_record("block_glossary_random", $prefs))) { + error("Could not update the database"); + } + } else { + $text = get_string('notyetconfigured','block_glossary_random'); + } + } + + //otherwise just return the cached text + $this->content->text = stripslashes($prefs->cache); + + // place link to glossary in the footer if the glossary is visible + + //Create a temp valid module structure (course,id) + $tempmod->course = $this->course->id; + $tempmod->id = $glossaryid; + + //Obtain the visible property from the instance + if (instance_is_visible('glossary', $tempmod)) { + + $cm = get_coursemodule_from_instance('glossary',$glossaryid, $this->course->id) ; + if ($studentcanpost) { + $footertext = $prefs->addentry; + } else { + $footertext = $prefs->viewglossary; + } + $this->content->footer = ''.$footertext.''; + + // otherwise just place some text, no link + } else { + $this->content->footer = $prefs->invisible; + } + + + } else { //nothing in the database, this block needs configuration + $this->content->text = get_string("notyetconfigured","block_glossary_random"); + } + + if (isteacheredit($this->course->id)) { //add the option to configure this block + $this->content->footer .= '
" + .get_string("configureblock","block_glossary_random").""; + } + + return $this->content; + } + + + } +?> diff --git a/blocks/glossary_random/db/mysql.php b/blocks/glossary_random/db/mysql.php new file mode 100644 index 0000000000..1c9d6f4932 --- /dev/null +++ b/blocks/glossary_random/db/mysql.php @@ -0,0 +1,33 @@ + + +
+

:

+ + + + + + + + + + + + + + + + + + + + + +

:

:

glossary) ?>

:

:

type, ""); + helpbutton("",get_string("type","block_glossary_random"),"moodle",true,false,get_string("typehelp","block_glossary_random")); + ?>
+ +

:

+

+
+

+
+

+
+ + + + +
">
+
+ + diff --git a/blocks/glossary_random/prefs.php b/blocks/glossary_random/prefs.php new file mode 100644 index 0000000000..9cf336ac31 --- /dev/null +++ b/blocks/glossary_random/prefs.php @@ -0,0 +1,71 @@ +nexttime = usergetmidnight(time())+24*60*60*$prefs->refresh; + if (!(update_record("block_glossary_random", $prefs))) { + error("Could not update record in the database."); + } + redirect("$CFG->wwwroot/course/view.php?id=$prefs->course"); + } + } + + // print form + + if (!empty($err)) { + $focus = "form.".array_shift(array_flip(get_object_vars($err))); + } else { + $focus = ""; + } + + $prefs = get_record("block_glossary_random", "course", $course); + if (!$prefs) { + $prefs->course = $course; + $prefs->title = get_string('blockname','block_glossary_random'); + $prefs->refresh = 0; + $prefs->text= get_string("notyetconfigured","block_glossary_random"); + $prefs->addentry=get_string("addentry", "block_glossary_random"); + $prefs->viewglossary=get_string("viewglossary", "block_glossary_random"); + $prefs->invisible=get_string("invisible", "block_glossary_random"); + + if (!(insert_record("block_glossary_random",$prefs))) { + error("Could not insert new record in database"); + } + } + + // select glossaries to put in dropdown box ... + + $glossaries = get_records_select_menu("glossary", "course= $course","name","id,name"); + // and quotetypes to put in dropdown box + + $type[0] = get_string("random","block_glossary_random"); + $type[1] = get_string("lastmodified","block_glossary_random"); + $type[2] = get_string("nextone","block_glossary_random"); + + print_header(get_string("blockname","block_glossary_random"), + get_string("change_configuration","block_glossary_random")); + include("prefs.html"); + print_footer(); + +/****************************************************************************** + * FUNCTIONS + *****************************************************************************/ + +function validate_form($user, &$err) { + //we might add a check for glossary selected + return; +} + + +?>