Feature request (Quiz Attempt)

Feature request (Quiz Attempt)

by Aditya Dubay -
Number of replies: 5

Hi,

I am using Moodle 3.3.2

I wish a feature in quiz attempt.

I want a unique number like "Reference number" of each quiz attempt must be displayed on attempt summary page as well as with attempts when we download attempts.

For example course short name is "dca", course id is "25", quiz short name is "fcit", quiz id is "36" and attempt id is "234" so it generate reference number like "dca25fcit36234"

Is it possible to create something like this?

 

Average of ratings: -
In reply to Aditya Dubay

Re: Feature request (Quiz Attempt)

by Aditya Dubay -
No reply yet sad
In reply to Aditya Dubay

Re: Feature request (Quiz Attempt)

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Try posting in the Quiz forum with a link to this post asking for help, then you won't fall foul of the forum rules.

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

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.