Skip to content

Commit

Permalink
Lots of work on site display, over many files. Improved front page
Browse files Browse the repository at this point in the history
and display of site modules.
  • Loading branch information
martin committed Aug 3, 2002
1 parent 3f63fdf commit 94361e0
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 135 deletions.
15 changes: 8 additions & 7 deletions admin/index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -162,16 +162,17 @@


// At this point, the databases exist, and the user is an admin // At this point, the databases exist, and the user is an admin


print_header("$site->fullname: Administration Page","$site->fullname: Administration Page", "Admin"); $stradministration = get_string("administration");
print_header("$site->fullname: $stradministration","$site->fullname: $stradministration", "$stradministration");


$table->head = array ("Site Management", "Course Setup", "Other"); $table->head = array ("Site Management", "Course Setup", "Other");
$table->align = array ("CENTER", "CENTER", "CENTER"); $table->align = array ("CENTER", "CENTER", "CENTER");
$table->data[0][0] = "<P><A HREF=\"site.php\">Site settings</A></P>". $table->data[0][0] = "<P><A HREF=\"site.php\">".get_string("sitesettings")."</A></P>".
"<P><A HREF=\"../course/log.php?id=$site->id\">Site logs</A></P>"; "<P><A HREF=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</A></P>";
$table->data[0][1] = "<P><A HREF=\"../course/edit.php\">Create a new course</A></P>". $table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
"<P><A HREF=\"../course/teacher.php\">Assign teachers to a course</A></P>". "<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
"<P><A HREF=\"../course/delete.php\">Delete a course</A></P>"; "<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>";
$table->data[0][2] = "<P><A HREF=\"user.php\">Edit a user's account</A></P>"; $table->data[0][2] = "<P><A HREF=\"user.php\">".get_string("edituser")."</A></P>";


print_table($table); print_table($table);


Expand Down
1 change: 1 addition & 0 deletions admin/site.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
</TABLE> </TABLE>
<INPUT type="hidden" name="id" value="<?=$form->id ?>"> <INPUT type="hidden" name="id" value="<?=$form->id ?>">
<INPUT type="hidden" name="category" value="<?=$form->category ?>"> <INPUT type="hidden" name="category" value="<?=$form->category ?>">
<INPUT type="hidden" name="format" value="<?=$form->format ?>">
</FORM> </FORM>
3 changes: 2 additions & 1 deletion admin/site.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require("../config.php"); require("../config.php");


$course = get_site(); $course = get_site();
$course->format = "social"; // override


/// If data submitted, then process and store. /// If data submitted, then process and store.


Expand Down Expand Up @@ -49,7 +50,7 @@
$form = $course; $form = $course;
} else { } else {
$form->category = 0; $form->category = 0;
$form->newsitems = 1; $form->format = "social";
} }


print_header("Admin: Setting up site", "Administration: Setting up site", print_header("Admin: Setting up site", "Administration: Setting up site",
Expand Down
2 changes: 1 addition & 1 deletion course/edit.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$section->id = insert_record("course_sections", $section); $section->id = insert_record("course_sections", $section);


add_to_log($newid, "course", "new", "view.php?id=$newid", ""); add_to_log($newid, "course", "new", "view.php?id=$newid", "");
redirect("$CFG->wwwroot/admin/teacher.php?id=$newid", get_string("changessaved")); redirect("teacher.php?id=$newid", get_string("changessaved"));
} else { } else {
error("Serious Error! Could not create the new course!"); error("Serious Error! Could not create the new course!");
} }
Expand Down
78 changes: 64 additions & 14 deletions course/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -174,12 +174,28 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
} }




