Quiz Results By Category (again)

Quiz Results By Category (again)

by Stephen Chasey -
Number of replies: 4
Hello,

I am putting together a quiz that requires the result to be shown to the student broken down by section.  Based on past posts, it looks like leveraging question categories for this purpose is the most popular approach.  However, the only code samples I see are for version 1.5, and they do not seem to do much in 1.6.2 (perhaps I implemented it poorly).

Anyways, I was hoping to get the current story on this feature before I attempt it myself.  Any suggestions you have are welcome.

Steve
Average of ratings: -
In reply to Stephen Chasey

Re: Quiz Results By Category (again)

by Dr S Bhatia -
Hello

you are another of those who require this. Welcome to the club.
TIM HUNT says this kind of feature is desirable but not being planned in near future.
What i have done is simply created 7 quizzes for seven categories and then created a lesson in which the student will manually fill his grades for all seven categories and the lesson will show his complete report by feedback method.
suits me as of now.

But if you do develop a code, do keep me posted coz i am no good at development.

In reply to Stephen Chasey

Re: Quiz Results By Category (again)

by Jakob Rasmussen -

Hi Stephen

I followed the same thread as you linked to in your posting. And I altered the code to make it work with moodle 1.6. Here is the code:

 

attempt.php

$catraw = $catmax = $catperc = array(); // blank arrays to store category information
foreach($questionidarray as $i) {
   if (!isset($actions[$i])) {
     $actions[$i]->responses = array('' => '');
     }
   $actions[$i]->timestamp = $timestamp;
   question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt);
   if (!isset ($catraw[$questions[$i]->category])) { // if this category has not been seen before
     $catraw[$questions[$i]->category] = 0; // set the raw total to 0
     $catmax[$questions[$i]->category] = 0; // set the maximum possible points to 0
     }
   $catraw[$questions[$i]->category] += $states[$i]->raw_grade; // add to the raw grade achieved for this category
   $catmax[$questions[$i]->category] += $questions[$i]->maxgrade; // add to the max grade possible
   save_question_session($questions[$i], $states[$i]);
 }

 foreach ($catraw as $categoryid=>$categorygrade) { // for each category involved in this quiz
   if (($category = get_record('question_categories', 'id', $categoryid)) && ($catmax[$categoryid]>0)) { // look up the category name
     array_push ($catperc, $category->name.': '.round ($categorygrade/$catmax[$categoryid]*100).'%');
      }
   }
   sort ($catperc); // sort the categories by key
   $attempt->categorygrades = join ("\n", $catperc); // put this information in the new categorygrades field

 

review.php

$table->data[] = array("$strgrade:", get_string('outof', 'quiz', $a));
$table->data[] = array("Categories:", nl2br($attempt->categorygrades));

I get the results for each categori.

Regards

Jakob

 

In reply to Jakob Rasmussen

Re: Quiz Results By Category (again)

by Jakob Rasmussen -

And by the way....

I am still having problem with the pagination of the quiz. The category results are stored in the database for the last page only. So the code must be changed again. I am working on it, but due to bussy days it might take some time. My own quizzes I just keep unpaginated, so every thing is fine.

Jakob