mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
Adding the Lesson module to the main CVS. Nice job Ray!
Still needs PostgreSQL support and wider testing
This commit is contained in:
parent
fd9521f6d4
commit
bbcbc0fecc
18 changed files with 2370 additions and 0 deletions
105
mod/lesson/index.php
Normal file
105
mod/lesson/index.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?PHP // $Id$
|
||||
|
||||
/// This page lists all the instances of lesson in a particular course
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); // course
|
||||
|
||||
if (!$course = get_record("course", "id", $id)) {
|
||||
error("Course ID is incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
add_to_log($course->id, "lesson", "view all", "index.php?id=$course->id", "");
|
||||
|
||||
|
||||
/// Get all required strings
|
||||
|
||||
$strlessons = get_string("modulenameplural", "lesson");
|
||||
$strlesson = get_string("modulename", "lesson");
|
||||
|
||||
|
||||
/// Print the header
|
||||
|
||||
if ($course->category) {
|
||||
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
|
||||
}
|
||||
|
||||
print_header("$course->shortname: $strlessons", "$course->fullname", "$navigation $strlessons", "", "", true, "", navmenu($course));
|
||||
|
||||
/// Get all the appropriate data
|
||||
|
||||
if (! $lessons = get_all_instances_in_course("lesson", $course)) {
|
||||
notice("There are no lessons", "../../course/view.php?id=$course->id");
|
||||
die;
|
||||
}
|
||||
|
||||
/// Print the list of instances (your module will probably extend this)
|
||||
|
||||
$timenow = time();
|
||||
$strname = get_string("name");
|
||||
$strgrade = get_string("grade");
|
||||
$strdeadline = get_string("deadline", "lesson");
|
||||
$strweek = get_string("week");
|
||||
$strtopic = get_string("topic");
|
||||
|
||||
if ($course->format == "weeks") {
|
||||
$table->head = array ($strweek, $strname, $strgrade, $strdeadline);
|
||||
$table->align = array ("CENTER", "LEFT", "CENTER", "CENTER");
|
||||
} else if ($course->format == "topics") {
|
||||
$table->head = array ($strtopic, $strname);
|
||||
$table->align = array ("CENTER", "LEFT", "CENTER", "CENTER");
|
||||
} else {
|
||||
$table->head = array ($strname);
|
||||
$table->align = array ("LEFT", "CENTER", "CENTER");
|
||||
}
|
||||
|
||||
foreach ($lessons as $lesson) {
|
||||
if (!$lesson->visible) {
|
||||
//Show dimmed if the mod is hidden
|
||||
$link = "<A class=\"dimmed\" HREF=\"view.php?id=$lesson->coursemodule\">$lesson->name</A>";
|
||||
} else {
|
||||
//Show normal if the mod is visible
|
||||
$link = "<A HREF=\"view.php?id=$lesson->coursemodule\">$lesson->name</A>";
|
||||
}
|
||||
|
||||
if ($lesson->deadline > $timenow) {
|
||||
$due = userdate($lesson->deadline);
|
||||
} else {
|
||||
$due = "<FONT COLOR=\"red\">".userdate($lesson->deadline)."</FONT>";
|
||||
}
|
||||
|
||||
if ($course->format == "weeks" or $course->format == "topics") {
|
||||
if (isteacher($course->id)) {
|
||||
$grade_value = $lesson->grade;
|
||||
} else {
|
||||
// it's a student, show their maximum grade
|
||||
if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND
|
||||
userid = $USER->id", "grade DESC")) {
|
||||
foreach ($grades as $grade) {
|
||||
// grades are stored as percentages
|
||||
$grade_value = number_format($grade->grade * $lesson->grade / 100, 1);
|
||||
break; // only the first (largest) grade needed
|
||||
}
|
||||
} else {
|
||||
$grade_value = 0;
|
||||
}
|
||||
}
|
||||
$table->data[] = array ($lesson->section, $link, $grade_value, $due);
|
||||
} else {
|
||||
$table->data[] = array ($link, $grade_value, $due);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<BR>";
|
||||
|
||||
print_table($table);
|
||||
|
||||
/// Finish the page
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue