General developer forum

Feature request (Quiz Attempt)

 
Picture of Aditya Dubay
Feature request (Quiz Attempt)
 

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: -
Picture of Aditya Dubay
Re: Feature request (Quiz Attempt)
 
No reply yet sad
 
Average of ratings: -
Gareth J Barnard
Re: Feature request (Quiz Attempt)
Group Core developersGroup Particularly helpful MoodlersGroup 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.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Feature request (Quiz Attempt)
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup 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.

 
Average of ratings: -
Picture of Aditya Dubay
Re: Feature request (Quiz Attempt)
 

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 {

}

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Feature request (Quiz Attempt)
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup 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.

 
Average of ratings: -