0 votes
in SoSci Survey (dt.) by s053408 (120 points)
edited by SoSci Survey

Guten Tag,

Wir haben einen automatischen Code für das mehrfache Versenden von E-Mails für eine Tagebuchstudie. Für den Tagebuchteil konnten die Teilnehmer eine von drei „Kohorten“ wählen. Es gab jedoch einen Fehler im Code, da alle Daten unter der ersten Kohorte gesammelt wurden. Wir sind uns nicht sicher, was wir falsch gemacht haben. Könnten Sie uns vielleicht helfen?

Viele Grüße,

Code:

$date = date("Y-m-d H:i:s");
$date = strtotime($date);

       // Diary IDs
$diary_011 =7; $diary_021 = 12; $diary_031 = 16; $diary_041 =20; $diary_051 =24;
$diary_012 =9; $diary_022 = 13; $diary_032 =17; $diary_042 =21; $diary_052 =25;
$diary_013 =10; $diary_023 = 14; $diary_033 =18; $diary_043 =22; $diary_053 =26;
$diary_014 =11; $diary_024 = 15; $diary_034 = 19; $diary_044 =23; $diary_054 =27;

$diary_061 =28; $diary_071 =32; $diary_081 =36; $diary_091 =40; $diary_101 =44;
$diary_062 =29; $diary_072 =33; $diary_082 =37; $diary_092 =41; $diary_102 =45;
$diary_063 =30; $diary_073 =34; $diary_083 =38; $diary_093 =42; $diary_103 =46;
$diary_064 =31; $diary_074 =35; $diary_084 =39; $diary_094 =43; $diary_104 =47;

// Kohorte 1 
if (value("AN17") == 1) {
	$day01 = date('d.m.Y', strtotime('17.06.2024'));
	$day02 = date('d.m.Y', strtotime('18.06.2024'));
        $day03 = date('d.m.Y', strtotime('19.06.2024'));
	$day04 = date('d.m.Y', strtotime('20.06.2024'));
        $day05 = date('d.m.Y', strtotime('21.06.2024'));
	$day06 = date('d.m.Y', strtotime('24.06.2024'));
        $day07 = date('d.m.Y', strtotime('25.06.2024'));
	$day08 = date('d.m.Y', strtotime('26.06.2024'));
        $day09 = date('d.m.Y', strtotime('27.06.2024'));
	$day10 = date('d.m.Y', strtotime('28.06.2024'));

    }
// Kohorte 
if (value("AN17") == 2) {
	$day01 = date('d.m.Y', strtotime('24.06.2024'));
	$day02 = date('d.m.Y', strtotime('25.06.2024'));
        $day03 = date('d.m.Y', strtotime('26.06.2024'));
	$day04 = date('d.m.Y', strtotime('27.06.2024'));
        $day05 = date('d.m.Y', strtotime('28.06.2024'));
	$day06 = date('d.m.Y', strtotime('01.07.2024'));
        $day07 = date('d.m.Y', strtotime('02.07.2024'));
	$day08 = date('d.m.Y', strtotime('03.07.2024'));
        $day09 = date('d.m.Y', strtotime('04.07.2024'));
	$day10 = date('d.m.Y', strtotime('05.07.2024'));
    }
// Kohorte 3 
if (value("AN17") == 3) {
	$day01 = date('d.m.Y', strtotime('01.07.2024'));
	$day02 = date('d.m.Y', strtotime('02.07.2024'));
        $day03 = date('d.m.Y', strtotime('03.07.2024'));
	$day04 = date('d.m.Y', strtotime('04.07.2024'));
        $day05 = date('d.m.Y', strtotime('05.07.2024'));
	$day06 = date('d.m.Y', strtotime('08.07.2024'));
        $day07 = date('d.m.Y', strtotime('09.07.2024'));
	$day08 = date('d.m.Y', strtotime('10.07.2024'));
        $day09 = date('d.m.Y', strtotime('11.07.2024'));
	$day10 = date('d.m.Y', strtotime('12.07.2024'));
    }

//////////////////////// Diary E-Mails planen  ///////////////////////// 
// Startdatum Diary abspeichern und in Platzhalter ersetzen
// put('start_diary', $day01); 
// Diary + Erinnerung Diary Uhrzeiten nach MZP definieren & Mails versenden

$MZP_011= date("H:i", strtotime('.06:00.')); 
$MZP_012= date("H:i", strtotime('.11:00.')); 
$MZP_013= date("H:i", strtotime('.15:00.'));
$MZP_014= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_011, strtotime($day01 ." ".$MZP_011));            
mailSchedule(false, $diary_012, strtotime($day01 ." ".$MZP_012));
mailSchedule(false, $diary_013, strtotime($day01 ." ".$MZP_013));
mailSchedule(false, $diary_014, strtotime($day01 ." ".$MZP_014));

$MZP_021= date("H:i", strtotime('.06:00.')); 
$MZP_022= date("H:i", strtotime('.11:00.')); 
$MZP_023= date("H:i", strtotime('.15:00.'));
$MZP_024= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_021, strtotime($day02 ." ".$MZP_021));            
mailSchedule(false, $diary_022, strtotime($day02 ." ".$MZP_022));
mailSchedule(false, $diary_023, strtotime($day02 ." ".$MZP_023));
mailSchedule(false, $diary_024, strtotime($day02 ." ".$MZP_024));

$MZP_031= date("H:i", strtotime('.06:00.')); 
$MZP_032= date("H:i", strtotime('.11:00.')); 
$MZP_033= date("H:i", strtotime('.15:00.'));
$MZP_034= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_031, strtotime($day03 ." ".$MZP_031));            
mailSchedule(false, $diary_032, strtotime($day03 ." ".$MZP_032));
mailSchedule(false, $diary_033, strtotime($day03 ." ".$MZP_033));
mailSchedule(false, $diary_034, strtotime($day03 ." ".$MZP_034));

