function SendQuizResponseMail($quizId, $assId, $menteeId, $menteeEmail, $givenAns, $ans, $correct) { $resp = "-1"; $givenAnswers = json_decode($givenAns, true); //$correctAnswers = json_decode($ans, true); $correctAnswers = $ans; $mentee = GetMenteeDetailsByEmail($menteeEmail); try { $subject = "Quiz Submitted - Mentored-Research"; $msg = "Dear " . $mentee["MenteeName"] . ","; $msg .= "You have submitted your Quiz(" . GetQuizNameById($quizId) . ") in the assignment(" . GetAssignmentName($assId) . "). <br /> "; $msg .= "<b>Your score is: " . $correct . "</b><br /><br />"; $msg .= "The answers given by you were: <br />1. " . $givenAnswers[0] . "<br />2. " . $givenAnswers[1] . "<br />3. " . $givenAnswers[2] . "<br />4. " . $givenAnswers[3] . "<br />5. " . $givenAnswers[4] . "<br /><br />"; $msg .= "The correct answers are: <br />1. " . $correctAnswers[0] . "<br />2. " . $correctAnswers[1] . "<br />3. " . $correctAnswers[2] . "<br />4. " . $correctAnswers[3] . "<br />5. " . $correctAnswers[4] . "<br /><br />"; $msg .= "Please contact your mentor in case of any doubts.<br /><br />"; $msg .= "Team Mentored-Research<br />"; $msg .= "info@mentored-research.com<br /><br />"; $msg .= "Please do not reply to this automated mail.<br /><br />"; //write the mail sending if else condition here. $res = SendMessage($menteeEmail, $mentee["MenteeName"], "*****@*****.**", "Mentored-Research", $subject, $msg); return $res; } catch (Exception $e) { $resp = "-1"; return $resp; } }
function GetQuizDetailsByAssignment($assId, $menteeId, $menteeEmail) { $resp = "-1"; $attempt = array(); try { $query = "select * from Quiz where AssID='{$assId}'"; $rs = mysql_query($query); if (!$rs) { $resp = "-1"; } else { if (mysql_num_rows($rs) > 0) { $resp = ""; while ($res = mysql_fetch_array($rs)) { $attempt = IsQuizAttempted($menteeId, $res["QuizID"]); if ($attempt["Error"] == "1") { $resp .= GetQuizNameById($res["QuizID"]) . " could not be loaded. Please try again."; } else { if ($attempt["IsAttempted"] == "1") { // quiz has been attempted. if ($res["QuizType"] == "0") { $resp .= "<tr><td colspan='2'><h3>" . $res["QuizName"] . "</h3></td></tr> <tr><td>Quiz Posted On: </td><td>" . $res["QuizPostedOn"] . "</td></tr> <tr><td>Quiz Deadline: </td><td>" . $res["QuizDeadline"] . "</td></tr> <tr><td colspan='2'><p>" . $res["QuizName"] . " has already been attempted. Your Score is: " . $attempt["CorrectAns"] . "/5. </p></td></tr>"; } else { if ($res["QuizType"] == "1") { if ($attempt["CorrectAns"] == "-1") { // not yet evaluated $resp .= "<tr><td colspan='2'><h3>" . $res["QuizName"] . "</h3></td></tr> <tr><td>Quiz Posted On: </td><td>" . $res["QuizPostedOn"] . "</td></tr> <tr><td>Quiz Deadline: </td><td>" . $res["QuizDeadline"] . "</td></tr> <tr><td colspan='2'><p>" . $res["QuizName"] . " has already been attempted. You will be notified through mail for Quiz Evaluation and Scores. </p></td></tr>"; } else { $resp .= "<tr><td colspan='2'><h3>" . $res["QuizName"] . "</h3></td></tr> <tr><td>Quiz Posted On: </td><td>" . $res["QuizPostedOn"] . "</td></tr> <tr><td>Quiz Deadline: </td><td>" . $res["QuizDeadline"] . "</td></tr> <tr><td colspan='2'><p>" . $res["QuizName"] . " has already been attempted and Evaluated. Your Score is: " . $attempt["CorrectAns"] . "</p></td></tr>"; } } } } else { // quiz has not been attempted if ($res["QuizType"] == "0") { $resp .= "<tr><td colspan='2'><h3>" . $res["QuizName"] . "</h3></td></tr> <tr><td>Quiz Posted On: </td><td>" . $res["QuizPostedOn"] . "</td></tr> <tr><td>Quiz Deadline: </td><td>" . $res["QuizDeadline"] . "</td></tr> <tr><td colspan='2'><input type='button' class='btn btn-lg btn-primary btn-block btnAttemptQuiz' value='Attempt " . $res["QuizName"] . "' data-id='" . $res["QuizID"] . "' data-name='" . $res["QuizName"] . "' /></td></tr>"; } else { if ($res["QuizType"] == "1") { $resp .= "<tr><td colspan='2'><h3>" . $res["QuizName"] . "</h3></td></tr> <tr><td>Quiz Posted On: </td><td>" . $res["QuizPostedOn"] . "</td></tr> <tr><td>Quiz Deadline: </td><td>" . $res["QuizDeadline"] . "</td></tr> <tr><td colspan='2'><input type='button' class='btn btn-lg btn-primary btn-block btnAttemptAdvQuiz' value='Attempt " . $res["QuizName"] . "' data-id='" . $res["QuizID"] . "' data-name='" . $res["QuizName"] . "' /></td></tr>"; } } } } } } else { $resp = "0"; } } echo $resp; } catch (Exception $e) { $resp = "-1"; echo $resp; } }