Quiz

Reducing the 'scroll of half-death' in the Summary Of Attempt table

 
This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
Frankie's the name, Moodle's my game!
Reducing the 'scroll of half-death' in the Summary Of Attempt table
Group Particularly helpful MoodlersGroup Plugin developers

Hi. Ain't nuthing wrong with the Summary Of Attempt table. However, since by default it consists of only one column, a quiz of 50 to 100 quiz questions will result in a Summary of Attempt table that extends for most of the screen's height. I have to scroll all the way down to access and to click the "Submit all and Finish' or 'Return to attempt' buttons. Here's what my summary looks like with a quiz of 20 questions.

Just wondering if the table could be redesigned to fit across two columns, like so:

 

 

But why, you may ask? I think it looks nicer and the user, can at a glance see the status of all questions without having to scroll down. 

I've narrowed down the Moodle 2.5 code to the  

   public function summary_table($attemptobj, $displayoptions)

function found inside the moodle/quiz/renderer.php file. Full code is below:

/**

* Generates the table of summarydata
*
* @param quiz_attempt $attemptobj
* @param mod_quiz_display_options $displayoptions
*/
public function summary_table($attemptobj, $displayoptions) {
   // Prepare the summary table header.
   $table = new html_table();
   $table->attributes['class'] = 'generaltable quizsummaryofattempt boxaligncenter';
   $table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
   $table->align = array('left', 'left');
   $table->size = array('', '');
   $markscolumn = $displayoptions->marks >= question_display_options::MARK_AND_MAX;
   if ($markscolumn) {
      $table->head[] = get_string('marks', 'quiz');
      $table->align[] = 'left';
      $table->size[] = '';
   }
   $table->data = array();

   // Get the summary info for each question.
   $slots = $attemptobj->get_slots();
   foreach ($slots as $slot) {
      if (!$attemptobj->is_real_question($slot)) {
         continue;
      }
      $flag = '';
      if ($attemptobj->is_question_flagged($slot)) {
         $flag = html_writer::empty_tag('img', array('src' => $this->pix_url('i/flagged'),
         'alt' => get_string('flagged', 'question'), 'class' => 'questionflag icon-post'));
      }
      if ($attemptobj->can_navigate_to($slot)) {
         $row = array(html_writer::link($attemptobj->attempt_url($slot),
         $attemptobj->get_question_number($slot) . $flag),
         $attemptobj->get_question_status($slot, $displayoptions->correctness));
      } else {
               $row = array($attemptobj->get_question_number($slot) . $flag,
               $attemptobj->get_question_status($slot, $displayoptions->correctness));
             }
      if ($markscolumn) {
         $row[] = $attemptobj->get_question_mark($slot);
      }
      $table->data[] = $row;
      $table->rowclasses[] = $attemptobj->get_question_state_class(
      $slot, $displayoptions->correctness);
   }

   // Print the summary table.
   $output = html_writer::table($table);

   return $output;
}

 

Nope, I haven't got the answer yet. To be continued....stay tuned for the next episode of Moodle HSI - 'Hack Scene Investigation'. 

 
Average of ratings: Useful (2)
Frankie's the name, Moodle's my game!
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
Group Particularly helpful MoodlersGroup Plugin developers

How to place two tables (columns?) next to each other, instead of having one below the other?
Related post: https://moodle.org/mod/forum/discuss.php?d=233974

Useful technical information on the array of html_table_row objects:
http://phpdocs.moodle.org/HEAD/core/lib/html_table.html

 

 
Average of ratings: -
Picture of Anh Tuan Bui
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
 

Hi Frankie,

This is a very interesting and useful hack ! Have you made any progress to solve it yet?

Cheers

Tuan

 
Average of ratings: -
Frankie's the name, Moodle's my game!
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
Group Particularly helpful MoodlersGroup Plugin developers

Hi Anh

No progress yet. Defeated by the complexity of the code.

frankie

 
Average of ratings: -
Frankie's the name, Moodle's my game!
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
Group Particularly helpful MoodlersGroup Plugin developers

Hi y'all

I'm almost there. Here's what I've managed to craft:


This 'solution' is based on my C++ code here: https://ideone.com/4q7KbY

Unfortunately the below bold sections of PHP code are not working. Does anyone have any how to solve the problem of the second and third Question columns being blank?

$row = array(html_writer::

link($attemptobj->attempt_url($slots[$r-1]), $attemptobj->get_question_number($slots[$r-1]) . $flag), 

$attemptobj->get_question_status($slots[$r-1], $displayoptions->correctness),

link($attemptobj->attempt_url($slots[$r-1+($nearest3/$COLS)]), $attemptobj->get_question_number($slots[$r-1+($nearest3/$COLS)]) . $flag), 

$attemptobj->get_question_status($slots[$r-1+($nearest3/$COLS)], $displayoptions->correctness),

link($attemptobj->attempt_url($slots[$r-1+($nearest3/$COLS)*2]), $attemptobj->get_question_number($slots[$r-1+($nearest3/$COLS)*2]) . $flag), 

$attemptobj->get_question_status($slots[$r-1+($nearest3/$COLS)*2], $displayoptions->correctness)

);

See attached renderer.php (Moodle 2.7.2)

 
Average of ratings: -
Frankie's the name, Moodle's my game!
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
Group Particularly helpful MoodlersGroup Plugin developers

Good news!

After 17 months, I revisited this problem and today I have solved it.
See here. Hope you find this useful.

wink



If you find this new layout useful, please let me know.

Cheers,
Frankie Kam, Malaysia

 
Average of ratings: -
Picture of Joelene Juries
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
 

Hi Frankie Kam

Congratulations, I do not have a clue about code but I celebrate with you. I have read your thread as it progressed. I signed up to the community just now and I have only been working with the moodle programme since 8 July 2014 here in Cape Town South Africa since we have only recently adopted the LMS for our schooling system in the Western Cape.

I just want to extend my admiration at your ability to keep working on a problem until you have cracked it. I salute you. I am teaching Natural Sciences, Grade 8 and I am currently finding my way around the moodle LMS developing my course. I am enjoying it so much. You inspire me and I can relate just a little bit to the feeling of success that you must be experiencing right now. It is a really fine feeling when I sit on my own and fiddle with an object until I get it right. I have nobody to really help me and nobody to really share any good resultant feelings with. There are days when I wish I could buy time, just to moodle. Now I have found this community of 'fundis' that I can learn from.  Great to be here!

Cheers

Joelene Juries



 
Average of ratings: -
Frankie's the name, Moodle's my game!
Re: Reducing the 'scroll of half-death' in the Summary Of Attempt table
Group Particularly helpful MoodlersGroup Plugin developers

Hi Joelene

Thank you for watching the latest episode of Moodle HSI - 'Hack Scene Investigation'.  And many thanks for your kind words! I wish you all the best in your Moodle discoveries and quest. May you also infect one or two other colleagues in your institution to become Moodle drivers. If you have the 'time', do drop by my humble blog for a cup of cha and some of Malaysia's finest durian fruit. You will find my tinkering work with Moodle over the past couple of years, and who knows, you may find something interesting that can be used with your students and your courses. Having said that, the real boffins and coders of Moodle are those who hang out at moodle.org. I'm just a little programmer wannabe. Finally if you need any help, you can always send out a post here on Moodle.org for the community to respond to.

Cheers and cheerio, will be back soon,
Frankie Kam, Malaysia


 
Average of ratings: -