示例#1
0
function show_courses_topic()
{
    include_once '../wp-content/plugins/wp-courseware/lib/common.inc.php';
    include_once '../wp-content/plugins/wp-courseware/lib/constants.inc.php';
    include_once '../wp-content/plugins/wp-courseware/lib/email_defaults.inc.php';
    include_once '../wp-content/plugins/wp-courseware/lib/class_user_progress.inc.php';
    $was_saved = 0;
    if ($_POST["topic_for_course"]) {
        foreach ($_POST["topic_for_course"] as $tfc_id => $tfc_value) {
            $tfc_value = explode("-", $tfc_value);
            //echo $tfc_value[0]."---".$tfc_value[1]."<br>";
            $set_topic = EventDatabaseManager::setTopicForCourse($tfc_value[0], $tfc_value[1]);
            $was_saved = 1;
        }
    }
    $output_str = "";
    $output_str .= "<form name=\"form1\" method=\"post\" action=\"" . $_SERVER['REQUEST_URI'] . "\">";
    $topic_per_course = EventDatabaseManager::getTopicPerCourse();
    // $topic_per_course_test_cert_date = EventDatabaseManager::getTopicPerCourse_test_CertDate();
    //echo "<pre>";var_dump($topic_per_course); echo "</pre><br><br>";
    $output_str .= "<h2>" . HEADER_TOPICS_PER_COURSE . "</h2>";
    if ($was_saved == 1) {
        $output_str .= "<p>Gespeichert!</p>";
    }
    $output_str .= "<table>";
    $output_str .= "<tr>";
    $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Course-ID</td>";
    $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Course-Title</td>";
    $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Topic-Title</td>";
    $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">User</td>";
    $output_str .= "</tr>";
    $topics = EventDatabaseManager::getAllTopics();
    $output_str .= "<tr>";
    $output_str .= "<td colspan=4 style=\"padding: 1px 2px; border: 1px solid black;\">Variante 1: Datum ist Topic Expiry Date</td>";
    $output_str .= "</tr>";
    foreach ($topic_per_course as $tpc => $course_value) {
        $topic_select = "<select name=\"topic_for_course[" . $course_value['course_id'] . "]\">";
        $topic_select .= "<option value=\"" . $course_value['course_id'] . "-0\">---</option>";
        foreach ($topics as $topic_id => $topic_value) {
            $selected = "";
            if ($topic_id == $course_value['topic_id']) {
                $selected = " selected ";
            }
            $topic_select .= "<option " . $selected . " value=\"" . $course_value['course_id'] . "-" . $topic_id . "\">" . $topic_value . " (" . $topic_id . ")</option>";
        }
        $topic_select .= "</select>";
        $user_string = "";
        //echo "tpc2:<br><pre>";var_dump($course_value['users']); echo "</pre>";
        foreach ($course_value['users'] as $users => $user) {
            $user_string .= $user['name'] . "&nbsp;(";
            $user_string .= $user['id'] . "):&nbsp;";
            // $user_string .= date("d.m.Y",strtotime($user['topic_expiry_date'])); // wird doch gar nicht benutzt!!!
            $bla = new UserProgress($course_value['course_id'], $user['id']);
            //echo "<pre>";var_dump($bla); echo "</pre><br><br>";
            if ($bla->isCourseCompleted()) {
                $user_string .= " <span style=\"background: orange; color: white;\">[completed (certificate)]</span>";
            }
            // Datum in Weiß auf Orange ist cert_generated
            $active = EventDatabaseManager::isTopicForUserActive($user['id'], $course_value['topic_id']);
            $user_string .= $active;
            // $user_string .= "+" . $user['repetition_frequency_days']."=";
            //$repetition_date = strtotime($user['topic_expiry_date']." +".$user['repetition_frequency_days']." days")."=";
            //$user_string .= date("d.m.Y",(int)$repetition_date);
            // wenn repetition_frequency_days == 0 -> keine Wiedervorlage
            // topic_expiry_date durch creation_date ersetzen
            // sonst:
            $user_string .= "<br>";
        }
        $output_str .= "<tr>";
        $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $course_value['course_id'] . "</td>";
        $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $course_value['course_title'] . "</td>";
        $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $topic_select . "</td>";
        $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">[" . count($course_value['users']) . "]<br>" . rtrim($user_string, ",") . "</td>";
        $output_str .= "</tr>";
    }
    $output_str .= "<tr><td colspan=\"4\">";
    $output_str .= " <span style=\"background: orange; color: white;\"> Course Completed und Datum der Zertifkatsgenerierung </span>";
    $output_str .= " <span style=\"background: red; color: white;\"> V = Rep.Date ist Vergangenheit </span>";
    $output_str .= " <span style=\"background: green; color: white;\"> Z = Rep.Date ist Heute oder Zukunft </span>";
    $output_str .= " <span style=\"background: red; color: white;\"> K = kein Zertifikat </span>";
    $output_str .= " <span style=\"background: #FFCC00; color: black;\"> WV am </span>";
    $output_str .= " <span style=\"background: green; color: white;\"> 0 = keine WV </span>";
    $output_str .= "</td></tr>";
    $output_str .= "<tr>";
    $output_str .= "<td colspan=4 style=\"padding: 1px 2px; border: 1px solid black;\">Variante 2: Datum ist Certificate Creation Date -> weniger Treffer (wieder verworfen)</td>";
    $output_str .= "</tr>";
    $output_str .= "</table>";
    $output_str .= "   <br>";
    $output_str .= "   <input type=\"submit\" value=\"Speichern\" />";
    $output_str .= "   <input name=\"action\" value=\"insert\" type=\"hidden\" />";
    $output_str .= " </form>";
    echo $output_str;
}