mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Can now specify course by "short name" using name parameter. Useful for
integrating with external interfaces. Thanks to dopey for the idea.
This commit is contained in:
parent
6f93182a0e
commit
388f8911e3
@ -5,13 +5,25 @@
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
|
||||
optional_variable($id);
|
||||
optional_variable($name);
|
||||
|
||||
if (!$id and !$name) {
|
||||
error("Must specify course id or short name");
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
if (! $course = get_record("course", "shortname", $name) ) {
|
||||
error("That's an invalid short course name");
|
||||
}
|
||||
} else {
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
}
|
||||
|
||||
require_login($id);
|
||||
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
|
||||
|
||||
if ( isteacher($course->id) ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user