Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Calculated question back to quiz button: Difference between revisions

From MoodleDocs
No edit summary
(code to change)
Line 16: Line 16:


the following code in question\type\datasetdependent\datasetitems.php do the trick.
the following code in question\type\datasetdependent\datasetitems.php do the trick.
==Sorry I have to learn how to include HTML code that won't affect the display==
     $strdataitemneed = get_string('dataitemneed', 'quiz');
     $strdataitemneed = get_string('dataitemneed', 'quiz');
     if (!empty($table->data)) {
     if (!empty($table->data)) {
Line 25: Line 24:
             <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\"/>
             <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\"/>
             <input type=\"hidden\" name=\"wizardpage\" value=\"datasetitems\"/>";
             <input type=\"hidden\" name=\"wizardpage\" value=\"datasetitems\"/>";
 
         echo " ".$datatableoption."<\p>";  
         echo " ".$datatableoption."<\p>";
   
         print_table($table); // this prints the remove button and the actual sets of data items
         print_table($table); // this prints the remove button and the actual sets of data items
         echo "</form>";      // this form returns to datasetitems.php to remove one set of  data items
         echo "</form>";      // this form returns to datasetitems.php to remove one set of  data items  
 
         echo "&lt;center&gt;&lt;br /&gt;&lt;br /&gt;<form method=\"post\" action=\"question.php\">
         echo "<center><br /><br /><form method=\"post\" action=\"question.php\">
           <input type=\"hidden\" name=\"id\" value=\"$question->id\"/>
           <input type=\"hidden\" name=\"id\" value=\"$question->id\"/>
           <input type=\"hidden\" name=\"category\" value=\"$question->category\"/>
           <input type=\"hidden\" name=\"category\" value=\"$question->category\"/>
Line 38: Line 34:
           <input type=\"hidden\" name=\"wizardpage\" value=\"datasetitems\"/>
           <input type=\"hidden\" name=\"wizardpage\" value=\"datasetitems\"/>
           <input type=\"submit\" name=\"backtoquiz\" value=\"$strbacktoquiz\">
           <input type=\"submit\" name=\"backtoquiz\" value=\"$strbacktoquiz\">
           </form></center>\n";// this form returns to datasetitems.php and exits to quiz edition
           </form>&lt;/center&gt;\n";// this form returns to datasetitems.php and exits to quiz edition
 
     } else {
     } else {
           notify( $strdataitemneed );//
           notify( $strdataitemneed );//

Revision as of 03:12, 15 June 2006

Controlling the display of the Back to quiz editing button

The question\type\datasetdependent\datasetitems.php which code the display of the third and last form of the creation of a calculated question have been modified so that when there is no data the Back to quiz editing button does not appears items but instead there is a warning.

nobackbutton.jpg

When the user as clicked once on the Add button,

  1. the question parameters are save.
  2. the dataset definitions are updated
  3. the first data items set is saved

and a valid but perhaps incomplete calculated question is created.

The Back to quiz editing button appears.

File:backtoquizbutton.jpg

the following code in question\type\datasetdependent\datasetitems.php do the trick.

   $strdataitemneed = get_string('dataitemneed', 'quiz');
   if (!empty($table->data)) {
       echo "<form method=\"post\" action=\"question.php\">
           <input type=\"hidden\" name=\"id\" value=\"$question->id\"/>
           <input type=\"hidden\" name=\"category\" value=\"$question->category\"/>
           <input type=\"hidden\" name=\"qtype\" value=\"$question->qtype\"/>
           <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\"/>
           <input type=\"hidden\" name=\"wizardpage\" value=\"datasetitems\"/>";
       echo " ".$datatableoption."<\p>";   
       print_table($table); // this prints the remove button and the actual sets of data items
       echo "</form>";      // this form returns to datasetitems.php to remove one set of  data items   
       echo "<center><br /><br /><form method=\"post\" action=\"question.php\">
         <input type=\"hidden\" name=\"id\" value=\"$question->id\"/>
         <input type=\"hidden\" name=\"category\" value=\"$question->category\"/>
         <input type=\"hidden\" name=\"qtype\" value=\"$question->qtype\"/>
         <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\"/>
         <input type=\"hidden\" name=\"wizardpage\" value=\"datasetitems\"/>
         <input type=\"submit\" name=\"backtoquiz\" value=\"$strbacktoquiz\">
         </form></center>\n";// this form returns to datasetitems.php and exits to quiz edition
   } else {
         notify( $strdataitemneed );//
   }
in /;lib/quiz.php 
   $string['dataitemneed'] = 'You need to add at least one set of data items to get a valid question';