Skip to content

Commit

Permalink
Fairly radical improvement to the Journal index, putting all the
Browse files Browse the repository at this point in the history
information on one page.
  • Loading branch information
moodler committed Aug 27, 2003
1 parent 7625591 commit 2a0d8c5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 31 deletions.
36 changes: 6 additions & 30 deletions mod/journal/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
add_to_log($course->id, "journal", "view all", "index.php?id=$course->id", "");

if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
}

$strjournal = get_string("modulename", "journal");
Expand All @@ -37,14 +37,11 @@
$timenow = time();

if ($course->format == "weeks") {
$table->head = array ($strweek, $strquestion, $stranswer);
$table->align = array ("CENTER", "LEFT", "LEFT");
$strsection = $strweek;
} else if ($course->format == "topics") {
$table->head = array ($strtopic, $strquestion, $stranswer);
$table->align = array ("CENTER", "LEFT", "LEFT");
$strsection = $strtopic;
} else {
$table->head = array ($strquestion, $stranswer);
$table->align = array ("LEFT", "LEFT");
$strsection = "";
}

foreach ($journals as $journal) {
Expand All @@ -55,36 +52,15 @@
} else {
$journal->timefinish = 9999999999;
}
$journalopen = ($journal->timestart < $timenow && $timenow < $journal->timefinish);

$entrytext = get_field("journal_entries", "text", "userid", $USER->id, "journal", $journal->id);
$journalopen = ($journal->timestart < $timenow && $timenow < $journal->timefinish);

$text = text_to_html($entrytext)."<p align=right><a href=\"view.php?id=$journal->coursemodule\">";
journal_user_complete_index($course, $USER, $journal, $journalopen, "$strsection $journal->section");

if ($journalopen) {
$text .= "$stredit</a></p>";
} else {
$text .= "$strview</a></p>";
}
if (!empty($journal->section)) {
$section = "$journal->section";
} else {
$section = "";
}
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($section,
text_to_html($journal->intro),
$text);
} else {
$table->data[] = array (text_to_html($journal->intro),
$text);
}
}

echo "<br />";

print_table($table);

print_footer($course);

?>
Expand Down
48 changes: 47 additions & 1 deletion mod/journal/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function journal_user_complete($course, $user, $mod, $journal) {
echo format_text($entry->text, $entry->format);
}
if ($entry->teacher) {
journal_print_feedback($course, $entry);
$grades = make_grades_menu($journal->assessed);
journal_print_feedback($course, $entry, $grades);
}
print_simple_box_end();

Expand All @@ -37,6 +38,51 @@ function journal_user_complete($course, $user, $mod, $journal) {
}
}

function journal_user_complete_index($course, $user, $journal, $journalopen, $heading) {

if ($heading) {
echo "<h3>$heading - $journal->name</h3>";
} else {
echo "<h3>$journal->name</h3>";
}

print_simple_box_start("left", "90%");
echo format_text($journal->intro);
print_simple_box_end();
echo "<br clear=all />";
echo "<br />";

print_simple_box_start("right", "90%");

if ($journalopen) {
echo "<p align=right><a href=\"edit.php?id=$journal->coursemodule\">";
echo get_string("edit")."</a></p>";
} else {
echo "<p align=right><a href=\"view.php?id=$journal->coursemodule\">";
echo get_string("view")."</a></p>";
}

if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
if ($entry->modified) {
echo "<p align=\"center\"><font size=1>".get_string("lastedited").": ".userdate($entry->modified)."</font></p>";
}
if ($entry->text) {
echo format_text($entry->text, $entry->format);
}
if ($entry->teacher) {
$grades = make_grades_menu($journal->assessed);
journal_print_feedback($course, $entry, $grades);
}
} else {
print_string("noentry", "journal");
}

print_simple_box_end();
echo "<br clear=all />";
echo "<br />";

}


function journal_cron () {
// Function to be run periodically according to the moodle cron
Expand Down

0 comments on commit 2a0d8c5

Please sign in to comment.