public function addParticipantToDatabaseFromMatriculationNumber($matNr, $term = 0)
 {
     $ldapManager = exam_organization_ldap_manager::getInstance();
     $imtLogin = $ldapManager->matriculationNumber2imtLogin($matNr);
     $lastName = $ldapManager->matriculationNumber2lastName($matNr);
     $firstName = $ldapManager->matriculationNumber2firstName($matNr);
     $eoDatabase = exam_organization_database::getInstance();
     $result1 = $eoDatabase->addParticipantToCourse($imtLogin, $lastName, $firstName, $matNr);
     //add participant to course
     $result2 = $eoDatabase->addParticipantToExam($imtLogin, $term);
     //add participant to exam
     //HIS LSF import
     if (isset($_SESSION["exam_organization_excelRowArray"])) {
         $rowStringArray = $_SESSION["exam_organization_excelRowArray"];
         if (isset($rowStringArray[$matNr])) {
             $result3 = $eoDatabase->saveExcelRow($term, $matNr, $rowStringArray[$matNr]);
             //add participant to exam
         }
     }
     //return result state
     if (!($result1 == FALSE) && !($result2 == FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #3
0
function sendRoundMail($sendingUser, $courseObject, $courseId, $term, $subject = "", $body = "")
{
    //get recipeints
    $recipients = array();
    $eoDatabase = exam_organization_database::getInstance();
    $participants = $eoDatabase->getParticipantsForTerm($term);
    //prefetch mail addresses
    $ldapManager = exam_organization_ldap_manager::getInstance();
    foreach ($participants as $participant) {
        $ldapManager->markForPreload($participant["matriculationNumber"]);
    }
    $ldapManager->preload();
    $header = 'MIME-Version: 1.0' . "\r\n";
    if ($sendingUser->get_full_name() == "Root User") {
        $lecturerName = "Root User";
        $lecturerMail = "*****@*****.**";
    } else {
        $lecturerMailArray = $sendingUser->get_email_forwarding();
        $lecturerMail = $lecturerMailArray[1];
        $lecturerName = $sendingUser->get_full_name();
    }
    $header .= "Content-type: text/html; charset=utf-8\r\n";
    $header .= 'From: ' . $lecturerName . ' <' . $lecturerMail . '>' . "\r\n";
    //get mail addresses
    foreach ($participants as $participant) {
        $mailAdress = $ldapManager->matriculationNumber2mail($participant["matriculationNumber"]);
        //$recipients[]=$mailAdress;
        $header .= "Bcc: " . $mailAdress . "\r\n";
    }
    $header .= "Bcc: " . $lecturerMail . "\r\n";
    //send mail to author
    //create recipients string
    $recipientsString = "";
    $first = true;
    foreach ($recipients as $recipient) {
        if ($first) {
            $first = FALSE;
            $recipientsString .= $recipient;
        } else {
            $recipientsString .= ", " . $recipient;
        }
    }
    //get staff members subgroup to send mail
    $staffGroup = $courseObject->get_group_staff();
    //send mail
    $sendingUser->mail(gettext("Circular") . ": " . $subject, $body);
    $staffGroup->mail(gettext("Circular") . ": " . $subject, $body);
    $returnValue = mail($recipientsString, '=?UTF-8?B?' . base64_encode(gettext("Circular") . ": " . $subject) . '?=', $body, $header);
    return returnValue;
}
Exemple #4
0
function getFullName($examObject, $examTerm, $matriculationNumber)
{
    $examOffice = exam_office_file_handling::getInstance();
    if (!$examOffice->isMatriculationNumber($matriculationNumber)) {
        //case no matriculation number
        echo "0";
    } else {
        //valid matriculation number
        $ldapManager = exam_organization_ldap_manager::getInstance();
        $fullName = $ldapManager->getFullName($matriculationNumber);
        echo $fullName;
    }
    exit(0);
}
//case parse table
if (isset($_FILES['input_excel_file']['name'])) {
    $tmpFileDestination = EXAM_ORGANIZATION_TEMP_DIR . "/exam_organization_tablefile_" . $_FILES['input_excel_file']['name'];
    if (isset($_POST["import_participants_loadfile"])) {
        if (copy($_FILES['input_excel_file']['tmp_name'], $tmpFileDestination)) {
            $portal->set_confirmation("The file " . basename($_FILES['input_excel_file']['name']) . " has been uploaded");
        } else {
            $portal->set_problem_description(gettext("There was an error uploading the file"));
        }
        $matriculationNumbers = $examOffice->tableFile2matriculationNumbersList($tmpFileDestination);
        //parse table file
        $ldapManager = exam_organization_ldap_manager::getInstance();
        $matriculationNumbersTable = "<table class='grid' width='100%'>";
        $matriculationNumbersTable .= "<tr> <th>" . gettext("Last name") . " </th> <th>" . gettext("First name") . " </th> <th> " . gettext("Matriculation number") . " </th> <th>" . gettext("Add to exam term") . "</th> </tr>";
        //pre caching
        $ldapManager = exam_organization_ldap_manager::getInstance();
        foreach ($matriculationNumbers as $matriculationNumber) {
            $ldapManager->markForPreload($matriculationNumber);
        }
        $ldapManager->preload();
        $excelRowArray = array();
        //HIS excel
        foreach ($matriculationNumbers as $matriculationNumber) {
            //TODO: a memory problem (next line) while importing big excel files, not good
            //$excelRowArray[$matriculationNumber]=$examOffice->getExcelRowString($tmpFileDestination, $matriculationNumber); //HIS excel
            $firstName = $ldapManager->matriculationNumber2firstName($matriculationNumber);
            $lastName = $ldapManager->matriculationNumber2lastName($matriculationNumber);
            //$imtLogin = $ldapManager->matriculationNumber2imtLogin($matriculationNumber);  //removed for speed
            $matriculationNumbersTable .= "<tr>";
            $matriculationNumbersTable .= "<td>" . $lastName . "</td>";
            $matriculationNumbersTable .= "<td>" . $firstName . "</td>";