示例#1
0
         if ($evaluation["request_timeout"]) {
             $PROCESSED_REQUEST["request_expires"] = time() + $evaluation["request_timeout"] * 60;
         } else {
             $PROCESSED_REQUEST["request_expires"] = 0;
         }
         $PROCESSED_REQUEST["evaluation_id"] = $RECORD_ID;
         $PROCESSED_REQUEST["proxy_id"] = $ENTRADA_USER->getId();
         $PROCESSED_REQUEST["target_proxy_id"] = $associated_evaluator;
         $PROCESSED_REQUEST["request_created"] = time();
         $PROCESSED_REQUEST["request_fulfilled"] = 0;
         if ($db->AutoExecute("evaluation_requests", $PROCESSED_REQUEST, "INSERT") && ($request_id = $db->Insert_Id())) {
             require_once "Models/notifications/Notification.class.php";
             require_once "Models/notifications/NotificationUser.class.php";
             $notification_user = NotificationUser::get($associated_evaluator, "evaluation_request", $RECORD_ID, $ENTRADA_USER->getId());
             if (!$notification_user) {
                 $notification_user = NotificationUser::add($associated_evaluator, "evaluation_request", $RECORD_ID, $ENTRADA_USER->getId());
             }
             if (Notification::add($notification_user->getID(), $ENTRADA_USER->getId(), $RECORD_ID)) {
                 $notifications_sent++;
             } else {
                 add_error("An issue was encountered while attempting to send a notification to a user [" . get_account_data("wholename", $associated_evaluator) . "] requesting that they complete an evaluation [" . $evaluation_title . "] for you. The system administrator has been notified of this error, please try again later.");
                 application_log("Unable to send notification requesting an evaluation be completed to evaluator [" . $associated_evaluator . "] for evaluation_id [" . $RECORD_ID . "].");
             }
         } else {
             add_error("Unable to create a request entry for this evaluation. The system administrator was notified of this error; please try again later.");
             application_log("Unable to create a request entry for this evaluator [" . $associated_evaluator . "] for evaluation_id [" . $RECORD_ID . "]. Database said: " . $db->ErrorMsg());
         }
     } else {
         add_error("The selected evaluator [" . get_account_data("wholename", $associated_evaluator) . "] has already completed this evaluation [" . $evaluation_title . "] for you, and is unable to attempt it again.");
     }
 } else {
        $recent_notifications = $db->GetAll($query);
        if (!isset($recent_notifications) || !$recent_notifications) {
            Notification::add($notification_user->getID(), $proxy_id, $evaluation_id, isset($pending_evaluation["event_id"]) && $pending_evaluation["event_id"] ? $pending_evaluation["event_id"] : $pending_evaluation["event_id"]);
        }
    }
}
//queue notifications for each user with the evaluations which have closed for them in the last 24 hours.
$query = "SELECT *, '0' AS `event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND a.`evaluation_finish` >= " . $db->qstr(strtotime("-10 weeks")) . "\n\t\t\tAND a.`evaluation_finish` <= " . $db->qstr(time()) . "\n\t\t\tAND c.`target_shortname` NOT IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'cohort'\n\t\t\tJOIN `group_members` AS h\n\t\t\tON g.`evaluator_value` = h.`group_id`\n\t\t\tAND h.`proxy_id` = f.`etype_id`\n\t\t\tAND h.`member_active`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT) . "\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'cgroup_id'\n\t\t\tJOIN `course_group_audience` AS h\n\t\t\tON g.`evaluator_value` = h.`cgroup_id`\n\t\t\tAND h.`proxy_id` = f.`etype_id`\n\t\t\tAND h.`active` = 1\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT) . "\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'proxy_id'\n\t\t\tAND g.`evaluator_value` = f.`etype_id`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT);
$ended_evaluations = $db->GetAll($query);
if ($ended_evaluations) {
    foreach ($ended_evaluations as $evaluation) {
        $overdue_evaluations[$evaluation["evaluation_id"] . (isset($evaluation["event_id"]) && $evaluation["event_id"] ? "-" . $evaluation["event_id"] : "")] = Models_Evaluation::getOverdueEvaluations($evaluation);
    }
}
foreach ($overdue_evaluations as $overdue_evaluation_users) {
    foreach ($overdue_evaluation_users as $overdue_evaluation) {
        $evaluation_id = $overdue_evaluation["evaluation_id"];
        require_once "Models/notifications/NotificationUser.class.php";
        require_once "Models/notifications/Notification.class.php";
        $proxy_id = $overdue_evaluation["user"]["id"];
        $notification_user = NotificationUser::get($proxy_id, "evaluation_overdue", $evaluation_id, $proxy_id);
        if (!$notification_user) {
            $notification_user = NotificationUser::add($proxy_id, "evaluation_overdue", $evaluation_id, $proxy_id);
        }
        $query = "SELECT * FROM `notifications` \n                    WHERE `nuser_id` = " . $db->qstr($notification_user->getID()) . " \n                    AND `proxy_id` = " . $db->qstr($proxy_id) . "\n                    AND (`sent_date` = 0 OR `sent_date` >= " . $db->qstr(strtotime("-7 days")) . ")";
        $recent_notifications = $db->GetAll($query);
        if (!isset($recent_notifications) || !$recent_notifications) {
            Notification::add($notification_user->getID(), $proxy_id, $evaluation_id, isset($overdue_evaluation["event_id"]) && $overdue_evaluation["event_id"] ? $overdue_evaluation["event_id"] : $overdue_evaluation["event_id"]);
        }
    }
}
示例#3
0
 }
 if (isset($evaluation_request) && $evaluation_request && !$db->AutoExecute("evaluation_requests", array("request_fulfilled" => 1), "UPDATE", "`erequest_id` = " . $db->qstr($evaluation_request["erequest_id"]))) {
     application_log("error", "Unable to mark evaluation request as completed [" . $progress_record["evaluation_id"] . "]. Database said: " . $db->ErrorMsg());
 }
 if ($evaluation_record["threshold_notifications_type"] != "disabled") {
     $is_below_threshold = Models_Evaluation::responsesBelowThreshold($evaluation_record["evaluation_id"], $eprogress_id);
     if ($is_below_threshold) {
         if (defined("NOTIFICATIONS_ACTIVE") && NOTIFICATIONS_ACTIVE) {
             require_once "Models/notifications/NotificationUser.class.php";
             require_once "Models/notifications/Notification.class.php";
             $threshold_notification_recipients = Models_Evaluation::getThresholdNotificationRecipients($evaluation_record["evaluation_id"], $eprogress_id, $PROCESSED["eevaluator_id"]);
             if (isset($threshold_notification_recipients) && $threshold_notification_recipients) {
                 foreach ($threshold_notification_recipients as $threshold_notification_recipient) {
                     $notification_user = NotificationUser::get($threshold_notification_recipient["proxy_id"], "evaluation_threshold", $evaluation_record["evaluation_id"], $ENTRADA_USER->getID());
                     if (!$notification_user) {
                         $notification_user = NotificationUser::add($threshold_notification_recipient["proxy_id"], "evaluation_threshold", $evaluation_record["evaluation_id"], $ENTRADA_USER->getID());
                     }
                     Notification::add($notification_user->getID(), $ENTRADA_USER->getID(), $eprogress_id);
                 }
             }
         }
     }
 }
 if (array_search($PROCESSED["target_shortname"], array("preceptor", "rotation_core", "rotation_elective")) !== false) {
     if (!$db->AutoExecute("evaluation_progress_clerkship_events", $PROCESSED_CLERKSHIP_EVENT, "INSERT")) {
         $db->Execute("UPDATE `evaluation_progress` SET `progress_value` = 'inprogress' WHERE `eprogress_id` = " . $db->qstr($PROCESSED["eprogress_id"]));
         application_log("error", "Unable to record the final clerkship event details for eprogress_id [" . $eprogress_id . "] in the evaluation_progress_clerkship_events table. Database said: " . $db->ErrorMsg());
         $ERROR++;
         $ERRORSTR[] = "We were unable to record the final results for this evaluation at this time. Please be assured that your responses are saved, but you will need to come back to this evaluation to re-submit it. This problem has been reported to a system administrator; please try again later.";
     } else {
         /**
            $content_type = clean_input($_GET["content_type"], "module");
        } else {
            $content_type = "default";
        }
        $notification_user = NotificationUser::get($ENTRADA_USER->getID(), $content_type, $record_id, $record_proxy_id);
        if ($notification_user && $notification_user->getProxyID() == $ENTRADA_USER->getID()) {
            if ($notification_user->getNotifyActive() != $notify_active) {
                if ($notification_user->setNotifyActive($notify_active)) {
                    echo ($notify_active == 1 ? "Activation" : "Deactivation") . " of notifications for this " . $notification_user->getContentTypeName() . " successful.";
                } else {
                    echo "There was an issue while trying to " . ($notify_active ? "activate" : "deactivate") . " notifications for this " . $notification_user->getContentTypeName() . ".";
                }
            } elseif ($notification_user->getDigestMode() != $digest_mode) {
                if ($notification_user->setDigestMode($digest_mode)) {
                    echo ($digest_mode == 1 ? "Activation" : "Deactivation") . " of digest mode for notifications regarding this " . $notification_user->getContentTypeName() . " successful.";
                } else {
                    echo "There was an issue while trying to " . ($digest_mode ? "activate" : "deactivate") . " digest mode for notifications regarding this " . $notification_user->getContentTypeName() . ".";
                }
            } else {
                echo "Notifications for this " . $notification_user->getContentTypeName() . " are already " . ($notify_active ? "activated" : "deactivated") . " and digest mode is already " . ($digest_mode ? "activated" : "deactivated") . ", no changes were made.";
            }
        } else {
            $notification_user = NotificationUser::add($ENTRADA_USER->getID(), $content_type, $record_id, $record_proxy_id, $notify_active, $digest_mode);
            if ($notification_user) {
                echo ($notify_active == 1 ? "Activation" : "Deactivation") . " of notifications for this " . $notification_user->getContentTypeName() . " successful.";
            } else {
                echo "There was an issue while trying to " . ($notify_active ? "activate" : "deactivate") . " notifications for this " . $notification_user->getContentTypeName() . ".";
            }
        }
    }
}
示例#5
0
 if ($student && $_SESSION["details"]["group"] == "student" || array_search($rotation_id, $accessible_rotation_ids) !== false) {
     // Error Checking
     if ($STEP == 2) {
         if (isset($_POST["discussion_comment"]) && ($new_comments = clean_input($_POST["discussion_comment"], array("trim", "notags")))) {
             $PROCESSED["comments"] = $new_comments;
             $PROCESSED["clerk_id"] = $PROXY_ID;
             $PROCESSED["proxy_id"] = $ENTRADA_USER->getID();
             $PROCESSED["rotation_id"] = $rotation_id;
             $PROCESSED["updated_date"] = time();
             if ($db->AutoExecute(CLERKSHIP_DATABASE . ".logbook_rotation_comments", $PROCESSED, "INSERT")) {
                 if (defined("NOTIFICATIONS_ACTIVE") && NOTIFICATIONS_ACTIVE) {
                     $lrcomment_id = $db->Insert_Id();
                     require_once "Models/notifications/NotificationUser.class.php";
                     $notification_user = NotificationUser::get($PROXY_ID, "logbook_rotation", $rotation_id, $PROXY_ID);
                     if (!$notification_user) {
                         $notification_user = NotificationUser::add($PROXY_ID, "logbook_rotation", $rotation_id, $PROXY_ID);
                     }
                     NotificationUser::addAllNotifications("logbook_rotation", $rotation_id, $PROXY_ID, $ENTRADA_USER->getID(), $lrcomment_id);
                 }
                 $SUCCESS++;
                 $SUCCESSSTR[] = "You have succesfully added a comment to this rotation" . ($student ? "" : " for " . get_account_data("firstlast", $PROXY_ID)) . ".";
             } else {
                 $ERROR++;
                 $ERRORSTR[] = "There was an issue while attempting to add your comment to the system. <br /><br />If you if this error persists, please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance.";
                 application_log("error", "There was an error adding a clerkship rotation comment entry. Database said: " . $db->ErrorMsg());
             }
         }
         $STEP = 1;
     }
     // Display Content
     switch ($STEP) {