tab = str_repeat(' ', $this->tabsize); $this->str->course = get_string('course'); $this->str->category = get_string('category', 'quiz'); $this->str->categoryinfo = get_string('categoryinfo', 'quiz'); $this->str->questions = get_string('questions', 'quiz'); $this->str->add = get_string('add'); $this->str->delete = get_string('delete'); $this->str->moveup = get_urse", "id", $id)) { error("Course ID is incorrect"); } $context = get_context_instance(CONTEXT_COURSE, $id); require_login($course->id, false); require_capability('moodle/question:managecategory', $context); $qcobject = new question_category_object(); $qcobject->set_course($course); // Page header // TODO: generalise this to any activity if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) { $strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id)) ? update_module_button($SESSION->modform->cmid, $course->id, get_string('modulename', 'quiz')) : ""; print_header_simple(get_string('editcategories', 'quiz'), '', "wwwroot/mod/quiz/index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').''. " -> wwwroot/mod/quiz/view.php?q=$quiz->id\">".format_string($quiz->name).''. ' -> '.get_string('editcategories', 'quiz'), "", "", true, $strupdatemodule); $currenttab = 'edit'; $mode = 'categories'; include($CFG->dirroot.'/mod/quiz/tabs.php'); } else { print_header_simple(get_string('editcategories', 'quiz'), '', get_string('editcategories', 'quiz')); // print tabs $currenttab = 'categories'; include('tabs.php'); } // Process actions. if (isset($_REQUEST['sesskey']) and confirm_sesskey()) { // sesskey must be ok if (!empty($param->delete) and empty($param->cancel)) { if (!empty($param->confirm)) { /// 'confirm' is the category to move existing questions to $qcobject->delete_category($param->delete, $param->confirm); } else { $qcobject->delete_category($param->delete); } } else if (!empty($param->moveup)) { $qcobject->move_category_up_down('up', $param->moveup); } else if (!empty($param->movedown)) { $qcobject->move_category_up_down('down', $param->movedown); } else if (!empty($param->hide)) { $qcobject->publish_category(false, $param->hide); } else if (!empty($param->move)) { $qcobject->move_category($param->move, $param->moveto); } else if (!empty($param->publish)) { $qcobject->publish_category(true, $param->publish); } else if (!empty($param->addcategory)) { $param->newparent = required_param('newparent',PARAM_INT); $param->newcategory = required_param('newcategory',PARAM_NOTAGS); $param->newinfo = required_param('newinfo',PARAM_NOTAGS); $param->newpublish = required_param('newpublish',PARAM_INT); $qcobject->add_category($param->newparent, $param->newcategory, $param->newinfo, $param->newpublish, $course->id); } else if (!empty($param->edit)) { $qcobject->edit_single_category($param->edit, $param->page); } else if (!empty($param->updateid)) { $param->updateparent = required_param('updateparent',PARAM_INT); $param->updatename = required_param('updatename',PARAM_NOTAGS); $param->updateinfo = required_param('updateinfo',PARAM_NOTAGS); $param->updatepublish = required_param('updatepublish',PARAM_INT); $qcobject->update_category($param->updateid, $param->updateparent, $param->updatename, $param->updateinfo, $param->updatepublish, $course->id); } } // display the user interface $qcobject->display_user_interface($param->page); print_footer($course); ?> } } /** * Outputs a table to allow editing of an existing category * * @param object category * @param int page current page */ function output_edit_single_table($category, $page=1) { global $USER; $publishoptions[0] = get_string("no"); $publishoptions[1] = get_string("yes"); $strupdate = get_string('update'); $edittable = new stdClass; $edittable->head = array ($this->str->parent, $this->str->category, $this->str->categoryinfo, $this->str->publish, $this->str->action); $edittable->width = 200; $edittable->data[] = array(); $edittable->tablealign = 'center'; /// Each section below adds a data cell to the table row $viableparents = $this->categorystrings; $this->set_viable_parents($viableparents, $category); $viableparents = array(0=>$this->str->top) + $viableparents; $edittable->align['parent'] = "left"; $edittable->wrap['parent'] = "nowrap"; $row['parent'] = choose_from_menu ($viableparents, "updateparent", "{$category->parent}", "", "", "", true); $edittable->align['category'] = "left"; $edittable->wrap['category'] = "nowrap"; $row['category'] = ''; $edittable->align['info'] = "left"; $edittable->wrap['info'] = "nowrap"; $row['info'] = ''; $edittable->align['publish'] = "left"; $edittable->wrap['publish'] = "nowrap"; $selected = (boolean)$category->publish ? 1 : 0; $row['publish'] = choose_from_menu ($publishoptions, "updatepublish", $selected, "", "", "", true); $edittable->align['action'] = "left"; $edittable->wrap['action'] = "nowrap"; $row['action'] = ''; $edittable->data[] = $row; // wrap the table in a form and output it echo '

'; echo '
'; echo ''; echo ''; echo ''; echo ''; print_table($edittable); echo '
'; echo '

'; } /** * Creates an array of "full-path" category strings * Structure: * key => string * where key is the category id, and string contains the name of all ancestors as well as the particular category name * E.g. '123'=>'Language / English / Grammar / Modal Verbs" * * @param array $categories an array containing categories arranged in a tree structure */ function expanded_category_strings($categories, $parent=null) { $prefix = is_null($parent) ? '' : "$parent / "; $categorystrings = array(); foreach ($categories as $key => $category) { $expandedname = "$prefix$category->name"; $categorystrings[$key] = $expandedname; if (isset($category->children)) { $categorystrings = $categorystrings + $this->expanded_category_strings($category->children, $expandedname); } } return $categorystrings; } /** * Arranges the categories into a hierarchical tree * * If a category has children, it's "children" property holds an array of children * The questioncount for eaace=Georgia size=3> 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

