help Course categories role ?

help Course categories role ?

by judy judy -
Number of replies: 1
Loading capabilities is done when a user first log in.
when has_capability() is called. How do I add Course categories curriculum administrator?





------------------------------------------------------------------------------------------------------------------------

<?php
/**
* Some small modifications for the moodle frontpage
*
* The file tried to change the display of the frontpage. There will be a tree
* menu to show whole categories and courses if nobody logged in. When someone
* logged in, a student role, the page would show whose courses.
*
* The file was modified from 'course\lib.php'.
*
* PHP versions 4 and 5
*
* @copyright Copyright (c) 2008 Buddhist Tzu Chi General Hospital
* @author yuzhou
* @version $Id: frontpage.php,v 22 2008-08-08 yuzhou exp $
*/
require_once $CFG->dirroot.'/course/lib.php';

//define('COURSE_MAX_COURSES_PER_DROPDOWN',1000); // max courses in log dropdown before switching to optional
//define('COURSE_MAX_USERS_PER_DROPDOWN',1000); // max users in log dropdown before switching to optional
define('FRONTPAGE_CATEGORY_LIST', 1);
define('FRONTPAGE_CATEGORY_COMBO', 2);
define('FRONTPAGE_CATEGORY_MENU', 3);
define('FRONTPAGE_COURSE', 4);
define('FRONTPAGE_MY_COURSE', 5);
define('FRONTPAGE_MY_SPECIFIC_COURSE', 6);
//define('FIRSTUSED_EXCEL_ROW', 3);
//define('FRONTPAGE_COURSE_LIMIT', 200); // maximum number of courses displayed on the frontpage

$EL_IMG = '<img src="%s" alt="%s" class="%s" />';
$EL_JS = '<script type="text/javascript" src="%s"></script>';

/**
* Generate an unique string
*
* @param int $num
* @return string
*/
function get_unique_name($num=17)
{
$result = '';
for ($i = 0; $i < $num; $i++) {
$result .= chr(rand(97, 122));
}
return $result;
}

/**
* Integrates the entire possibilities when shows the frontpage. Some states are
* refactored from index.php.
*
* @param constant $type
* @global $CFG;
*/
function print_frontpage($type=FRONTPAGE_CATEGORY_MENU)
{
global $CFG;

switch($type) {
case FRONTPAGE_CATEGORY_LIST:
case FRONTPAGE_CATEGORY_COMBO:
case FRONTPAGE_CATEGORY_MENU:
$clazz = get_unique_name(rand(13, 19));
print_specific_heading_block(get_string('categories'), $clazz);
print_box_start('generalbox categorybox');
print_ajax_whole_menu($clazz);
print_box_end();

echo '<table width="100%"><tr><td align="center">';
print_course_search('', false, 'short');
echo '</td><td>';
print_course_download_button();
echo '</td><td>';
print_temp_link();
echo '</td></tr></table>';
break;

case FRONTPAGE_MY_COURSE:
// Ray: Stduy History
case FRONTPAGE_MY_SPECIFIC_COURSE:
if (isloggedin() and !has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
print_ajax_my_moodle();
print_frontpage(FRONTPAGE_CATEGORY_MENU);
} else {
print_frontpage(FRONTPAGE_CATEGORY_MENU);
}
break;

case FRONTPAGE_COURSE:
print_heading_block(get_string('availablecourses'));
print_courses(0, true);
break;

default:
error('Unknown type for frontpage.');
}
}

/**
* Prints the heading block that contains the icons for effecting the status of
* the tree menu.
*
* @param string $heading - heading block text
* @param string $clazz - value of the tag attribute 'class'
* @global $CFG
*/
function print_specific_heading_block($heading, $clazz='')
{
global $CFG;
global $EL_IMG;

if (empty($clazz)) {
$icons = '';
} else {
$collpase = get_string('collpase');
$expand = get_string('expand');

$colImgEl = sprintf($EL_IMG, "{$CFG->pixpath}/t/switch_minus.gif", $collpase, 'square14');
$expImgEl = sprintf($EL_IMG, "{$CFG->pixpath}/t/switch_plus.gif", $expand, 'square14');

$el = '<a href="javascript:void(0)" Xonclick="%s" title="%s">%s</a> ';
$icons = sprintf($el, "colClass('{$clazz}')", $collpase, $colImgEl)
.sprintf($el, "expClass('{$clazz}')", $expand, $expImgEl);
}

$tbl = <<<EOT
<table style="width:100%"><tr>
<td>{$heading}</td><td style="text-align:right">{$icons}</td>
</tr></table>
EOT;
print_heading_block($tbl);
}

/**
* Show a button for downloading whole courses
*
* @global $CFG
*/
function print_course_download_button()
{
if (has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_SYSTEM))) {
global $CFG;
$download = get_string('fulllistofcoursesdownload');

echo <<<EOT
<form name="clform" method="post" action="{$CFG->wwwroot}/lms/course_xls.php">
<input type="submit" value="{$download}" />
</form>
EOT;
}
//** YCT add link to course categories
//** which allow the priority of course creator
if (has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_SYSTEM))) {
echo <<<EOT
<form name="clform" method="post" action="{$CFG->wwwroot}/course/index.php">
<input type="submit" value=" open course " />
</form>
EOT;
}

}
Attachment _123.PNG
Average of ratings: -
In reply to judy judy

Re: help Course categories role ?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm not sure I understand the question.

Are you asking: "How do I make someone a course creator in just one course category?"

If so,
  1. Admin -> Courses -> Add/edit courses.
  2. Click on the category you want.
  3. Click on the 'Assign roles' link.
  4. Assign the user the course creator role in the usual way.