function print_all_courses($cat=1) { function print_all_courses($cat=1, $style="full", $maxcount=999) {
global $CFG;


if ($courses = get_records("course", "category", $cat, "fullname ASC")) { if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
foreach ($courses as $course) { if ($style == "minimal") {
print_course($course); $count = 0;
echo "<BR>\n"; $icon = "<IMG SRC=\"pix/i/course.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
foreach ($courses as $course) {
$moddata[]="<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A>";
$modicon[]=$icon;
if ($count++ >= $maxcount) {
break;
}
}
$fulllist = "<P><A HREF=\"$CFG->wwwroot/course/\">".get_string("fulllistofcourses")."</A>...";
print_side_block("", $moddata, "$fulllist", $modicon);

} else {
foreach ($courses as $course) {
print_course($course);
echo "<BR>\n";
}
} }


} else { } else {
Expand Down Expand Up @@ -398,6 +414,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname


$mods = NULL; // course modules indexed by id $mods = NULL; // course modules indexed by id
$modnames = NULL; // all course module names $modnames = NULL; // all course module names
$modnamesplural= NULL; // all course module names (plural form)
$modnamesused = NULL; // course module names used $modnamesused = NULL; // course module names used


if ($allmods = get_records_sql("SELECT * FROM modules") ) { if ($allmods = get_records_sql("SELECT * FROM modules") ) {
Expand All @@ -414,7 +431,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname
FROM modules m, course_modules cm FROM modules m, course_modules cm
WHERE cm.course = '$courseid' WHERE cm.course = '$courseid'
AND cm.deleted = '0' AND cm.deleted = '0'
AND cm.module = m.id") ) { AND cm.module = m.id ") ) {
foreach($rawmods as $mod) { // Index the mods foreach($rawmods as $mod) { // Index the mods
$mods[$mod->id] = $mod; $mods[$mod->id] = $mod;
$mods[$mod->id]->modfullname = $modnames[$mod->modname]; $mods[$mod->id]->modfullname = $modnames[$mod->modname];
Expand All @@ -432,6 +449,31 @@ function get_all_sections($courseid) {
ORDER BY section"); ORDER BY section");
} }


function print_section($courseid, $section, $mods, $modnamesused, $absolute=false) {
global $CFG;


echo "<P>";
if ($section->sequence) {

$sectionmods = explode(",", $section->sequence);

foreach ($sectionmods as $modnumber) {
$mod = $mods[$modnumber];
$instancename = get_field("$mod->modname", "name", "id", "$mod->instance");
echo "<IMG SRC=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo " <A TITLE=\"$mod->modfullname\"";
echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</A>";
if (isediting($courseid)) {
echo make_editing_buttons($mod->id, $absolute);
}
echo "<BR>\n";
}
}
echo "</P>\n";
}


function print_log_graph($course, $userid=0, $type="course.png", $date=0) { function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
global $CFG; global $CFG;
echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">"; echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
Expand Down Expand Up @@ -654,20 +696,28 @@ function move_module($id, $move) {
} }
} }


function make_editing_buttons($moduleid) { function make_editing_buttons($moduleid, $absolute=false) {
global $CFG;

$delete = get_string("delete"); $delete = get_string("delete");
$moveup = get_string("moveup"); $moveup = get_string("moveup");
$movedown = get_string("movedown"); $movedown = get_string("movedown");
$update = get_string("update"); $update = get_string("update");

if ($absolute) {
$path = "$CFG->wwwroot/course/";
} else {
$path = "";
}
return "&nbsp; &nbsp; return "&nbsp; &nbsp;
<A HREF=mod.php?delete=$moduleid><IMG <A HREF=\"".$path."mod.php?delete=$moduleid\"><IMG
SRC=../pix/t/delete.gif BORDER=0 ALT=\"$delete\"></A> SRC=".$path."../pix/t/delete.gif BORDER=0 ALT=\"$delete\"></A>
<A HREF=mod.php?id=$moduleid&move=-1><IMG <A HREF=\"".$path."mod.php?id=$moduleid&move=-1\"><IMG
SRC=../pix/t/up.gif BORDER=0 ALT=\"$moveup\"></A> SRC=".$path."../pix/t/up.gif BORDER=0 ALT=\"$moveup\"></A>
<A HREF=mod.php?id=$moduleid&move=1><IMG <A HREF=\"".$path."mod.php?id=$moduleid&move=1\"><IMG
SRC=../pix/t/down.gif BORDER=0 ALT=\"$movedown\"></A> SRC=".$path."../pix/t/down.gif BORDER=0 ALT=\"$movedown\"></A>
<A HREF=mod.php?update=$moduleid><IMG <A HREF=\"".$path."mod.php?update=$moduleid\"><IMG
SRC=../pix/t/edit.gif BORDER=0 ALT=\"$update\"></A>"; SRC=".$path."../pix/t/edit.gif BORDER=0 ALT=\"$update\"></A>";
} }


function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) { function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
Expand Down
19 changes: 1 addition & 18 deletions course/topics.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -151,24 +151,7 @@


echo text_to_html($thissection->summary); echo text_to_html($thissection->summary);


echo "<P>"; print_section($course->id, $thissection, $mods, $modnamesused);
if ($thissection->sequence) {

$thissectionmods = explode(",", $thissection->sequence);

foreach ($thissectionmods as $modnumber) {
$mod = $mods[$modnumber];
$instancename = get_field("$mod->modname", "name", "id", "$mod->instance");
echo "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo " <A TITLE=\"$mod->modfullname\"";
echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instancename</A>";
if (isediting($course->id)) {
echo make_editing_buttons($mod->id);
}
echo "<BR>\n";
}
}
echo "</UL></P>\n";


if (isediting($course->id)) { if (isediting($course->id)) {
echo "<DIV ALIGN=right>"; echo "<DIV ALIGN=right>";
Expand Down
2 changes: 1 addition & 1 deletion course/user.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
echo "</TR></TABLE>"; echo "</TR></TABLE>";




get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);


switch ($mode) { switch ($mode) {
case "today" : case "today" :
Expand Down
2 changes: 1 addition & 1 deletion course/view.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true, print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
update_course_icon($course->id)); update_course_icon($course->id));


get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);


switch ($course->format) { switch ($course->format) {
case "weeks": case "weeks":
Expand Down
23 changes: 3 additions & 20 deletions course/weeks.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


include("../mod/forum/lib.php"); include("../mod/forum/lib.php");


if (! $sections = get_all_sections($course->id, $course->numsections) ) { if (! $sections = get_all_sections($course->id)) {
$section->course = $course->id; // Create a default section. $section->course = $course->id; // Create a default section.
$section->section = 0; $section->section = 0;
$section->id = insert_record("course_sections", $section); $section->id = insert_record("course_sections", $section);
if (! $sections = get_all_sections($course->id, $course->numsections) ) { if (! $sections = get_all_sections($course->id) ) {
error("Error finding or creating section structures for this course"); error("Error finding or creating section structures for this course");
} }
} }
Expand Down Expand Up @@ -141,24 +141,7 @@


echo text_to_html($thisweek->summary); echo text_to_html($thisweek->summary);


echo "<P>"; print_section($course->id, $thisweek, $mods, $modnamesused);
if ($thisweek->sequence) {

$thisweekmods = explode(",", $thisweek->sequence);

foreach ($thisweekmods as $modnumber) {
$mod = $mods[$modnumber];
$instancename = get_field("$mod->modname", "name", "id", "$mod->instance");
echo "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo " <A TITLE=\"$mod->modfullname\"";
echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instancename</A>";
if (isediting($course->id)) {
echo make_editing_buttons($mod->id);
}
echo "<BR>\n";
}
}
echo "</UL></P>\n";


if (isediting($course->id)) { if (isediting($course->id)) {
echo "<DIV ALIGN=right>"; echo "<DIV ALIGN=right>";
Expand Down
56 changes: 34 additions & 22 deletions index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,39 +26,51 @@
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5"> <TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<TR> <TR>
<TD VALIGN="TOP" NOWRAP> <TD VALIGN="TOP" NOWRAP>
<? $readings = reading_list_all_readings(); <?

$sections = get_all_sections($site->id);


if ($site->newsitems > 0 or $readings or isediting($site->id)) { if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {


print_simple_box(get_string("mainmenu"), $align="CENTER", $width="100%", $color="$THEME->cellheading");

if ($site->newsitems > 0 ) { if ($site->newsitems > 0 ) {
echo "<LI><A TITLE=\"". print_simple_box(get_string("courses"), "CENTER", "100%", "$THEME->cellheading");
get_string("availablecourses").
"\" HREF=\"course/\"><B>". print_all_courses($cat=1, "minimal", 10);
get_string("courses").
"</B></A><BR></LI>";
} }


if ($readings) { if ($sections[0]->sequence or isediting($site->id)) {
foreach ($readings as $reading) { get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
echo "<LI>$reading"; print_simple_box(get_string("mainmenu"), "CENTER", "100%", "$THEME->cellheading");
} }

if ($sections[0]->sequence) {
print_section($site->id, $sections[0], $mods, $modnamesused, true);
} }

if (isediting($site->id)) { if (isediting($site->id)) {
echo "<P align=right><A HREF=\"$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=reading\">". echo "<DIV ALIGN=right>";
get_string("addreading", "reading")."</A>...</P>"; popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=",
} else { $modnames, "section0", "", "Add...");
echo "<BR><BR>"; echo "</DIV>";
} }
} }



if (isadmin()) { if (isadmin()) {
print_simple_box(get_string("admin"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); print_simple_box(get_string("administration"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<LI><A HREF=\"$CFG->wwwroot/admin/\">".get_string("adminpage")."...</A></LI>"; $icon = "<IMG SRC=\"pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
echo "<LI><A HREF=\"$CFG->wwwroot/course/log.php?id=$site->id\">".get_string("sitelogs")."...</A></LI>"; $moddata[]="<A HREF=\"course/log.php?id=$site->id\">".get_string("sitelogs")."</A>";
echo "<LI><A HREF=\"$CFG->wwwroot/admin/site.php\">".get_string("sitesettings")."...</A></LI>"; $modicon[]=$icon;
$moddata[]="<A HREF=\"admin/site.php\">".get_string("sitesettings")."</A>";
$modicon[]=$icon;
$moddata[]="<A HREF=\"course/edit.php\">".get_string("addnewcourse")."</A>";
$modicon[]=$icon;
$moddata[]="<A HREF=\"course/teacher.php\">".get_string("assignteachers")."</A>";
$modicon[]=$icon;
$moddata[]="<A HREF=\"course/delete.php\">".get_string("deletecourse")."</A>";
$modicon[]=$icon;
$moddata[]="<A HREF=\"admin/user.php\">".get_string("edituser")."</A>";
$modicon[]=$icon;
print_side_block("", $moddata, "", $modicon);
} }
?> ?>


Expand Down
2 changes: 1 addition & 1 deletion lang/en/forum.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$string[generalforum] = "Standard forum for general use"; $string[generalforum] = "Standard forum for general use";
$string[generalforums] = "General forums"; $string[generalforums] = "General forums";
$string[inforum] = "in \$a"; $string[inforum] = "in \$a";
$string[intronews] = "General news and announcements about this course"; $string[intronews] = "General news and announcements";
$string[introsocial] = "An open forum for chatting about anything you want to"; $string[introsocial] = "An open forum for chatting about anything you want to";
$string[introteacher] = "A forum for teacher-only notes and discussion"; $string[introteacher] = "A forum for teacher-only notes and discussion";
$string[learningforums] = "Learning forums"; $string[learningforums] = "Learning forums";
Expand Down
13 changes: 6 additions & 7 deletions lang/en/moodle.php
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,17 @@
<?PHP // $Id$ <?PHP // $Id$


#------------------------------------------------------------
$string[modulename] = "Site";
$string[modulenameplural] = "Sites";
#------------------------------------------------------------


$string[activity] = "Activity"; $string[activity] = "Activity";
$string[activityreport] = "Activity report"; $string[activityreport] = "Activity report";
$string[addnewcourse] = "Add a new course";
$string[address] = "Address"; $string[address] = "Address";
$string[admin] = "Admin"; $string[admin] = "Admin";
$string[adminpage] = "Admin page"; $string[administration] = "Administration";
$string[again] = "again"; $string[again] = "again";
$string[alllogs] = "All logs"; $string[alllogs] = "All logs";
$string[allfieldsrequired] = "All fields are required"; $string[allfieldsrequired] = "All fields are required";
$string[alphanumerical] = "Can only contain alphabetical letters or numbers"; $string[alphanumerical] = "Can only contain alphabetical letters or numbers";
$string[alreadyconfirmed] = "Registration has already been confirmed"; $string[alreadyconfirmed] = "Registration has already been confirmed";
$string[assignteachers] = "Assign teachers";
$string[availablecourses] = "Available Courses"; $string[availablecourses] = "Available Courses";
$string[category] = "Category"; $string[category] = "Category";
$string[changepassword] = "Change password"; $string[changepassword] = "Change password";
Expand All @@ -31,8 +27,10 @@
$string[createuserandpass] = "Create a new username and password to log in with"; $string[createuserandpass] = "Create a new username and password to log in with";
$string[currentlocaltime] = "your current local time"; $string[currentlocaltime] = "your current local time";
$string[delete] = "Delete"; $string[delete] = "Delete";
$string[deletecourse] = "Delete a course";
$string[editcoursesettings] = "Edit course settings"; $string[editcoursesettings] = "Edit course settings";
$string[editmyprofile] = "Edit my profile"; $string[editmyprofile] = "Edit my profile";
$string[edituser] = "Edit user accounts";
$string[email] = "Email address"; $string[email] = "Email address";
$string[emailformat] = "Email format"; $string[emailformat] = "Email format";
$string[emailconfirm] = "Confirm your account"; $string[emailconfirm] = "Confirm your account";
Expand Down Expand Up @@ -68,6 +66,7 @@
$string[firsttime] = "Is this your first time here?"; $string[firsttime] = "Is this your first time here?";
$string[forgotten] = "Forgotten your username or password?"; $string[forgotten] = "Forgotten your username or password?";
$string[format] = "Format"; $string[format] = "Format";
$string[fulllistofcourses] = "Full list of courses";
$string[fullprofile] = "Full profile"; $string[fullprofile] = "Full profile";
$string[fullname] = "Full name"; $string[fullname] = "Full name";
$string[guestsno] = "No, do not allow guests in"; $string[guestsno] = "No, do not allow guests in";
Expand Down
Loading

0 comments on commit 94361e0

Please sign in to comment.