$MZP_041= date("H:i", strtotime('.06:00.')); 
$MZP_042= date("H:i", strtotime('.11:00.')); 
$MZP_043= date("H:i", strtotime('.15:00.'));
$MZP_044= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_041, strtotime($day04 ." ".$MZP_041));            
mailSchedule(false, $diary_042, strtotime($day04 ." ".$MZP_042));
mailSchedule(false, $diary_043, strtotime($day04 ." ".$MZP_043));
mailSchedule(false, $diary_044, strtotime($day04 ." ".$MZP_044));

$MZP_051= date("H:i", strtotime('.06:00.')); 
$MZP_052= date("H:i", strtotime('.11:00.')); 
$MZP_053= date("H:i", strtotime('.15:00.'));
$MZP_054= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_051, strtotime($day05 ." ".$MZP_051));            
mailSchedule(false, $diary_052, strtotime($day05 ." ".$MZP_052));
mailSchedule(false, $diary_053, strtotime($day05 ." ".$MZP_053));
mailSchedule(false, $diary_054, strtotime($day05 ." ".$MZP_054));

$MZP_061= date("H:i", strtotime('.06:00.')); 
$MZP_062= date("H:i", strtotime('.11:00.')); 
$MZP_063= date("H:i", strtotime('.15:00.'));
$MZP_064= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_061, strtotime($day06 ." ".$MZP_061));            
mailSchedule(false, $diary_062, strtotime($day06 ." ".$MZP_062));
mailSchedule(false, $diary_063, strtotime($day06 ." ".$MZP_063));
mailSchedule(false, $diary_064, strtotime($day06 ." ".$MZP_064));

$MZP_071= date("H:i", strtotime('.06:00.')); 
$MZP_072= date("H:i", strtotime('.11:00.')); 
$MZP_073= date("H:i", strtotime('.15:00.'));
$MZP_074= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_071, strtotime($day07 ." ".$MZP_071));            
mailSchedule(false, $diary_072, strtotime($day07 ." ".$MZP_072));
mailSchedule(false, $diary_073, strtotime($day07 ." ".$MZP_073));
mailSchedule(false, $diary_074, strtotime($day07 ." ".$MZP_074));

$MZP_081= date("H:i", strtotime('.06:00.')); 
$MZP_082= date("H:i", strtotime('.11:00.')); 
$MZP_083= date("H:i", strtotime('.15:00.'));
$MZP_084= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_081, strtotime($day08 ." ".$MZP_081));            
mailSchedule(false, $diary_082, strtotime($day08 ." ".$MZP_082));
mailSchedule(false, $diary_083, strtotime($day08 ." ".$MZP_083));
mailSchedule(false, $diary_084, strtotime($day08 ." ".$MZP_084));

$MZP_091= date("H:i", strtotime('.06:00.')); 
$MZP_092= date("H:i", strtotime('.11:00.')); 
$MZP_093= date("H:i", strtotime('.15:00.'));
$MZP_094= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_091, strtotime($day09 ." ".$MZP_091));            
mailSchedule(false, $diary_092, strtotime($day09 ." ".$MZP_092));
mailSchedule(false, $diary_093, strtotime($day09 ." ".$MZP_093));
mailSchedule(false, $diary_094, strtotime($day09 ." ".$MZP_094));

$MZP_101= date("H:i", strtotime('.06:00.')); 
$MZP_102= date("H:i", strtotime('.11:00.')); 
$MZP_103= date("H:i", strtotime('.15:00.'));
$MZP_104= date("H:i", strtotime('.18:00.')); 

mailSchedule(false, $diary_101, strtotime($day10 ." ".$MZP_101));            
mailSchedule(false, $diary_102, strtotime($day10 ." ".$MZP_102));
mailSchedule(false, $diary_103, strtotime($day10 ." ".$MZP_103));
mailSchedule(false, $diary_104, strtotime($day10 ." ".$MZP_104));

// Eingangsbefragung
$vorab = 3;
mailSchedule(false, $vorab, 1); // zu Testzwecken nur eine Sekunde, bis der
// Versand der Eingangsbefragung beginnt. Ich würde die Zeit zwischen Bestätigung
// und Versand relativ knapp halten, müssen wir aber noch klären

goToPage('end');

1 Answer

+1 vote
by SoSci Survey (324k points)

Der Code ist ein wenig arg umständlich. Mit der Zeile

$day10 = date('d.m.Y', strtotime('12.07.2024'));

wandeln Sie z.B. nur den String '12.07.2024' in einen Unix-Zeitstempel, und diesen dann wieder zurück in einen String um. Allerdings würde ich mich darauf verlassen, dass strtotime() die deutsche Angabe Tag.Monat.Jahr immer korrekte versteht - mit '2024-07-12' ist man auf der sicheren Seite. Unabhängig davon: Die Zeile könnte man einfacher als

$day10 = '12.07.2024';

schreiben. Auch bin ich nicht ganz sicher, ob strototime() die Zeitangaben mit Punkten vor und hinter der Zeit korrekt interpretiert. Auch hier ist die doppelte Umwandlung wieder nicht sinnvoll.

Den unteren Teil des Codes könnten Sie deutlich eleganter mit einer FOR-Schleife schreiben.

Aber trotz dieser noch oiptimierbaren Code-Formulierung ... ich sehe keinen offensichtlichen Fehler. Sie haben überprüft, dass für AN17 alle Codes (1, 2 und 3) im Datensatz vorkommen?

Was sagt denn die Debug-Information, wenn Sie AN17 auf den Wert 2 setzen und dann die Seite mit dem PHP-Code aufrufen?

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...