Feature request (Quiz Attempt)

Re: Feature request (Quiz Attempt)

by Tim Hunt -
Number of replies: 2
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Of course it is possible, but the only easy way is by changing core code in the quiz reports.

Or, you could make your own quiz report plugin.

In reply to Tim Hunt

Re: Feature request (Quiz Attempt)

by Aditya Dubay -

Hi Tim,

Thanks for reply.

We added below code in view.php of quiz module and it works fine, but, we still want this as core functionality of moodle or as plugin. We try to make plugin but we are not able to do.


//to get the quize id in particular page
$cm = $PAGE->cm;
$quiz_details = $DB->get_record('quiz', array('id' => $cm->instance));
$quiz_id = $quiz_details->id;

// check the details in course attemp that exam avilabe or not
$userid = $USER->id;
// connection goes here
$dbhost = $CFG->dbhost;
$dbname = $CFG->dbname;
$dbuser = $CFG->dbuser;
$dbpass = $CFG->dbpass;
$conn = new mysqli($dbhost, $dbuser, $dbpass,$dbname);

$sql_check_attempt = $conn->query("SELECT * FROM mdl_quiz_attempts
WHERE `userid` = '$userid' AND `quiz` = '$quiz_id' AND `state` = 'finished'");

$count_row = $sql_check_attempt->num_rows;
if ($count_row>0) {
while ($row = $sql_check_attempt->fetch_assoc()) {
$quiz_id = $row['quiz'];
$uniqueid = $row['uniqueid'];
}
echo "<span style='color:red; font-weight:bold;'> Reference Number : "
.$quiz_id.$uniqueid.$userid.
"</span>";

} else {

}

In reply to Aditya Dubay

Re: Feature request (Quiz Attempt)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can do that more elegantly using this technique: https://docs.moodle.org/dev/Overriding_a_renderer

You cannot expect Moodle core to add a feature of displaying 'Reference numbers' in a weird format that is specific to your university. Things can only go into Moodle core if they are generic.