Esempio n. 1
0
					<div class="answer">
						<?php 
        echo $readonlyAnswer;
        ?>
					</div>
<?php 
    }
} else {
    // Get this person's answers to the survey, and display those which
    // the current member is allowed to see.
    $permissions = $USER->Permissions(true);
    if (count($permissions) == 0) {
        echo "<i>None of {$mem->FirstName()}'s survey answers are available for you to view.</i>";
    }
    foreach ($permissions as $per) {
        $qu = SurveyQuestion::Load($per->QuestionID());
        if (!$qu) {
            continue;
        }
        $ans = $qu->Answers($mem->ID());
        $readonlyAnswer = $ans && $ans->ReadonlyAnswer() ? $ans->ReadonlyAnswer() : '<i>no answer</i>';
        ?>
					<div class="question">
						<?php 
        echo $qu->Question;
        ?>
					</div>
					<div class="answer">
						<?php 
        echo $readonlyAnswer;
        ?>
Esempio n. 2
0
        $ansObj->Save();
    }
}
// Identify un-answered questions, both required and not.
// We poll the DB because un-checked checkboxes aren't submitted
// at all, so we have to manually check if they're missing.
// If the question requires an answer, enforce that requirement.
// If the question is not required, give un-filled answers an empty value.
// (This whole block isn't very efficient way to do this, but for
// the low traffic volume we get, it should be fine.... for now...
// especially considering how quickly this had to be ready!)
$q = "SELECT ID FROM SurveyQuestions WHERE WardID={$MEMBER->WardID} AND Visible='1'";
$r = DB::Run($q);
while ($row = mysql_fetch_array($r)) {
    // Find out about the question and the user's answer to it, if any
    $reqQu = SurveyQuestion::Load($row['ID']);
    $userAns = isset($answers[$reqQu->ID()]) ? $answers[$reqQu->ID()] : null;
    if (is_string($userAns)) {
        $userAns = trim($userAns);
    }
    // If it IS required, and not answered, time to throw.
    if ($reqQu->Required && (!$userAns || !is_array($userAns) && strlen(trim($userAns)) == 0 || $userAns == ' ')) {
        Response::Send(400, "Please answer the required question:<br><br>\"" . $reqQu->Question . "\"");
    }
    // If NOT required, set to empty value if not filled out
    if (!$reqQu->Required && (!$userAns || !is_array($userAns) && strlen(trim($userAns)) == 0 || $userAns == ' ')) {
        // First we have to get it from the DB.
        $ansObj = $reqQu->Answers($memID);
        // TODO: FIX THIS:
        // I added this if statement because this block was causing errors
        // in the error log (a lot of them):
Esempio n. 3
0
?>
			</div>

			<div class="grid-container" style="font-size: 16px;">

				<div class="grid-100 text-center" style="font-size: 12px;">
					<i>Questions marked with <span class="req">*</span> require an answer.</i>
					<hr>
				</div>

<?php 
$i = 0;
// Display questions / answers
while ($row = mysql_fetch_array($r)) {
    // Load the question...
    $sq = SurveyQuestion::Load($row['ID']);
    // Load this member's answer
    $ans = $sq->Answers($MEMBER->ID());
    // Create the name for this question's answer's input field
    $inputName = 'answers[' . $sq->ID() . ']';
    // Array idx is question ID
    // Is this question designed to have radio buttons or checkboxes?
    $multAnsOpt = $sq->QuestionType == QuestionType::MultipleChoice || $sq->QuestionType == QuestionType::MultipleAnswer;
    // Okay, now which one?
    $inputType = "radio";
    if ($sq->QuestionType == QuestionType::MultipleAnswer) {
        $inputType = "checkbox";
        $inputName .= '[]';
        // Store each check, not just the last one
    }
    $inputID = "field" . $i;
Esempio n. 4
0
 public function Delete($sure = false, $hardDelete = false)
 {
     if ($sure !== true) {
         fail("Cannot delete ward; please pass boolean true as a second argument.");
     }
     if (!$this->ID) {
         return false;
     }
     $wid = $this->ID;
     // convenience
     // FHE groups
     DB::Run("DELETE FROM FheGroups WHERE WardID={$wid}");
     // Residences
     $res = $ward->Residences(true);
     foreach ($res as $residence) {
         $res->Delete(true);
     }
     // SurveyQuestions, SurveyAnswers, SurveyAnswerOptions, Permissions
     $r = DB::Run("SELECT ID FROM SurveyQuestions WHERE WardID={$wid}");
     while ($row = mysql_fetch_array($r)) {
         $sq = SurveyQuestion::Load($row['ID']);
         $sq->Delete(true);
     }
     // Callings, MembersCallings, and any remaining calling Permissions (shouldn't be any...)
     $r = DB::Run("SELECT ID FROM Callings WHERE WardID={$wid}");
     while ($row = mysql_fetch_array($r)) {
         $c = Calling::Load($row['ID']);
         $c->Delete(true);
     }
     // Members, Credentials, GrantedPrivileges, remaining Callings, PwdResetTokens,
     // profile pic, and remaining member Permissions (shouldn't be any...)
     // (Everything else except the ward itself)
     $r = DB::Run("SELECT ID FROM Members WHERE WardID={$wid}");
     while ($row = mysql_fetch_array($r)) {
         $m = Member::Load($row['ID']);
         $m->Delete(true);
     }
     // Ward itself
     if ($hardDelete) {
         DB::Run("DELETE FROM Wards WHERE ID={$wid} LIMIT 1");
         // Unset this object so it can't inadvertently be saved again
         $this->ID = null;
         $this->Name = null;
     } else {
         $this->Deleted = true;
         $this->Save();
     }
     return true;
 }
Esempio n. 5
0
@($question = $_POST['question']);
@($qtype = $_POST['qtype']);
@($qid = $_POST['qid']);
$ansArray = isset($_POST['ans']) ? $_POST['ans'] : null;
$req = isset($_POST['req']) ? true : false;
$visible = isset($_POST['visible']) ? true : false;
$delete = isset($_POST['delete']) ? true : false;
// Validation
if (!$qid) {
    fail("No question ID found. Must abort... please report this.");
}
if (!$question || strlen(trim($question)) < 3) {
    Response::Send(401, "The question must be at least 3 characters long.");
}
// Load existing question
$existing = SurveyQuestion::Load($qid);
// Validate it...
if (!is_object($existing)) {
    fail("Not a valid question was loaded, so thus it can't be changed! (Is the ID {$qid} correct?)");
}
// Make sure it's in the same ward...
if ($existing->WardID != $MEMBER->WardID) {
    Response::Send(403, "You may only change questions which belong to your ward.");
}
// Are we to delete this question?
if ($delete) {
    if (!$existing->Delete(true)) {
        fail("Could not delete question... not sure why... do report this, though.");
    }
    Response::Send(200);
}