g($category->name) . "' to '$category2->name'", "category.php?id={$this->course->id}"); } } else { // todo: delete any hidden questions that are not actually in use any more if ($count = count_records("question", "category", $category->id)) { $vars = new stdClass; $vars->name = $category->name; $vars->count = $count; print_simple_box(get_string("categorymove", "quiz", $vars), "center"); $this->initialize(); $categorystrings = $this->categorystrings; unset ($categorystrings[$category->id]); echo "

"; echo '
'; echo "sesskey\" />"; echo "course->id}\" />"; echo "id\" />"; choose_from_menu($categorystrings, "confirm", "", ""); echo ""; echo "str->cancel}\" />"; echo '
'; echo "

"; print_footer($this->course); exit; } } /// Send the children categories to live with their grandparent if ($childcats = get_records("question_categories", "parent", $category->id)) { foreach ($childcats as $childcat) { if (! set_field("question_categories", "parent", $category->parent, "id", $childcat->id)) { error("Could not update a child category!", "category.php?id={$this->course->id}"); } } } /// Finally delete the category itself if (delete_records("question_categories", "id", $category->id)) { notify(get_string("categorydeleted", "quiz", format_string($category->name)), 'notifysuccess'); } } /** * Moves a category up or down in the display order * * @param string direction up|down * @param int categoryid id of category to move */ function move_category_up_down ($direction, $categoryid) { /// Move a category up or down $swapcategory = NULL; $movecategory = NULL; if ($direction == 'up') { if ($movecategory = get_record("question_categories", "id", $categoryid)) { $categories = $this->get_question_categories("$movecategory->parent", 'parent, sortorder, name'); foreach ($categories as $category) { if ($category->id == $movecategory->id) { break; } $swapcategory = $category; } } } if ($direction == 'down') { if ($movecategory = get_record("question_categories", "id", $categoryid)) { $categories = $this->get_question_categories("$movecategory->parent", 'parent, sortorder, name'); $choosenext = false; foreach ($categories as $category) { if ($choosenext) { $swapcategory = $category; break; } if ($category->id == $movecategory->id) { $choosenext = true; } } } } if ($swapcategory and $movecategory) { // Renumber everything for robustness $count=0; foreach ($categories as $category) { $count++; if ($category->id == $swapcategory->id) { $category = $movecategory; } else if ($category->id == $movecategory->id) { $category = $swapcategory; } if (! set_field("question_categories", "sortorder", $count, "id", $category->id)) { notify("Could not update that category!"); } } } } /** * Changes the parent of a category * * @param int categoryid * @param int parentid */ function move_category($categoryid, $parentid) { /// Move a category to a new parent if ($tempcat = get_record("question_categories", "id", $categoryid)) { if ($tempcat->parent != $parentid) { if (! set_field("question_categories", "parent", $parentid, "id", $tempcat->id)) { notify("Could not update that category!"); } } } } /** * Changes the published status of a category * * @param boolean publish * @param int categoryid */ function publish_category($publish, $categoryid) { /// Hide or publish a category $publish = ($publish == false) ? 0 : 1; $tempcat = get_record("question_categories", "id", $categoryid); if ($tempcat) { if (! set_field("question_categories", "publish", $publish, "id", $tempcat->id)) { notify("Could not update that category!"); } } } /** * Creates a new category with given params * * @param int $newparent id of the parent category * @param string $newcategory the name for the new category * @param string $newinfo the info field for the new category * @param int $newpublish whether to publish the category * @param int $newcourse the id of the associated course */ function add_category($newparent, $newcategory, $newinfo, $newpublish, $newcourse) { if (empty($newcategory)) { notify(get_string('categorynamecantbeblank', 'quiz'), 'notifyproblem'); return false; } if ($newparent) { // first check that the parent category is in the correct course if(!(get_field('question_categories', 'course', 'id', $newparent) == $newcourse)) { return false; } } $cat = NULL; $cat->parent = $newparent; $cat->name = $newcategory; $cat->info = $newinfo; $cat->publish = $newpublish; $cat->course = $newcourse; $cat->sortorder = 999; $cat->stamp = make_unique_id_code(); if (!insert_record("question_categories", $cat)) { error("Could not insert the new question category '$newcategory'", "category.php?id={$newcourse}"); } else { notify(get_string("categoryadded", "quiz", $newcategory), 'notifysuccess'); } } /** * Updates an existing category with given params * * @param int updateid * @param int updateparent * @param string updatename * @param string updateinfo * @param int updatepublish * @param int courseid the id of the associated course */ function update_category($updateid, $updateparent, $updatename, $updateinfo, $updatepublish, $courseid) { if (empty($updatename)) { notify(get_string('categorynamecantbeblank', 'quiz'), 'notifyproblem'); return false; } $cat = NULL; $cat->id = $updateid; $cat->parent = $updateparent; $cat->name = $updatename; $cat->info = $updateinfo; $cat->publish = $updatepublish; if (!update_record("question_categories", $cat)) { error("Could not update the category '$updatename'", "category.php?id={$courseid}"); } else { notify(get_string("categoryupdated", 'quiz'), 'notifysuccess'); } } } ?> NT face=Georgia size=3> 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                             

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Los Menetriers de la Comba

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Pom Pom girls

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Nouveauté cette année, dimanche après midi

les Marsac western dance

                                                                          

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                                      

                                                                                               

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Les insolites       

              

              

                                                                                                                                                                                                                                                                                              

 

                                                            

 

© 2009
Accueil
Nos manifestations
L' album photos
Vos commentaires
Nos anonces
Liens