Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-8450 Added support for including question categories in a quiz ex…

…port.
  • Loading branch information...
commit e2647523810317f38741d8604c56507dd1ce78d5 1 parent 075f610
thepurpleblob authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 lib/questionlib.php
View
24 lib/questionlib.php
@@ -1570,6 +1570,30 @@ function create_category_path( $catpath, $delimiter='/', $courseid=0 ) {
return $category;
}
+/**
+ * get the category as a path (e.g., tom/dick/harry)
+ * @param int id the id of the most nested catgory
+ * @param string delimiter the delimiter you want
+ * @return string the path
+ */
+function get_category_path( $id, $delimiter='/' ) {
+ $path = '';
+ do {
+ if (!$category = get_record( 'question_categories','id',$id )) {
+ print_error( "Error reading category record - $id" );
+ }
+ $name = $category->name;
+ $id = $category->parent;
+ if (!empty($path)) {
+ $path = "{$name}{$delimiter}{$path}";
+ }
+ else {
+ $path = $name;
+ }
+ } while ($id != 0);
+
+ return $path;
+}
//===========================
// Import/Export Functions
Please sign in to comment.
Something went wrong with that request. Please try again.