Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix to account for people not in course

  • Loading branch information...
commit 96e0ad26b6149c4799835829ed9e1bb3f4cb1905 1 parent ab2eafe
martin authored

Showing 1 changed file with 12 additions and 7 deletions. Show diff stats Hide diff stats

  1. +12 7 mod/journal/lib.php
19 mod/journal/lib.php
@@ -80,10 +80,10 @@ function journal_cron () {
80 80
81 81 $cutofftime = time() - $CFG->maxeditingtime;
82 82
83   - if ($entries = get_records_sql("SELECT e.*, j.course, j.name
  83 + if ($entries = get_records_sql("SELECT e.*, j.course, j.name
84 84 FROM journal_entries e, journal j
85   - WHERE e.mailed = '0' AND
86   - e.timemarked < '$cutofftime' AND e.timemarked > 0
  85 + WHERE e.mailed = '0'
  86 + AND e.timemarked < '$cutofftime' AND e.timemarked > 0
87 87 AND e.journal = j.id")) {
88 88 $timenow = time();
89 89
@@ -96,16 +96,21 @@ function journal_cron () {
96 96 continue;
97 97 }
98 98
99   - if (! $teacher = get_record("user", "id", "$entry->teacher")) {
100   - echo "Could not find teacher $entry->teacher\n";
  99 + if (! $course = get_record("course", "id", "$entry->course")) {
  100 + echo "Could not find course $entry->course\n";
101 101 continue;
102 102 }
103 103
104   - if (! $course = get_record("course", "id", "$entry->course")) {
105   - echo "Could not find course $entry->course\n";
  104 + if (! isstudent($course->id, $user->id) and !isteacher($course->id, $user->id)) {
  105 + continue; // Not an active participant
  106 + }
  107 +
  108 + if (! $teacher = get_record("user", "id", "$entry->teacher")) {
  109 + echo "Could not find teacher $entry->teacher\n";
106 110 continue;
107 111 }
108 112
  113 +
109 114 if (! $mod = get_coursemodule_from_instance("journal", $entry->journal, $course->id)) {
110 115 echo "Could not find course module for journal id $entry->journal\n";
111 116 continue;

0 comments on commit 96e0ad2

Please sign in to comment.
Something went wrong with that request. Please try again.