";
$tbc_external_review_eligibility_test_form = drupal_get_form("tbc_external_review_eligibility_test_form", $question_id);
$page_content .= drupal_render($tbc_external_review_eligibility_test_form);
/* hidden fields with minutes_remaining and seconds_remaining */
$page_content .= "";
$page_content .= "";
} else if($action == "end") {
$query = "
UPDATE external_review_eligibility_timings
SET status = 2
WHERE uid = {:uid}
";
$result = db_query($query, array(':uid'=> $user->uid));
drupal_set_message("Eligibility Test completed successfully. We will get back to you soon.", "status");
}
else {
/* checking if the user has filled the profile form */
$query = "
SELECT uid FROM external_review_profile
WHERE uid = :uid
";
$result = db_query($query, array(':uid'=> $user->uid));
$num_rows = $result->rowCount();
if(!$num_rows) {
drupal_set_message("Please fill the profile form before you can attend the test.", "error");
drupal_goto("tbc_external_review/profile");
}
/* showing the test details before starting the test */
$page_content .= "
You are about to give a test based on which you will be selected as a reviewer for the Scilab Textbook Companions.
";
$page_content .= "
";
$page_content .= "
The test consists of 5 code review questions that are mandatory.
";
$page_content .= "
Test duration is 25 minutes, after which the test will automatically close.
";
$page_content .= "
";
$page_content .= "" . l("Click here", "tbc_external_review/eligibility_test/question/1") . "";
$page_content .= " to start the test.";
// $page_content .= "The test has been suspended for today due to technical reasons. ";
// $page_content .= "Please visit this page tomorrow.";
}
return $page_content;
}
function tbc_external_review_manage_tests_all($action="", $user_id=0){
/*
end the tests that did not close properly
i.e set status=2 before loading this page in the future\
if the time has expired.
*/
$page_content = "";
if($action == "view" && $user_id) {
/* fetching the correct answers*/
$query = "
SELECT * FROM external_review_eligibility_timings
WHERE uid = :uid
";
$result = db_query($query, array(':uid'=> $user_id));
if($result->rowCount()) {
/* fetching correct answers */
$query = "
SELECT id, ncf, eit, sua, sfu, aci, auu, teo, mit, agl
FROM external_review_eligibility_questions
";
$result = db_query($query);
$correct_answers = array();
while($row = $result->fetchObject()) {
$correct_answers[$row->id] = $row;
}
/* fetching user answers */
$query = "
SELECT * FROM external_review_eligibility_answers
WHERE uid = :uid
";
$result = db_query($query, array(':uid'=> $user_id));
$user_answers = array();
while($row = $result->fetchObject()) {
$user_answers[$row->question_id] = $row;
}
/* comparing the results */
$scores = array();
foreach($user_answers as $user_answer) {
$scores [$user_answer->question_id] = 0;
($user_answer->ncf == $correct_answers[$user_answer->question_id]->ncf)?$scores[$user_answer->question_id]++:Null;
($user_answer->eit == $correct_answers[$user_answer->question_id]->eit)?$scores[$user_answer->question_id]++:Null;
($user_answer->sua == $correct_answers[$user_answer->question_id]->sua)?$scores[$user_answer->question_id]++:Null;
($user_answer->sfu == $correct_answers[$user_answer->question_id]->sfu)?$scores[$user_answer->question_id]++:Null;
($user_answer->aci == $correct_answers[$user_answer->question_id]->aci)?$scores[$user_answer->question_id]++:Null;
($user_answer->auu == $correct_answers[$user_answer->question_id]->auu)?$scores[$user_answer->question_id]++:Null;
($user_answer->teo == $correct_answers[$user_answer->question_id]->teo)?$scores[$user_answer->question_id]++:Null;
($user_answer->mit == $correct_answers[$user_answer->question_id]->mit)?$scores[$user_answer->question_id]++:Null;
($user_answer->agl == $correct_answers[$user_answer->question_id]->agl)?$scores[$user_answer->question_id]++:Null;
}
$page_content .= "
User Score
";
$total_score = 0;
foreach($scores as $key => $value) {
$page_content .= "Question {$key} score = {$value} out of 9 ";
$total_score += $value;
}
$page_content .= "
Total Score = {$total_score} out of 45";
/* fetching user data for display */
$query = "
SELECT * FROM external_review_profile erd
LEFT JOIN users usr ON usr.uid = erd.uid
WHERE erd.uid = :uid
";
$result = db_query($query, array(':uid' => $user_id));
$row = $result->fetchAssoc();
$fields = array(
"first_name", "last_name", "designation", "university",
"phone", "email", "alt_email", "address",
"description"
);
$page_content .= "
User Profile
";
$page_content .= "
";
foreach($fields as $field) {
$page_content .= "