';
+if ($canmanage and $numcourses > 1) {
+ // Print button to re-sort courses by name
+ $url = new moodle_url('/course/category.php', array('id' => $category->id, 'resort' => 'name', 'sesskey' => sesskey()));
+ echo $OUTPUT->single_button($url, get_string('resortcoursesbyname'), 'get');
+}
- print_course_search();
+if (has_capability('moodle/course:create', $context)) {
+ // Print button to create a new course
+ $url = new moodle_url('/course/edit.php', array('category' => $category->id, 'returnto' => 'category'));
+ echo $OUTPUT->single_button($url, get_string('addnewcourse'), 'get');
+}
- echo $OUTPUT->footer();
+if (!empty($CFG->enablecourserequests) && $category->id == $CFG->defaultrequestcategory) {
+ print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
+}
+echo '
';
+print_course_search();
+
+echo $OUTPUT->footer();
diff --git a/course/editcategory.php b/course/editcategory.php
index 9752cce1713..ff4bad5e0b6 100644
--- a/course/editcategory.php
+++ b/course/editcategory.php
@@ -1,9 +1,29 @@
.
+
/**
* Page for creating or editing course category name/parent/description.
* When called with an id parameter, edits the category with that id.
* Otherwise it creates a new category with default parent from the parent
* parameter, which may be 0.
+ *
+ * @package core
+ * @subpackage course
+ * @copyright 2007 Nicolas Connault
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../config.php');
@@ -108,6 +128,21 @@ if ($mform->is_cancelled()) {
redirect('category.php?id='.$newcategory->id.'&categoryedit=on');
}
+// Unfortunately the navigation never generates correctly for this page because technically
+// this page doesn't actually exist on the navigation you get here through the course
+// management page.
+try {
+ // First up we'll try to make the course management page active seeing as that is
+ // where the user thinks they are.
+ // The big prolem here is that the course management page is a common page
+ // for both editing users and common users.
+ $PAGE->settingsnav->get('root')->get('courses')->get('coursemgmt')->make_active();
+} catch (Exception $ex) {
+ // Failing that we'll override the URL, not as accurate and chances are things
+ // won't be 100% correct all the time but should work most times.
+ navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryedit' => 'on')));
+}
+
$PAGE->set_title($title);
$PAGE->set_heading($fullname);
echo $OUTPUT->header();
diff --git a/course/index.php b/course/index.php
index e87312848e2..ce1466a494f 100644
--- a/course/index.php
+++ b/course/index.php
@@ -177,6 +177,7 @@ if (!$categories = get_categories()) { /// No category yet!
$tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id);
mark_context_dirty('/'.SYSCONTEXTID);
fix_course_sortorder(); // Required to build course_categories.depth and .path.
+ set_config('defaultrequestcategory', $tempcat->id);
}
/// Move a category to a new parent if required
@@ -394,4 +395,4 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
print_category_edit($cat, $displaylist, $parentslist, $depth+1, $up, $down);
}
}
-}
\ No newline at end of file
+}
diff --git a/course/search.php b/course/search.php
index b3be91283e6..3a172f1a352 100644
--- a/course/search.php
+++ b/course/search.php
@@ -15,10 +15,19 @@
$blocklist = optional_param('blocklist', 0, PARAM_INT);
$modulelist= optional_param('modulelist', '', PARAM_PLUGIN);
- $PAGE->set_url('/course/search.php', compact('search', 'page', 'perpage', 'blocklist', 'modulelist', 'edit'));
- $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
- $search = trim(strip_tags($search)); // trim & clean raw searched string
+ // List of minimum capabilities which user need to have for editing/moving course
+ $capabilities = array('moodle/course:create', 'moodle/category:manage');
+ // List of category id's in which current user has course:create and category:manage capability.
+ $usercatlist = array();
+
+ // List of parent category id's
+ $catparentlist = array();
+
+ //Populate usercatlist with list of category id's with required capabilities.
+ make_categories_list($usercatlist, $catparentlist, $capabilities);
+
+ $search = trim(strip_tags($search)); // trim & clean raw searched string
if ($search) {
$searchterms = explode(" ", $search); // Search for words independently
foreach ($searchterms as $key => $searchterm) {
@@ -32,7 +41,7 @@
$site = get_site();
$urlparams = array();
- foreach (array('search', 'page', 'blocklist', 'modulelist') as $param) {
+ foreach (array('search', 'page', 'blocklist', 'modulelist', 'edit') as $param) {
if (!empty($$param)) {
$urlparams[$param] = $$param;
}
@@ -41,24 +50,30 @@
$urlparams['perpage'] = $perpage;
}
$PAGE->set_url('/course/search.php', $urlparams);
- $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
+ $PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('standard');
if ($CFG->forcelogin) {
require_login();
}
- if (can_edit_in_category()) {
+ //Editing is possible if user have system or category level create and manage capability
+ if (can_edit_in_category() || !empty($usercatlist)) {
if ($edit !== -1) {
$USER->editing = $edit;
}
$adminediting = $PAGE->user_is_editing();
+
+ // Set perpage if user can edit in category
+ if ($perpage != 99999) {
+ $perpage = 30;
+ }
} else {
$adminediting = false;
}
/// Editing functions
- if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM))) {
+ if (has_capability('moodle/course:visibility', context_system::instance())) {
/// Hide or show a course
if ($hide or $show and confirm_sesskey()) {
if ($hide) {
@@ -74,11 +89,6 @@
}
}
- $capabilities = array('moodle/course:create', 'moodle/category:manage');
- if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM)) && ($perpage != 99999)) {
- $perpage = 30;
- }
-
$displaylist = array();
$parentlist = array();
make_categories_list($displaylist, $parentlist);
@@ -94,7 +104,7 @@
$strfrontpage = get_string('frontpage', 'admin');
$strnovalidcourses = get_string('novalidcourses');
- if (empty($search) and empty($blocklist) and empty($modulelist)) {
+ if (empty($search) and empty($blocklist) and empty($modulelist) and empty($moveto) and ($edit != -1)) {
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
$PAGE->navbar->add($strsearch);
$PAGE->set_title("$site->fullname : $strsearch");
@@ -114,18 +124,28 @@
exit;
}
+ $courses = array();
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
- if (! $destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
- print_error('cannotfindcategory', '', '', $data->moveto);
+ if (!$destcategory = $DB->get_record("course_categories", array("id" => $moveto))) {
+ print_error('cannotfindcategory', '', '', $moveto);
}
- $courses = array();
+ //User should have manage and create capablity on destination category.
+ require_capability('moodle/category:manage', context_coursecat::instance($moveto));
+ require_capability('moodle/course:create', context_coursecat::instance($moveto));
+
foreach ( $data as $key => $value ) {
if (preg_match('/^c\d+$/', $key)) {
- array_push($courses, substr($key, 1));
+ $courseid = substr($key, 1);
+ // user must have category:manage and course:create capability for the course to be moved.
+ $coursecontext = context_course::instance($courseid);
+ foreach ($capabilities as $capability) {
+ require_capability($capability, $coursecontext);
+ array_push($courses, $courseid);
+ }
}
}
- move_courses($courses, $data->moveto);
+ move_courses($courses, $moveto);
}
// get list of courses containing blocks if required
@@ -148,9 +168,7 @@
foreach ($courses as $course) {
$courses[$course->id] = $course;
}
- }
- // get list of courses containing modules if required
- elseif (!empty($modulelist) and confirm_sesskey()) {
+ } elseif (!empty($modulelist) and confirm_sesskey()) { // get list of courses containing modules
$modulename = $modulelist;
$sql = "SELECT DISTINCT c.id FROM {".$modulelist."} module, {course} c"
." WHERE module.course=c.id";
@@ -172,34 +190,26 @@
else {
$totalcount = 0;
}
- }
- else {
+ } else if (!empty($searchterm)) { //Donot do search for empty search request.
$courses = get_courses_search($searchterms, "fullname ASC",
$page, $perpage, $totalcount);
}
- $searchform = print_course_search($search, true, "navbar");
-
- if (!empty($courses) && has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) {
- $searchform = '';
- // not sure if this capability is the best here
- if (has_capability('moodle/category:manage', get_context_instance(CONTEXT_SYSTEM))) {
- if ($PAGE->user_is_editing()) {
- $string = get_string("turneditingoff");
- $edit = "off";
- } else {
- $string = get_string("turneditingon");
- $edit = "on";
- }
-
- $aurl = new moodle_url("$CFG->wwwroot/course/search.php", array(
- 'edit' => $edit,
- 'sesskey' => sesskey(),
- 'search' => $search,
- 'page' => $page,
- 'perpage' => $perpage));
- $searchform = $OUTPUT->single_button($aurl, $string, 'get');
+ $searchform = '';
+ //Turn editing should be visible if user have system or category level capability
+ if (!empty($courses) && (can_edit_in_category() || !empty($usercatlist))) {
+ if ($PAGE->user_is_editing()) {
+ $string = get_string("turneditingoff");
+ $edit = "off";
+ } else {
+ $string = get_string("turneditingon");
+ $edit = "on";
}
+ $params = array_merge($urlparams, array('sesskey' => sesskey(), 'edit' => $edit));
+ $aurl = new moodle_url("$CFG->wwwroot/course/search.php", $params);
+ $searchform = $OUTPUT->single_button($aurl, $string, 'get');
+ } else {
+ $searchform = print_course_search($search, true, "navbar");
}
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
@@ -228,25 +238,30 @@
print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink);
- if (!$adminediting) {
+ // Show list of courses
+ if (!$adminediting) { //Not editing mode
foreach ($courses as $course) {
-
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
-
- $course->summary .= "
\n";
- // this is ok since this will get inherited from course category context
- // if it is set
- if (has_capability('moodle/category:manage', $coursecontext)) {
+ // If user has all required capabilities to move course then show selectable checkbox
+ if (has_all_capabilities($capabilities, $coursecontext)) {
echo "id\" />\n";
} else {
echo "id\" disabled=\"disabled\" />\n";
@@ -338,7 +352,8 @@
echo " ";
echo "\n";
echo "\n";
- echo html_writer::select($displaylist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
+ //Select box should only show categories in which user has min capability to move course.
+ echo html_writer::select($usercatlist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
echo "
\n
\n";
echo "
\n
";
@@ -384,7 +399,7 @@
$defaultperpage = 10;
//If user has course:create or category:manage capability the show 30 records.
$capabilities = array('moodle/course:create', 'moodle/category:manage');
- if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM))) {
+ if (has_any_capability($capabilities, context_system::instance())) {
$defaultperpage = 30;
}
diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php
index 3a35fd86575..ca4c063d17b 100644
--- a/grade/report/grader/index.php
+++ b/grade/report/grader/index.php
@@ -22,7 +22,6 @@ require_once $CFG->dirroot.'/grade/report/grader/lib.php';
$courseid = required_param('id', PARAM_INT); // course id
$page = optional_param('page', 0, PARAM_INT); // active page
-$perpageurl = optional_param('perpage', 0, PARAM_INT);
$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
$sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
@@ -127,12 +126,6 @@ if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/gr
$warnings = array();
}
-
-// Override perpage if set in URL
-if ($perpageurl) {
- $report->user_prefs['studentsperpage'] = $perpageurl;
-}
-
// final grades MUST be loaded after the processing
$report->load_users();
$numusers = $report->get_numusers();
@@ -162,6 +155,7 @@ if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback')
echo '';
echo '';
echo '';
+ echo '';
echo $reporthtml;
echo '';
echo '';
diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php
index 2aea35f324f..d171289e2f8 100644
--- a/grade/report/grader/lib.php
+++ b/grade/report/grader/lib.php
@@ -135,12 +135,11 @@ class grade_report_grader extends grade_report {
$this->baseurl = new moodle_url('index.php', array('id' => $this->courseid));
- $studentsperpage = $this->get_pref('studentsperpage');
- if (!empty($studentsperpage)) {
- $this->baseurl->params(array('perpage' => $studentsperpage, 'page' => $this->page));
+ if (!empty($this->page)) {
+ $this->baseurl->params(array('page' => $this->page));
}
- $this->pbarurl = new moodle_url('/grade/report/grader/index.php', array('id' => $this->courseid, 'perpage' => $studentsperpage));
+ $this->pbarurl = new moodle_url('/grade/report/grader/index.php', array('id' => $this->courseid));
$this->setup_groups();
diff --git a/group/members.php b/group/members.php
index fd53b135f03..587ab4eea62 100644
--- a/group/members.php
+++ b/group/members.php
@@ -20,7 +20,7 @@ $cancel = optional_param('cancel', false, PARAM_BOOL);
$group = $DB->get_record('groups', array('id'=>$groupid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$group->courseid), '*', MUST_EXIST);
-$PAGE->set_url('/groups/members.php', array('id'=>$groupid));
+$PAGE->set_url('/group/members.php', array('group'=>$groupid));
$PAGE->set_pagelayout('standard');
require_login($course);
diff --git a/lang/en/blog.php b/lang/en/blog.php
index 1d54561d87e..202ad8770c0 100644
--- a/lang/en/blog.php
+++ b/lang/en/blog.php
@@ -54,6 +54,8 @@ $string['blogentriesbyuseraboutmodule'] = 'Blog entries about this {$a->mod} by
$string['blogentrybyuser'] = 'Blog entry by {$a}';
$string['blogpreferences'] = 'Blog preferences';
$string['blogs'] = 'Blogs';
+$string['blogscourse'] = 'Course blogs';
+$string['blogssite'] = 'Site blogs';
$string['blogtags'] = 'Blog tags';
$string['cannotviewcourseblog'] = 'You do not have the required permissions to view blogs in this course';
$string['cannotviewcourseorgroupblog'] = 'You do not have the required permissions to view blogs in this course/group';
diff --git a/lang/en/message.php b/lang/en/message.php
index 60993bc4ca6..5aa5f4e6083 100644
--- a/lang/en/message.php
+++ b/lang/en/message.php
@@ -128,6 +128,7 @@ $string['settings'] = 'Settings';
$string['settingssaved'] = 'Your settings have been saved';
$string['showmessagewindow'] = 'Popup window on new message';
$string['strftimedaydatetime'] = '%A, %d %B %Y, %I:%M %p';
+$string['thisconversation'] = 'this conversation';
$string['timenosee'] = 'Minutes since I was last seen online';
$string['timesent'] = 'Time sent';
$string['touserdoesntexist'] = 'You can not send a message to a user id ({$a}) that doesn\'t exist';
diff --git a/lib/javascript.php b/lib/javascript.php
index 02ab49a7f87..59965316bf2 100644
--- a/lib/javascript.php
+++ b/lib/javascript.php
@@ -46,7 +46,11 @@ foreach ($files as $fsfile) {
// does not exist
continue;
}
- if (strpos($jsfile, $CFG->dirroot . DIRECTORY_SEPARATOR) !== 0) {
+ if ($CFG->dirroot === '/') {
+ // Some shared hosting sites serve files directly from '/',
+ // this is NOT supported, but at least allow JS when showing
+ // errors and warnings.
+ } else if (strpos($jsfile, $CFG->dirroot . DIRECTORY_SEPARATOR) !== 0) {
// hackers - not in dirroot
continue;
}
diff --git a/lib/navigationlib.php b/lib/navigationlib.php
index 10d13baf8f5..7aea49a9333 100644
--- a/lib/navigationlib.php
+++ b/lib/navigationlib.php
@@ -1061,7 +1061,10 @@ class global_navigation extends navigation_node {
$mycourses = enrol_get_my_courses(NULL, 'visible DESC,sortorder ASC', $limit);
$showallcourses = (count($mycourses) == 0 || !empty($CFG->navshowallcourses));
- $showcategories = ($showallcourses && $this->show_categories());
+ // When checking if we are to show categories there is an additional override.
+ // If the user is viewing a category then we will load it regardless of settings.
+ // to ensure that the navigation is consistent.
+ $showcategories = $this->page->context->contextlevel == CONTEXT_COURSECAT || ($showallcourses && $this->show_categories());
$issite = ($this->page->course->id == SITEID);
$ismycourse = (array_key_exists($this->page->course->id, $mycourses));
@@ -1086,188 +1089,201 @@ class global_navigation extends navigation_node {
$canviewcourseprofile = true;
- if (!$issite) {
- // Next load context specific content into the navigation
- switch ($this->page->context->contextlevel) {
- case CONTEXT_SYSTEM :
- // This has already been loaded we just need to map the variable
- $coursenode = $frontpagecourse;
- $this->load_all_categories(null, $showcategories);
+ // Next load context specific content into the navigation
+ switch ($this->page->context->contextlevel) {
+ case CONTEXT_SYSTEM :
+ // This has already been loaded we just need to map the variable
+ $coursenode = $frontpagecourse;
+ $this->load_all_categories(null, $showcategories);
+ break;
+ case CONTEXT_COURSECAT :
+ // This has already been loaded we just need to map the variable
+ $coursenode = $frontpagecourse;
+ $this->load_all_categories($this->page->context->instanceid, $showcategories);
+ if (array_key_exists($this->page->context->instanceid, $this->addedcategories)) {
+ $this->addedcategories[$this->page->context->instanceid]->make_active();
+ }
+ break;
+ case CONTEXT_BLOCK :
+ case CONTEXT_COURSE :
+ if ($issite) {
+ // If it is the front page course, or a block on it then
+ // everything has already been loaded.
break;
- case CONTEXT_COURSECAT :
- // This has already been loaded we just need to map the variable
- $coursenode = $frontpagecourse;
- $this->load_all_categories($this->page->context->instanceid, $showcategories);
+ }
+ // Load the course associated with the page into the navigation
+ $course = $this->page->course;
+ if ($showcategories && !$ismycourse) {
+ $this->load_all_categories($course->category, $showcategories);
+ }
+ $coursenode = $this->load_course($course);
+
+ // If the course wasn't added then don't try going any further.
+ if (!$coursenode) {
+ $canviewcourseprofile = false;
break;
- case CONTEXT_BLOCK :
- case CONTEXT_COURSE :
- // Load the course associated with the page into the navigation
- $course = $this->page->course;
- if ($showcategories && !$ismycourse) {
- $this->load_all_categories($course->category, $showcategories);
- }
- $coursenode = $this->load_course($course);
+ }
- // If the course wasn't added then don't try going any further.
- if (!$coursenode) {
- $canviewcourseprofile = false;
- break;
- }
+ // If the user is not enrolled then we only want to show the
+ // course node and not populate it.
- // If the user is not enrolled then we only want to show the
- // course node and not populate it.
-
- // Not enrolled, can't view, and hasn't switched roles
- if (!can_access_course($course)) {
- // TODO: very ugly hack - do not force "parents" to enrol into course their child is enrolled in,
- // this hack has been propagated from user/view.php to display the navigation node. (MDL-25805)
- $isparent = false;
- if ($this->useridtouseforparentchecks) {
- if ($this->useridtouseforparentchecks != $USER->id) {
- $usercontext = get_context_instance(CONTEXT_USER, $this->useridtouseforparentchecks, MUST_EXIST);
- if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id))
- and has_capability('moodle/user:viewdetails', $usercontext)) {
- $isparent = true;
- }
+ // Not enrolled, can't view, and hasn't switched roles
+ if (!can_access_course($course)) {
+ // TODO: very ugly hack - do not force "parents" to enrol into course their child is enrolled in,
+ // this hack has been propagated from user/view.php to display the navigation node. (MDL-25805)
+ $isparent = false;
+ if ($this->useridtouseforparentchecks) {
+ if ($this->useridtouseforparentchecks != $USER->id) {
+ $usercontext = get_context_instance(CONTEXT_USER, $this->useridtouseforparentchecks, MUST_EXIST);
+ if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id))
+ and has_capability('moodle/user:viewdetails', $usercontext)) {
+ $isparent = true;
}
}
-
- if (!$isparent) {
- $coursenode->make_active();
- $canviewcourseprofile = false;
- break;
- }
- }
- // Add the essentials such as reports etc...
- $this->add_course_essentials($coursenode, $course);
- if ($this->format_display_course_content($course->format)) {
- // Load the course sections
- $sections = $this->load_course_sections($course, $coursenode);
- }
- if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) {
- $coursenode->make_active();
- }
- break;
- case CONTEXT_MODULE :
- $course = $this->page->course;
- $cm = $this->page->cm;
-
- if ($showcategories && !$ismycourse) {
- $this->load_all_categories($course->category, $showcategories);
}
- // Load the course associated with the page into the navigation
- $coursenode = $this->load_course($course);
-
- // If the course wasn't added then don't try going any further.
- if (!$coursenode) {
- $canviewcourseprofile = false;
- break;
- }
-
- // If the user is not enrolled then we only want to show the
- // course node and not populate it.
- if (!can_access_course($course)) {
+ if (!$isparent) {
$coursenode->make_active();
$canviewcourseprofile = false;
break;
}
-
- $this->add_course_essentials($coursenode, $course);
-
- // Get section number from $cm (if provided) - we need this
- // before loading sections in order to tell it to load this section
- // even if it would not normally display (=> it contains only
- // a label, which we are now editing)
- $sectionnum = isset($cm->sectionnum) ? $cm->sectionnum : 0;
- if ($sectionnum) {
- // This value has to be stored in a member variable because
- // otherwise we would have to pass it through a public API
- // to course formats and they would need to change their
- // functions to pass it along again...
- $this->includesectionnum = $sectionnum;
- } else {
- $this->includesectionnum = false;
- }
-
- // Load the course sections into the page
+ }
+ // Add the essentials such as reports etc...
+ $this->add_course_essentials($coursenode, $course);
+ if ($this->format_display_course_content($course->format)) {
+ // Load the course sections
$sections = $this->load_course_sections($course, $coursenode);
- if ($course->id != SITEID) {
- // Find the section for the $CM associated with the page and collect
- // its section number.
- if ($sectionnum) {
- $cm->sectionnumber = $sectionnum;
- } else {
- foreach ($sections as $section) {
- if ($section->id == $cm->section) {
- $cm->sectionnumber = $section->section;
- break;
- }
- }
- }
+ }
+ if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) {
+ $coursenode->make_active();
+ }
+ break;
+ case CONTEXT_MODULE :
+ if ($issite) {
+ // If this is the site course then most information will have
+ // already been loaded.
+ // However we need to check if there is more content that can
+ // yet be loaded for the specific module instance.
+ $activitynode = $this->rootnodes['site']->get($this->page->cm->id, navigation_node::TYPE_ACTIVITY);
+ if ($activitynode) {
+ $this->load_activity($this->page->cm, $this->page->course, $activitynode);
+ }
+ break;
+ }
- // Load all of the section activities for the section the cm belongs to.
- if (isset($cm->sectionnumber) and !empty($sections[$cm->sectionnumber])) {
- list($sectionarray, $activityarray) = $this->generate_sections_and_activities($course);
- $activities = $this->load_section_activities($sections[$cm->sectionnumber]->sectionnode, $cm->sectionnumber, $activityarray);
- } else {
- $activities = array();
- if ($activity = $this->load_stealth_activity($coursenode, get_fast_modinfo($course))) {
- // "stealth" activity from unavailable section
- $activities[$cm->id] = $activity;
+ $course = $this->page->course;
+ $cm = $this->page->cm;
+
+ if ($showcategories && !$ismycourse) {
+ $this->load_all_categories($course->category, $showcategories);
+ }
+
+ // Load the course associated with the page into the navigation
+ $coursenode = $this->load_course($course);
+
+ // If the course wasn't added then don't try going any further.
+ if (!$coursenode) {
+ $canviewcourseprofile = false;
+ break;
+ }
+
+ // If the user is not enrolled then we only want to show the
+ // course node and not populate it.
+ if (!can_access_course($course)) {
+ $coursenode->make_active();
+ $canviewcourseprofile = false;
+ break;
+ }
+
+ $this->add_course_essentials($coursenode, $course);
+
+ // Get section number from $cm (if provided) - we need this
+ // before loading sections in order to tell it to load this section
+ // even if it would not normally display (=> it contains only
+ // a label, which we are now editing)
+ $sectionnum = isset($cm->sectionnum) ? $cm->sectionnum : 0;
+ if ($sectionnum) {
+ // This value has to be stored in a member variable because
+ // otherwise we would have to pass it through a public API
+ // to course formats and they would need to change their
+ // functions to pass it along again...
+ $this->includesectionnum = $sectionnum;
+ } else {
+ $this->includesectionnum = false;
+ }
+
+ // Load the course sections into the page
+ $sections = $this->load_course_sections($course, $coursenode);
+ if ($course->id != SITEID) {
+ // Find the section for the $CM associated with the page and collect
+ // its section number.
+ if ($sectionnum) {
+ $cm->sectionnumber = $sectionnum;
+ } else {
+ foreach ($sections as $section) {
+ if ($section->id == $cm->section) {
+ $cm->sectionnumber = $section->section;
+ break;
}
}
+ }
+
+ // Load all of the section activities for the section the cm belongs to.
+ if (isset($cm->sectionnumber) and !empty($sections[$cm->sectionnumber])) {
+ list($sectionarray, $activityarray) = $this->generate_sections_and_activities($course);
+ $activities = $this->load_section_activities($sections[$cm->sectionnumber]->sectionnode, $cm->sectionnumber, $activityarray);
} else {
$activities = array();
- $activities[$cm->id] = $coursenode->get($cm->id, navigation_node::TYPE_ACTIVITY);
- }
- if (!empty($activities[$cm->id])) {
- // Finally load the cm specific navigaton information
- $this->load_activity($cm, $course, $activities[$cm->id]);
- // Check if we have an active ndoe
- if (!$activities[$cm->id]->contains_active_node() && !$activities[$cm->id]->search_for_active_node()) {
- // And make the activity node active.
- $activities[$cm->id]->make_active();
+ if ($activity = $this->load_stealth_activity($coursenode, get_fast_modinfo($course))) {
+ // "stealth" activity from unavailable section
+ $activities[$cm->id] = $activity;
}
- } else {
- //TODO: something is wrong, what to do? (Skodak)
}
- break;
- case CONTEXT_USER :
- $course = $this->page->course;
- if ($showcategories && !$ismycourse) {
- $this->load_all_categories($course->category, $showcategories);
- }
- // Load the course associated with the user into the navigation
- $coursenode = $this->load_course($course);
-
- // If the course wasn't added then don't try going any further.
- if (!$coursenode) {
- $canviewcourseprofile = false;
- break;
- }
-
- // If the user is not enrolled then we only want to show the
- // course node and not populate it.
- if (!can_access_course($course)) {
- $coursenode->make_active();
- $canviewcourseprofile = false;
- break;
- }
- $this->add_course_essentials($coursenode, $course);
- $sections = $this->load_course_sections($course, $coursenode);
- break;
- }
- } else {
- // We need to check if the user is viewing a front page module.
- // If so then there is potentially more content to load yet for that
- // module.
- if ($this->page->context->contextlevel == CONTEXT_MODULE) {
- $activitynode = $this->rootnodes['site']->get($this->page->cm->id, navigation_node::TYPE_ACTIVITY);
- if ($activitynode) {
- $this->load_activity($this->page->cm, $this->page->course, $activitynode);
+ } else {
+ $activities = array();
+ $activities[$cm->id] = $coursenode->get($cm->id, navigation_node::TYPE_ACTIVITY);
}
- }
+ if (!empty($activities[$cm->id])) {
+ // Finally load the cm specific navigaton information
+ $this->load_activity($cm, $course, $activities[$cm->id]);
+ // Check if we have an active ndoe
+ if (!$activities[$cm->id]->contains_active_node() && !$activities[$cm->id]->search_for_active_node()) {
+ // And make the activity node active.
+ $activities[$cm->id]->make_active();
+ }
+ } else {
+ //TODO: something is wrong, what to do? (Skodak)
+ }
+ break;
+ case CONTEXT_USER :
+ if ($issite) {
+ // The users profile information etc is already loaded
+ // for the front page.
+ break;
+ }
+ $course = $this->page->course;
+ if ($showcategories && !$ismycourse) {
+ $this->load_all_categories($course->category, $showcategories);
+ }
+ // Load the course associated with the user into the navigation
+ $coursenode = $this->load_course($course);
+
+ // If the course wasn't added then don't try going any further.
+ if (!$coursenode) {
+ $canviewcourseprofile = false;
+ break;
+ }
+
+ // If the user is not enrolled then we only want to show the
+ // course node and not populate it.
+ if (!can_access_course($course)) {
+ $coursenode->make_active();
+ $canviewcourseprofile = false;
+ break;
+ }
+ $this->add_course_essentials($coursenode, $course);
+ $sections = $this->load_course_sections($course, $coursenode);
+ break;
}
$limit = 20;
@@ -1347,7 +1363,9 @@ class global_navigation extends navigation_node {
protected function show_categories() {
global $CFG, $DB;
if ($this->showcategories === null) {
- $this->showcategories = !empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1;
+ $show = $this->page->context->contextlevel == CONTEXT_COURSECAT;
+ $show = $show || (!empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1);
+ $this->showcategories = $show;
}
return $this->showcategories;
}
@@ -2274,7 +2292,7 @@ class global_navigation extends navigation_node {
if (($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
and has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
- $participants->add(get_string('blogs','blog'), $blogsurls->out());
+ $participants->add(get_string('blogscourse','blog'), $blogsurls->out());
}
if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) {
$participants->add(get_string('notes','notes'), new moodle_url('/notes/index.php', array('filtertype'=>'course', 'filterselect'=>$course->id)));
@@ -2339,7 +2357,7 @@ class global_navigation extends navigation_node {
and ($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
and has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
- $coursenode->add(get_string('blogs','blog'), $blogsurls->out());
+ $coursenode->add(get_string('blogssite','blog'), $blogsurls->out());
}
// Notes
diff --git a/lib/outputlib.php b/lib/outputlib.php
index 8feae4c83d5..285085e78eb 100644
--- a/lib/outputlib.php
+++ b/lib/outputlib.php
@@ -441,6 +441,12 @@ class theme_config {
if (is_readable($rendererfile)) {
// may contain core and plugin renderers and renderer factory
include_once($rendererfile);
+ } else {
+ // check if renderers.php file is missnamed renderer.php
+ if (is_readable($this->dir.'/renderer.php')) {
+ debugging('Developer hint: '.$this->dir.'/renderer.php should be renamed to ' . $this->dir."/renderers.php.
+ See: http://docs.moodle.org/dev/Output_renderers#Theme_renderers.", DEBUG_DEVELOPER);
+ }
}
// cascade all layouts properly
diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php
index 240d131d8d1..f7a5e8afd59 100644
--- a/lib/outputrequirementslib.php
+++ b/lib/outputrequirementslib.php
@@ -408,7 +408,7 @@ class page_requirements_manager {
array('saving', 'repository'), array('search', 'repository'), array('searching', 'repository'), array('size', 'repository'),
array('submit', 'repository'), array('sync', 'repository'), array('title', 'repository'), array('upload', 'repository'),
array('uploading', 'repository'), array('xhtmlerror', 'repository'),
- array('cancel'), array('chooselicense', 'repository'), array('author', 'repository'),
+ array('cancel'), array('chooselicense', 'repository'), array('author', 'repository'),array('next', 'moodle'),
array('ok', 'moodle'), array('error', 'moodle'), array('info', 'moodle'), array('norepositoriesavailable', 'repository'), array('norepositoriesexternalavailable', 'repository'),
array('nofilesattached', 'repository'), array('filepicker', 'repository'),
array('nofilesavailable', 'repository'), array('overwrite', 'repository'),
diff --git a/lib/searchlib.php b/lib/searchlib.php
index 75baa499402..c9512e98fdc 100644
--- a/lib/searchlib.php
+++ b/lib/searchlib.php
@@ -359,14 +359,14 @@ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfie
/// First of all, search for reasons to switch to standard SQL generation
/// Only mysql are supported for now
- if ($DB->get_db_family() != 'mysql') {
+ if ($DB->get_dbfamily() != 'mysql') {
return search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,
$userfirstnamefield, $userlastnamefield, $timefield, $instancefield);
}
/// Some languages don't have "word separators" and MySQL FULLTEXT doesn't perform well with them, so
/// switch to standard SQL search generation
- if ($DB->get_db_family() == 'mysql') {
+ if ($DB->get_dbfamily() == 'mysql') {
$nonseparatedlangs = array('ja', 'th', 'zh_cn', 'zh_tw');
if (in_array(current_language(), $nonseparatedlangs)) {
return search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,
@@ -445,12 +445,12 @@ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfie
$text_sql_string .= ', ' . $metafield;
}
/// Begin with the AGAINST clause
- $text_sql_string .= ') AGAINST (' . "'";
+ $text_sql_string .= ') AGAINST (';
/// Add the search terms
$text_sql_string .= ':sgt'.$p;
$params['sgt'.$p++] = trim($datasearch_clause);
/// Close AGAINST clause
- $text_sql_string .= "' IN BOOLEAN MODE)";
+ $text_sql_string .= " IN BOOLEAN MODE)";
}
}
/// Now add the metasearch_clause
@@ -463,12 +463,12 @@ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfie
}
$text_sql_string .= 'MATCH (' . $metafield;
/// Begin with the AGAINST clause
- $text_sql_string .= ') AGAINST (' . "'";
+ $text_sql_string .= ') AGAINST (';
/// Add the search terms
$text_sql_string .= ':sgt'.$p;
$params['sgt'.$p++] = trim($metasearch_clause);
/// Close AGAINST clause
- $text_sql_string .= "' IN BOOLEAN MODE)";
+ $text_sql_string .= " IN BOOLEAN MODE)";
}
}
/// Finally add the non-text conditions
diff --git a/message/edit.php b/message/edit.php
index 17e0e75b222..a231b25553b 100644
--- a/message/edit.php
+++ b/message/edit.php
@@ -31,12 +31,9 @@ $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults
$disableall = optional_param('disableall', 0, PARAM_BOOL); //disable all of this user's notifications
$url = new moodle_url('/message/edit.php');
-if ($userid !== $USER->id) {
- $url->param('id', $userid);
-}
-if ($course != SITEID) {
- $url->param('course', $course);
-}
+$url->param('id', $userid);
+$url->param('course', $course);
+
$PAGE->set_url($url);
if (!$course = $DB->get_record('course', array('id' => $course))) {
diff --git a/message/lib.php b/message/lib.php
index cd4f5242163..01ffd2c765c 100644
--- a/message/lib.php
+++ b/message/lib.php
@@ -816,6 +816,12 @@ function message_print_recent_conversations($user=null, $showicontext=false) {
$conversations = message_get_recent_conversations($user);
+ // Attach context url information to create the "View this conversation" type links
+ foreach($conversations as $conversation) {
+ $conversation->contexturl = new moodle_url("/message/index.php?user2={$conversation->id}");
+ $conversation->contexturlname = get_string('thisconversation', 'message');
+ }
+
$showotheruser = true;
message_print_recent_messages_table($conversations, $user, $showotheruser, $showicontext);
}
diff --git a/mod/feedback/edit.php b/mod/feedback/edit.php
index 3eeb7a4e235..67b7b6da408 100644
--- a/mod/feedback/edit.php
+++ b/mod/feedback/edit.php
@@ -349,10 +349,10 @@ if ($do_show == 'edit') {
echo '';
if ($feedbackitem->required == 1) {
$buttontitle = get_string('switch_item_to_not_required', 'feedback');
- $buttonimg = 'pics/required.gif';
+ $buttonimg = $OUTPUT->pix_url('required', 'feedback');
} else {
$buttontitle = get_string('switch_item_to_required', 'feedback');
- $buttonimg = 'pics/notrequired.gif';
+ $buttonimg = $OUTPUT->pix_url('notrequired', 'feedback');
}
$urlparams = array('switchitemrequired'=>$feedbackitem->id);
$requiredurl = new moodle_url($url, $urlparams);
diff --git a/mod/feedback/item/multichoice/lib.php b/mod/feedback/item/multichoice/lib.php
index 3f46a1054aa..4c836e0d850 100644
--- a/mod/feedback/item/multichoice/lib.php
+++ b/mod/feedback/item/multichoice/lib.php
@@ -216,6 +216,7 @@ class feedback_item_multichoice extends feedback_item_base {
}
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
+ global $OUTPUT;
$sep_dec = get_string('separator_decimal', 'feedback');
if (substr($sep_dec, 0, 2) == '[[') {
$sep_dec = FEEDBACK_DECIMAL;
@@ -237,7 +238,7 @@ class feedback_item_multichoice extends feedback_item_base {
$pixnr = 0;
foreach ($analysed_vals as $val) {
$intvalue = $pixnr % 10;
- $pix = "pics/$intvalue.gif";
+ $pix = $OUTPUT->pix_url('multichoice/' . $intvalue, 'feedback');
$pixnr++;
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
$quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous);
diff --git a/mod/feedback/item/multichoicerated/lib.php b/mod/feedback/item/multichoicerated/lib.php
index 9787dcb236a..050f7ebc050 100644
--- a/mod/feedback/item/multichoicerated/lib.php
+++ b/mod/feedback/item/multichoicerated/lib.php
@@ -192,6 +192,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
}
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
+ global $OUTPUT;
$sep_dec = get_string('separator_decimal', 'feedback');
if (substr($sep_dec, 0, 2) == '[[') {
$sep_dec = FEEDBACK_DECIMAL;
@@ -212,7 +213,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
$avg = 0.0;
foreach ($analysed_vals as $val) {
$intvalue = $pixnr % 10;
- $pix = "pics/$intvalue.gif";
+ $pix = $OUTPUT->pix_url('multichoice/' . $intvalue, 'feedback');
$pixnr++;
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
diff --git a/mod/feedback/pics/0.gif b/mod/feedback/pix/multichoice/0.gif
similarity index 100%
rename from mod/feedback/pics/0.gif
rename to mod/feedback/pix/multichoice/0.gif
diff --git a/mod/feedback/pics/1.gif b/mod/feedback/pix/multichoice/1.gif
similarity index 100%
rename from mod/feedback/pics/1.gif
rename to mod/feedback/pix/multichoice/1.gif
diff --git a/mod/feedback/pics/2.gif b/mod/feedback/pix/multichoice/2.gif
similarity index 100%
rename from mod/feedback/pics/2.gif
rename to mod/feedback/pix/multichoice/2.gif
diff --git a/mod/feedback/pics/3.gif b/mod/feedback/pix/multichoice/3.gif
similarity index 100%
rename from mod/feedback/pics/3.gif
rename to mod/feedback/pix/multichoice/3.gif
diff --git a/mod/feedback/pics/4.gif b/mod/feedback/pix/multichoice/4.gif
similarity index 100%
rename from mod/feedback/pics/4.gif
rename to mod/feedback/pix/multichoice/4.gif
diff --git a/mod/feedback/pics/5.gif b/mod/feedback/pix/multichoice/5.gif
similarity index 100%
rename from mod/feedback/pics/5.gif
rename to mod/feedback/pix/multichoice/5.gif
diff --git a/mod/feedback/pics/6.gif b/mod/feedback/pix/multichoice/6.gif
similarity index 100%
rename from mod/feedback/pics/6.gif
rename to mod/feedback/pix/multichoice/6.gif
diff --git a/mod/feedback/pics/7.gif b/mod/feedback/pix/multichoice/7.gif
similarity index 100%
rename from mod/feedback/pics/7.gif
rename to mod/feedback/pix/multichoice/7.gif
diff --git a/mod/feedback/pics/8.gif b/mod/feedback/pix/multichoice/8.gif
similarity index 100%
rename from mod/feedback/pics/8.gif
rename to mod/feedback/pix/multichoice/8.gif
diff --git a/mod/feedback/pics/9.gif b/mod/feedback/pix/multichoice/9.gif
similarity index 100%
rename from mod/feedback/pics/9.gif
rename to mod/feedback/pix/multichoice/9.gif
diff --git a/mod/feedback/pics/notrequired.gif b/mod/feedback/pix/notrequired.gif
similarity index 100%
rename from mod/feedback/pics/notrequired.gif
rename to mod/feedback/pix/notrequired.gif
diff --git a/mod/feedback/pics/required.gif b/mod/feedback/pix/required.gif
similarity index 100%
rename from mod/feedback/pics/required.gif
rename to mod/feedback/pix/required.gif
diff --git a/mod/folder/edit.php b/mod/folder/edit.php
index dc66f941c4f..161745c70ef 100644
--- a/mod/folder/edit.php
+++ b/mod/folder/edit.php
@@ -58,6 +58,7 @@ if ($mform->is_cancelled()) {
} else if ($formdata = $mform->get_data()) {
$formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0);
+ $DB->set_field('folder', 'revision', $folder->revision+1, array('id'=>$folder->id));
redirect(new moodle_url('/mod/folder/view.php', array('id'=>$cm->id)));
}
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index 90e145c799a..c4b9dd1ed91 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -2882,7 +2882,12 @@ function glossary_comment_validate($comment_param) {
if (!$record = $DB->get_record('glossary_entries', array('id'=>$comment_param->itemid))) {
throw new comment_exception('invalidcommentitemid');
}
- if (!$glossary = $DB->get_record('glossary', array('id'=>$record->glossaryid))) {
+ if ($record->sourceglossaryid && $record->sourceglossaryid == $comment_param->cm->instance) {
+ $glossary = $DB->get_record('glossary', array('id'=>$record->sourceglossaryid));
+ } else {
+ $glossary = $DB->get_record('glossary', array('id'=>$record->glossaryid));
+ }
+ if (!$glossary) {
throw new comment_exception('invalidid', 'data');
}
if (!$course = $DB->get_record('course', array('id'=>$glossary->course))) {
diff --git a/mod/lesson/pagetypes/multichoice.php b/mod/lesson/pagetypes/multichoice.php
index 7ab9d2cd0e7..f9307560885 100644
--- a/mod/lesson/pagetypes/multichoice.php
+++ b/mod/lesson/pagetypes/multichoice.php
@@ -145,8 +145,7 @@ class lesson_page_type_multichoice extends lesson_page {
$answers = $this->get_used_answers();
$ncorrect = 0;
$nhits = 0;
- $correctresponse = '';
- $wrongresponse = '';
+ $responses = array();
$correctanswerid = 0;
$wronganswerid = 0;
// store student's answers for displaying on feedback page
@@ -155,6 +154,9 @@ class lesson_page_type_multichoice extends lesson_page {
foreach ($studentanswers as $answerid) {
if ($answerid == $answer->id) {
$result->studentanswer .= ' '.format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
+ if (trim(strip_tags($answer->response))) {
+ $responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
+ }
}
}
}
@@ -182,10 +184,6 @@ class lesson_page_type_multichoice extends lesson_page {
if ($correctanswerid == 0) {
$correctanswerid = $answer->id;
}
- // ...also save any response from the correct answers...
- if (trim(strip_tags($answer->response))) {
- $correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
- }
} else {
// save the first jumpto page id, may be needed!...
if (!isset($wrongpageid)) {
@@ -196,10 +194,6 @@ class lesson_page_type_multichoice extends lesson_page {
if ($wronganswerid == 0) {
$wronganswerid = $answer->id;
}
- // ...and from the incorrect ones, don't know which to use at this stage
- if (trim(strip_tags($answer->response))) {
- $wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
- }
}
}
} else {
@@ -220,10 +214,6 @@ class lesson_page_type_multichoice extends lesson_page {
if ($correctanswerid == 0) {
$correctanswerid = $answer->id;
}
- // ...also save any response from the correct answers...
- if (trim(strip_tags($answer->response))) {
- $correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
- }
} else {
// save the first jumpto page id, may be needed!...
if (!isset($wrongpageid)) {
@@ -234,20 +224,16 @@ class lesson_page_type_multichoice extends lesson_page {
if ($wronganswerid == 0) {
$wronganswerid = $answer->id;
}
- // ...and from the incorrect ones, don't know which to use at this stage
- if (trim(strip_tags($answer->response))) {
- $wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
- }
}
}
}
if ((count($studentanswers) == $ncorrect) and ($nhits == $ncorrect)) {
$result->correctanswer = true;
- $result->response = $correctresponse;
+ $result->response = implode(' ', $responses);
$result->newpageid = $correctpageid;
$result->answerid = $correctanswerid;
} else {
- $result->response = $wrongresponse;
+ $result->response = implode(' ', $responses);
$result->newpageid = $wrongpageid;
$result->answerid = $wronganswerid;
}
diff --git a/mod/quiz/module.js b/mod/quiz/module.js
index 63c44d65d8d..3ac6032be1d 100644
--- a/mod/quiz/module.js
+++ b/mod/quiz/module.js
@@ -143,6 +143,29 @@ M.mod_quiz.nav.init = function(Y) {
var form = Y.one('#responseform');
if (form) {
+ function find_enabled_submit() {
+ // This is rather inelegant, but the CSS3 selector
+ // return form.one('input[type=submit]:enabled');
+ // does not work in IE7, 8 or 9 for me.
+ var enabledsubmit = null;
+ form.all('input[type=submit]').each(function(submit) {
+ if (!enabledsubmit && !submit.get('disabled')) {
+ enabledsubmit = submit;
+ }
+ });
+ return enabledsubmit;
+ }
+
+ function nav_to_page(pageno) {
+ Y.one('#followingpage').set('value', pageno);
+
+ // Automatically submit the form. We do it this strange way because just
+ // calling form.submit() does not run the form's submit event handlers.
+ var submit = find_enabled_submit();
+ submit.set('name', '');
+ submit.getDOMNode().click();
+ };
+
Y.delegate('click', function(e) {
if (this.hasClass('thispage')) {
return;
@@ -157,22 +180,20 @@ M.mod_quiz.nav.init = function(Y) {
} else {
pageno = 0;
}
- Y.one('#followingpage').set('value', pageno);
var questionidmatch = this.get('href').match(/#q(\d+)/);
if (questionidmatch) {
form.set('action', form.get('action') + '#q' + questionidmatch[1]);
}
- form.submit();
+ nav_to_page(pageno);
}, document.body, '.qnbutton');
}
if (Y.one('a.endtestlink')) {
Y.on('click', function(e) {
e.preventDefault();
- Y.one('#followingpage').set('value', -1);
- Y.one('#responseform').submit();
+ nav_to_page(-1);
}, 'a.endtestlink');
}
diff --git a/mod/wiki/admin.php b/mod/wiki/admin.php
index 1b8ea47ce39..b2b720b1d76 100644
--- a/mod/wiki/admin.php
+++ b/mod/wiki/admin.php
@@ -58,7 +58,8 @@ require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:managewiki', $context);
-add_to_log($course->id, "wiki", "admin", "admin.php?id=$cm->id", "$wiki->id");
+
+add_to_log($course->id, "wiki", "admin", "admin.php?pageid=".$page->id, $page->id, $cm->id);
//Delete page if a page ID to delete was supplied
if (!empty($delete) && confirm_sesskey()) {
diff --git a/mod/wiki/comments.php b/mod/wiki/comments.php
index a2699044e88..3032dba5080 100644
--- a/mod/wiki/comments.php
+++ b/mod/wiki/comments.php
@@ -59,7 +59,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
require_login($course->id, true, $cm);
-add_to_log($course->id, 'wiki', 'comments', 'comments.php?id=' . $cm->id, $wiki->id);
+add_to_log($course->id, 'wiki', 'comments', "comments.php?pageid=".$pageid, $pageid, $cm->id);
/// Print the page header
$wikipage = new page_wiki_comments($wiki, $subwiki, $cm);
diff --git a/mod/wiki/create.php b/mod/wiki/create.php
index 19e571f2259..d9e8d2d8d0e 100644
--- a/mod/wiki/create.php
+++ b/mod/wiki/create.php
@@ -66,8 +66,6 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
require_login($course->id, true, $cm);
-add_to_log($course->id, 'createpage', 'createpage', 'view.php?id=' . $cm->id, $wiki->id);
-
$wikipage = new page_wiki_create($wiki, $subwiki, $cm);
if (!empty($swid)) {
@@ -80,22 +78,25 @@ if (!empty($swid)) {
$wikipage->set_uid($uid);
}
-if (!empty($title)) {
- $wikipage->set_title($title);
-} else {
- $wikipage->set_title(get_string('newpage', 'wiki'));
+if (empty($title)) {
+ $title = get_string('newpage', 'wiki');
}
+$wikipage->set_title($title);
// set page action, and initialise moodle form
$wikipage->set_action($action);
switch ($action) {
case 'create':
- $wikipage->create_page($title);
+ $newpageid = $wikipage->create_page($title);
+ add_to_log($course->id, 'wiki', 'add page', "view.php?pageid=".$newpageid, $newpageid, $cm->id);
+ redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid='.$newpageid);
break;
case 'new':
if ((int)$wiki->forceformat == 1 && !empty($title)) {
- $wikipage->create_page($title);
+ $newpageid = $wikipage->create_page($title);
+ add_to_log($course->id, 'wiki', 'add page', "view.php?pageid=".$newpageid, $newpageid, $cm->id);
+ redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid='.$newpageid);
} else {
// create link from moodle navigation block without pagetitle
$wikipage->print_header();
diff --git a/mod/wiki/db/migration/wiki/ewikimoodlelib.php b/mod/wiki/db/migration/wiki/ewikimoodlelib.php
index abb0da763dd..859fe528e0b 100644
--- a/mod/wiki/db/migration/wiki/ewikimoodlelib.php
+++ b/mod/wiki/db/migration/wiki/ewikimoodlelib.php
@@ -192,7 +192,7 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
array("flags","meta","lastmodified");
*/
case "GETALL":
- switch ($DB->get_db_family()) {
+ switch ($DB->get_dbfamily()) {
case 'postgres':
// All but the latest version eliminated by DISTINCT
// ON (pagename)
diff --git a/mod/wiki/diff.php b/mod/wiki/diff.php
index cf620960c65..c5eed893598 100644
--- a/mod/wiki/diff.php
+++ b/mod/wiki/diff.php
@@ -67,13 +67,14 @@ if ($compare >= $comparewith) {
}
require_login($course->id, true, $cm);
-add_to_log($course->id, "wiki", "diff", "diff.php?id=$cm->id", "$wiki->id");
$wikipage = new page_wiki_diff($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->set_comparison($compare, $comparewith);
+add_to_log($course->id, "wiki", "diff", "diff.php?pageid=".$pageid."&comparewith=".$comparewith."&compare=".$compare, $pageid, $cm->id);
+
$wikipage->print_header();
$wikipage->print_content();
diff --git a/mod/wiki/edit.php b/mod/wiki/edit.php
index f750718976e..7be82afcb38 100644
--- a/mod/wiki/edit.php
+++ b/mod/wiki/edit.php
@@ -77,8 +77,6 @@ require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:editpage', $context);
-add_to_log($course->id, 'wiki', 'edit', "edit.php?id=$cm->id", "$wiki->id");
-
if ($option == get_string('save', 'wiki')) {
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
@@ -87,6 +85,7 @@ if ($option == get_string('save', 'wiki')) {
$wikipage->set_page($page);
$wikipage->set_newcontent($newcontent);
$wikipage->set_upload(true);
+ add_to_log($course->id, 'wiki', 'edit', "view.php?pageid=".$pageid, $pageid, $cm->id);
} else {
if ($option == get_string('preview')) {
if (!confirm_sesskey()) {
diff --git a/mod/wiki/history.php b/mod/wiki/history.php
index 3b8a344c396..59851b1e2a8 100644
--- a/mod/wiki/history.php
+++ b/mod/wiki/history.php
@@ -61,7 +61,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, 'wiki', 'history', 'history.php?id=' . $cm->id, $wiki->id);
+add_to_log($course->id, 'wiki', 'history', "history.php?pageid=".$pageid, $pageid, $cm->id);
/// Print the page header
$wikipage = new page_wiki_history($wiki, $subwiki, $cm);
diff --git a/mod/wiki/index.php b/mod/wiki/index.php
index d1db74a22d9..7f13ee24a4e 100644
--- a/mod/wiki/index.php
+++ b/mod/wiki/index.php
@@ -45,7 +45,7 @@ require_login($course->id, true);
$PAGE->set_pagelayout('incourse');
$context = get_context_instance(CONTEXT_COURSE, $course->id);
-add_to_log($course->id, 'wiki', 'view all', "index.php?id=$course->id", "");
+add_to_log($course->id, 'wiki', 'view', "index.php?id=".$id, "");
/// Get all required stringswiki
$strwikis = get_string("modulenameplural", "wiki");
diff --git a/mod/wiki/instancecomments.php b/mod/wiki/instancecomments.php
index 80aa4277faf..4467b171e96 100644
--- a/mod/wiki/instancecomments.php
+++ b/mod/wiki/instancecomments.php
@@ -94,12 +94,12 @@ if ($action == 'delete') {
if ($action == 'edit') {
$comm->set_action($action, $id, $content);
-
} else {
$action = 'add';
$comm->set_action($action, 0, $content);
}
}
+add_to_log($course->id, 'wiki', 'comment', "comments.php?pageid=".$pageid, $pageid, $cm->id);
$comm->print_header();
$comm->print_content();
diff --git a/mod/wiki/lock.php b/mod/wiki/lock.php
index 562aabfcf01..d82a0f0db1b 100644
--- a/mod/wiki/lock.php
+++ b/mod/wiki/lock.php
@@ -71,8 +71,6 @@ require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:editpage', $context);
-//add_to_log($course->id, "wiki", "lock", "lock.php?id=$cm->id", "$wiki->id");
-
$wikipage = new page_wiki_lock($wiki, $subwiki, $cm);
$wikipage->set_page($page);
diff --git a/mod/wiki/map.php b/mod/wiki/map.php
index 341667bfcf6..edd49d1c8b8 100644
--- a/mod/wiki/map.php
+++ b/mod/wiki/map.php
@@ -56,13 +56,11 @@ if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, "wiki", "map", "map.php?id=$cm->id", "$wiki->id");
-/// Print page header
-
-/// Finish the page
$wikipage = new page_wiki_map($wiki, $subwiki, $cm);
+add_to_log($course->id, "wiki", "map", "map.php?pageid=".$pageid, $pageid, $cm->id);
+// Print page header
$wikipage->set_view($option);
$wikipage->set_page($page);
$wikipage->print_header();
diff --git a/mod/wiki/overridelocks.php b/mod/wiki/overridelocks.php
index e4c516499d7..f725976f3de 100644
--- a/mod/wiki/overridelocks.php
+++ b/mod/wiki/overridelocks.php
@@ -67,8 +67,6 @@ require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:overridelock', $context);
-add_to_log($course->id, "wiki", "overridelocks", "overridelocks.php?id=$cm->id", "$wiki->id");
-
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
}
@@ -79,6 +77,7 @@ $wikipage->set_page($page);
if (!empty($section)) {
$wikipage->set_section($sectioncontent, $section);
}
+add_to_log($course->id, "wiki", "overridelocks", "view.php?pageid=".$pageid, $pageid, $cm->id);
$wikipage->print_header();
diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php
index d14c92b498f..ecf3ff3efb8 100644
--- a/mod/wiki/pagelib.php
+++ b/mod/wiki/pagelib.php
@@ -935,11 +935,14 @@ class page_wiki_create extends page_wiki {
$this->subwiki = wiki_get_subwiki($swid);
}
if ($data) {
+ $this->set_title($data->pagetitle);
$id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
} else {
+ $this->set_title($pagetitle);
$id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
}
- redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $id);
+ $this->page = $id;
+ return $id;
}
}
diff --git a/mod/wiki/prettyview.php b/mod/wiki/prettyview.php
index 30a19ea1a3b..6556ed76488 100644
--- a/mod/wiki/prettyview.php
+++ b/mod/wiki/prettyview.php
@@ -56,11 +56,10 @@ require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, "wiki", "view", "prettyview.php?pageid=$pageid", "$wiki->id");
-
$wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
$wikipage->set_page($page);
+add_to_log($course->id, "wiki", "view", "prettyview.php?pageid=".$pageid, $pageid, $cm->id);
$wikipage->print_header();
$wikipage->print_content();
diff --git a/mod/wiki/restoreversion.php b/mod/wiki/restoreversion.php
index a959b322565..eba4e2379f9 100644
--- a/mod/wiki/restoreversion.php
+++ b/mod/wiki/restoreversion.php
@@ -60,8 +60,6 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
require_login($course->id, true, $cm);
-add_to_log($course->id, "restore", "restore", "view.php?id=$cm->id", "$wiki->id");
-
if ($confirm) {
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
@@ -77,6 +75,7 @@ if ($confirm) {
$wikipage->set_versionid($versionid);
}
+add_to_log($course->id, "wiki", "restore", "view.php?pageid=".$pageid, $pageid, $cm->id);
$wikipage->print_header();
$wikipage->print_content();
diff --git a/mod/wiki/view.php b/mod/wiki/view.php
index c29bfeccada..85e81e8f500 100644
--- a/mod/wiki/view.php
+++ b/mod/wiki/view.php
@@ -269,8 +269,6 @@ require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, 'wiki', 'view', 'view.php?id=' . $cm->id, $wiki->id);
-
// Update 'viewed' state if required by completion system
require_once($CFG->libdir . '/completionlib.php');
$completion = new completion_info($course);
@@ -294,6 +292,14 @@ if ($id) {
$wikipage->set_gid($currentgroup);
$wikipage->set_page($page);
+if($pageid) {
+ add_to_log($course->id, 'wiki', 'view', "view.php?pageid=".$pageid, $pageid, $cm->id);
+} else if($id) {
+ add_to_log($course->id, 'wiki', 'view', "view.php?id=".$id, $id, $cm->id);
+} else if($wid && $title) {
+ add_to_log($course->id, 'wiki', 'view', "view.php?wid=".$wid."&title=".$title, $wid, $cm->id);
+}
+
$wikipage->print_header();
$wikipage->print_content();
diff --git a/mod/wiki/viewversion.php b/mod/wiki/viewversion.php
index ca420d24f5b..fb36789e173 100644
--- a/mod/wiki/viewversion.php
+++ b/mod/wiki/viewversion.php
@@ -59,14 +59,15 @@ if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course->id, true, $cm);
-add_to_log($course->id, "wiki", "history", "history.php?id=$cm->id", "$wiki->id");
-/// Print the page header
$wikipage = new page_wiki_viewversion($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->set_versionid($versionid);
+add_to_log($course->id, "wiki", "history", "viewversion.php?pageid=".$pageid."&versionid=".$versionid, $pageid, $cm->id);
+
+// Print the page header
$wikipage->print_header();
$wikipage->print_content();
diff --git a/question/editlib.php b/question/editlib.php
index cc13b8f29cf..14368c36a79 100644
--- a/question/editlib.php
+++ b/question/editlib.php
@@ -1430,9 +1430,7 @@ class question_bank_view {
if ($question->id == $this->lastchangedid) {
$classes[] ='highlight';
}
- if (!empty($this->extrarows)) {
- $classes[] = 'r' . ($rowcount % 2);
- }
+ $classes[] = 'r' . ($rowcount % 2);
return $classes;
}
diff --git a/question/engine/questionattempt.php b/question/engine/questionattempt.php
index bde5115d062..4a2253ebcef 100644
--- a/question/engine/questionattempt.php
+++ b/question/engine/questionattempt.php
@@ -884,10 +884,10 @@ class question_attempt {
case self::PARAM_MARK:
// Special case to work around PARAM_NUMBER converting '' to 0.
$mark = $this->get_submitted_var($name, PARAM_RAW_TRIMMED, $postdata);
- if ($mark === '') {
+ if ($mark === '' || is_null($mark)) {
return $mark;
} else {
- return $this->get_submitted_var($name, PARAM_NUMBER, $postdata);
+ return clean_param(str_replace(',', '.', $mark), PARAM_NUMBER);
}
case self::PARAM_FILES:
diff --git a/question/engine/simpletest/testquestionattempt.php b/question/engine/simpletest/testquestionattempt.php
index 84a4d4679ad..b4fe736b8b0 100644
--- a/question/engine/simpletest/testquestionattempt.php
+++ b/question/engine/simpletest/testquestionattempt.php
@@ -123,6 +123,16 @@ class question_attempt_test extends UnitTestCase {
'name', question_attempt::PARAM_MARK, array('name' => '123')));
}
+ public function test_get_submitted_var_param_mark_number_uk_decimal() {
+ $this->assertIdentical(123.45, $this->qa->get_submitted_var(
+ 'name', question_attempt::PARAM_MARK, array('name' => '123.45')));
+ }
+
+ public function test_get_submitted_var_param_mark_number_eu_decimal() {
+ $this->assertIdentical(123.45, $this->qa->get_submitted_var(
+ 'name', question_attempt::PARAM_MARK, array('name' => '123,45')));
+ }
+
public function test_get_submitted_var_param_mark_invalid() {
$this->assertIdentical(0.0, $this->qa->get_submitted_var(
'name', question_attempt::PARAM_MARK, array('name' => 'frog')));
diff --git a/question/qbank.js b/question/qbank.js
index 69cf07fc3cf..5f82f53bd26 100644
--- a/question/qbank.js
+++ b/question/qbank.js
@@ -44,7 +44,7 @@ question_bank = {
question_bank.firstcheckbox = document.getElementById(firstcbid);
// Add the event handler.
- YAHOO.util.Event.addListener(question_bank.headercheckbox, 'change', question_bank.header_checkbox_click);
+ YAHOO.util.Event.addListener(question_bank.headercheckbox, 'click', question_bank.header_checkbox_click);
},
header_checkbox_click: function() {
diff --git a/repository/filepicker.js b/repository/filepicker.js
index 72d0a5668e8..8d8a6f7ef11 100644
--- a/repository/filepicker.js
+++ b/repository/filepicker.js
@@ -149,7 +149,11 @@ M.core_filepicker.init = function(Y, options) {
// error checking
if (data && data.error) {
scope.print_msg(data.error, 'error');
- scope.list();
+ if (args.onerror) {
+ args.onerror(id,data,p);
+ } else {
+ Y.one(panel_id).set('innerHTML', '');
+ }
return;
} else if (data && data.event) {
switch (data.event) {
@@ -678,6 +682,9 @@ M.core_filepicker.init = function(Y, options) {
client_id: client_id,
repository_id: repository_id,
'params': params,
+ onerror: function(id, obj, args) {
+ scope.view_files();
+ },
callback: function(id, obj, args) {
if (scope.options.editor_target && scope.options.env=='editor') {
scope.options.editor_target.value=obj.url;
@@ -1188,6 +1195,9 @@ M.core_filepicker.init = function(Y, options) {
params: {'savepath':scope.options.savepath},
repository_id: scope.active_repo.id,
form: {id: id, upload:true},
+ onerror: function(id, o, args) {
+ scope.create_upload_form(data);
+ },
callback: function(id, o, args) {
if (scope.options.editor_target&&scope.options.env=='editor') {
scope.options.editor_target.value=o.url;
@@ -1370,15 +1380,21 @@ M.core_filepicker.init = function(Y, options) {
var r = this.active_repo;
var str = '';
var action = '';
- if(r.pages > 1) {
+ var lastpage = r.pages;
+ var lastpagetext = r.pages;
+ if (r.pages == -1) {
+ lastpage = r.page + 1;
+ lastpagetext = M.str.moodle.next;
+ }
+ if (lastpage > 1) {
str += '
';
str += this.get_page_button(1)+'1 ';
var span = 5;
var ex = (span-1)/2;
- if (r.page+ex>=r.pages) {
- var max = r.pages;
+ if (r.page+ex>=lastpage) {
+ var max = lastpage;
} else {
if (r.page';
+ if (max==lastpage) {
+ str += this.get_page_button(lastpage)+lastpagetext+'';
} else {
str += this.get_page_button(max)+max+'';
- str += ' ... '+this.get_page_button(r.pages)+r.pages+'';
+ str += ' ... '+this.get_page_button(lastpage)+lastpagetext+'';
}
str += '
';
}
diff --git a/repository/filepicker.php b/repository/filepicker.php
index b7b1a65f3f3..68aee10060b 100644
--- a/repository/filepicker.php
+++ b/repository/filepicker.php
@@ -206,9 +206,23 @@ case 'sign':
}
}
if (!empty($list['page'])) {
- // TODO: need a better solution
- $pagingurl = new moodle_url("$CFG->httpswwwroot/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id&course=$courseid");
- echo $OUTPUT->paging_bar($list['total'], $list['page'] - 1, $list['perpage'], $pagingurl);
+ // TODO MDL-28482: need a better solution
+ // paging_bar is not a good option because it starts page numbering from 0 and
+ // repositories number pages starting from 1.
+ $pagingurl = new moodle_url("$CFG->httpswwwroot/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id&course=$courseid&sesskey=". sesskey());
+ if (!isset($list['perpage']) && !isset($list['total'])) {
+ $list['perpage'] = 10; // instead of setting perpage&total we use number of pages, the result is the same
+ }
+ if (empty($list['total'])) {
+ if ($list['pages'] == -1) {
+ $total = ($list['page'] + 2) * $list['perpage'];
+ } else {
+ $total = $list['pages'] * $list['perpage'];
+ }
+ } else {
+ $total = $list['total'];
+ }
+ echo $OUTPUT->paging_bar($total, $list['page'], $list['perpage'], $pagingurl);
}
echo '
';
foreach ($list['list'] as $item) {
diff --git a/repository/repository_ajax.php b/repository/repository_ajax.php
index ccf55cdaa0f..b7793c8b9b0 100644
--- a/repository/repository_ajax.php
+++ b/repository/repository_ajax.php
@@ -66,7 +66,7 @@ if (empty($_POST) && !empty($action)) {
}
if (!confirm_sesskey()) {
- $err->error = get_string('invalidsesskey');
+ $err->error = get_string('invalidsesskey', 'error');
die(json_encode($err));
}
diff --git a/repository/wikimedia/lib.php b/repository/wikimedia/lib.php
index adc3d25d947..8a827afa95b 100644
--- a/repository/wikimedia/lib.php
+++ b/repository/wikimedia/lib.php
@@ -31,17 +31,41 @@ require_once('wikimedia.php');
class repository_wikimedia extends repository {
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
+ global $SESSION;
parent::__construct($repositoryid, $context, $options);
$this->keyword = optional_param('wikimedia_keyword', '', PARAM_RAW);
if (empty($this->keyword)) {
$this->keyword = optional_param('s', '', PARAM_RAW);
}
+ $sess_keyword = 'wikimedia_'.$this->id.'_keyword';
+ if (empty($this->keyword) && optional_param('page', '', PARAM_RAW)) {
+ // This is the request of another page for the last search, retrieve the cached keyword
+ if (isset($SESSION->{$sess_keyword})) {
+ $this->keyword = $SESSION->{$sess_keyword};
+ }
+ } else if (!empty($this->keyword)) {
+ // save the search keyword in the session so we can retrieve it later
+ $SESSION->{$sess_keyword} = $this->keyword;
+ }
}
public function get_listing($path = '', $page = '') {
$client = new wikimedia;
$list = array();
- $list['list'] = $client->search_images($this->keyword);
+ $list['page'] = (int)$page;
+ if ($list['page'] < 1) {
+ $list['page'] = 1;
+ }
+ $list['list'] = $client->search_images($this->keyword, $list['page'] - 1);
$list['nologin'] = true;
+ $list['norefresh'] = true;
+ $list['nosearch'] = true;
+ if (!empty($list['list'])) {
+ $list['pages'] = -1; // means we don't know exactly how many pages there are but we can always jump to the next page
+ } else if ($list['page'] > 1) {
+ $list['pages'] = $list['page']; // no images available on this page, this is the last page
+ } else {
+ $list['pages'] = 0; // no paging
+ }
return $list;
}
// login
@@ -57,10 +81,24 @@ class repository_wikimedia extends repository {
$keyword->type = 'text';
$keyword->name = 'wikimedia_keyword';
$keyword->value = '';
-
- $form = array();
- $form['login'] = array($keyword);
- return $form;
+ if ($this->options['ajax']) {
+ $form = array();
+ $form['login'] = array($keyword);
+ $form['nologin'] = true;
+ $form['norefresh'] = true;
+ $form['nosearch'] = true;
+ $form['allowcaching'] = true; // indicates that login form can be cached in filepicker.js
+ return $form;
+ } else {
+ echo <<
+
+
{$keyword->label}
+
+
+
+EOD;
+ }
}
//search
// if this plugin support global search, if this function return
diff --git a/repository/wikimedia/wikimedia.php b/repository/wikimedia/wikimedia.php
index 549b394dbb9..ce186b8f21e 100644
--- a/repository/wikimedia/wikimedia.php
+++ b/repository/wikimedia/wikimedia.php
@@ -141,13 +141,14 @@ class wikimedia {
* @param string $keyword
* @return array
*/
- public function search_images($keyword) {
+ public function search_images($keyword, $page = 0) {
$files_array = array();
$this->_param['action'] = 'query';
$this->_param['generator'] = 'search';
$this->_param['gsrsearch'] = $keyword;
$this->_param['gsrnamespace'] = WIKIMEDIA_FILE_NS;
$this->_param['gsrlimit'] = WIKIMEDIA_THUMBS_PER_PAGE;
+ $this->_param['gsroffset'] = $page * WIKIMEDIA_THUMBS_PER_PAGE;
$this->_param['prop'] = 'imageinfo';
$this->_param['iiprop'] = 'url|dimensions|mime';
$this->_param['iiurlwidth'] = WIKIMEDIA_IMAGE_SIDE_LENGTH;
diff --git a/repository/youtube/lib.php b/repository/youtube/lib.php
index cb0020443cf..19f60b27cbf 100644
--- a/repository/youtube/lib.php
+++ b/repository/youtube/lib.php
@@ -27,6 +27,8 @@
*/
class repository_youtube extends repository {
+ /** @var int maximum number of thumbs per page */
+ const YOUTUBE_THUMBS_PER_PAGE = 27;
/**
* Youtube plugin constructor
@@ -35,9 +37,6 @@ class repository_youtube extends repository {
* @param array $options
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
- $this->start =1;
- $this->max = 27;
- $this->sort = optional_param('youtube_sort', 'relevance', PARAM_TEXT);
parent::__construct($repositoryid, $context, $options);
}
@@ -50,11 +49,40 @@ class repository_youtube extends repository {
* @param string $search_text
* @return array
*/
- public function search($search_text) {
+ public function search($search_text, $page) {
+ global $SESSION;
+ $sort = optional_param('youtube_sort', '', PARAM_TEXT);
+ $sess_keyword = 'youtube_'.$this->id.'_keyword';
+ $sess_sort = 'youtube_'.$this->id.'_sort';
+
+ // This is the request of another page for the last search, retrieve the cached keyword and sort
+ if ($page && !$search_text && isset($SESSION->{$sess_keyword})) {
+ $search_text = $SESSION->{$sess_keyword};
+ }
+ if ($page && !$sort && isset($SESSION->{$sess_sort})) {
+ $sort = $SESSION->{$sess_sort};
+ }
+ if (!$sort) {
+ $sort = 'relevance'; // default
+ }
+
+ // Save this search in session
+ $SESSION->{$sess_keyword} = $search_text;
+ $SESSION->{$sess_sort} = $sort;
+
$this->keyword = $search_text;
$ret = array();
$ret['nologin'] = true;
- $ret['list'] = $this->_get_collection($search_text, $this->start, $this->max, $this->sort);
+ $ret['page'] = (int)$page;
+ if ($ret['page'] < 1) {
+ $ret['page'] = 1;
+ }
+ $start = ($ret['page'] - 1) * self::YOUTUBE_THUMBS_PER_PAGE + 1;
+ $max = self::YOUTUBE_THUMBS_PER_PAGE;
+ $ret['list'] = $this->_get_collection($search_text, $start, $max, $sort);
+ $ret['norefresh'] = true;
+ $ret['nosearch'] = true;
+ $ret['pages'] = -1;
return $ret;
}
@@ -142,6 +170,7 @@ class repository_youtube extends repository {
$ret['login'] = array($search, $sort);
$ret['login_btn_label'] = get_string('search');
$ret['login_btn_action'] = 'search';
+ $ret['allowcaching'] = true; // indicates that login form can be cached in filepicker.js
return $ret;
}
diff --git a/theme/base/style/course.css b/theme/base/style/course.css
index 3062ac629a0..7a457a4a89b 100644
--- a/theme/base/style/course.css
+++ b/theme/base/style/course.css
@@ -123,3 +123,6 @@
#page-course-index.dir-rtl .category .image {padding-left: 5px; padding-right: 0px;}
#page-course-index.dir-rtl .indentation {padding-left: 0px;padding-right: 30px;}
+
+table.category_subcategories {margin-bottom:1em;}
+table.category_subcategories td {white-space: nowrap;}
\ No newline at end of file
diff --git a/theme/fusion/layout/frontpage.php b/theme/fusion/layout/frontpage.php
index 4b499f380a4..c1ca1191d13 100644
--- a/theme/fusion/layout/frontpage.php
+++ b/theme/fusion/layout/frontpage.php
@@ -23,7 +23,7 @@ if ($hascustommenu) {
if (!empty($PAGE->theme->settings->tagline)) {
$tagline = $PAGE->theme->settings->tagline;
} else {
- $tagline = "Another Moodle Theme";
+ $tagline = '';
}
if (!empty($PAGE->theme->settings->footertext)) {
@@ -49,90 +49,90 @@ echo $OUTPUT->doctype() ?>