Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

delete user attempts now deletes a users grades, attempts, and time r…

…ecrods. The email it sends is nicer as well
  • Loading branch information...
commit b0ec882fc1687885c1f541ad303d61bf9587cd38 1 parent 5f3b3a0
michaelpenne authored
Showing with 22 additions and 5 deletions.
  1. +22 −5 mod/lesson/lib.php
View
27 mod/lesson/lib.php
@@ -99,19 +99,36 @@ function lesson_update_instance($lesson) {
if ($userid = get_field("user", "id", "username", $lesson->deleteattempts)) {
if (delete_records("lesson_attempts", "lessonid", $lesson->id, "userid", $userid)) {
// email good
- $message = "Successfully deleted attempts from \"$lesson->name\" lesson!<br>\r\n";
+ $message .= "Successfully deleted attempts from \"$lesson->name\" lesson!<br />";
} else {
// email couldnt delete
- $message = "Failed to delete attempts from \"$lesson->name\" lesson!<br>\r\n";
+ $message .= "Failed to delete attempts from \"$lesson->name\" lesson!<br />";
}
+ if (delete_records("lesson_grades", "lessonid", $lesson->id, "userid", $userid)) {
+ // email good
+ $message .= "Successfully deleted grades from \"$lesson->name\" lesson!<br />";
+ } else {
+ // email couldnt delete
+ $message .= "Failed to delete grades from \"$lesson->name\" lesson!<br />";
+ }
+ if (delete_records("lesson_timer", "lessonid", $lesson->id, "userid", $userid)) {
+ // email good
+ $message .= "Successfully deleted time records from \"$lesson->name\" lesson!<br />";
+ } else {
+ // email couldnt delete
+ $message .= "Failed to delete time records from \"$lesson->name\" lesson!<br />";
+ }
+
} else {
// email couldnt find user
- $message = "Could not find user in database.<br>\r\n";
+ $message .= "Could not find user in database.<br />";
}
- $message .= "<br>\r\n User ID used: $lesson->deleteattempts <br>\r\n";
+ $message .= "<br /> User ID used: $lesson->deleteattempts <br />";
+
+ $txt = format_text_email($message, FORMAT_HTML);
if ($currentuser = get_record("user", "id", $lesson->deleteattemptsid)) {
- email_to_user($currentuser, $currentuser, $subject, $message, $message);
+ email_to_user($currentuser, $currentuser, $subject, $txt, $message);
}
// unset lessondefault
}
Please sign in to comment.
Something went wrong with that request. Please try again.