]> git.mjollnir.org Git - moodle.git/commitdiff
quiz manual grading: MDL-5517 manual grading pop-up is too small. HTML editor does...
authortjhunt <tjhunt>
Wed, 10 Dec 2008 09:11:30 +0000 (09:11 +0000)
committertjhunt <tjhunt>
Wed, 10 Dec 2008 09:11:30 +0000 (09:11 +0000)
Also MDL-17585 Improve layout of manual grading forms to make them look more like formslib forms. The standard trick of stealing the HTML and class names that formslib works, so the standard style rules apply to your form.

lang/en_utf8/quiz_grading.php
lib/questionlib.php
mod/quiz/attemptlib.php
mod/quiz/comment.php
mod/quiz/report/grading/report.php
question/type/questiontype.php
theme/standard/styles_layout.css

index 02e6801068b6f843c711489836f48db6bce2b7b5..87d9e6e3c9a70bd989db3c9161bb82a6928505aa 100644 (file)
@@ -14,7 +14,7 @@ $string['gradeungraded'] = 'Grade all $a ungraded attempts';
 $string['gradenextungraded'] = 'Grade next $a ungraded attempts';
 $string['gradinguser'] = 'Attempts for $a';
 $string['gradingall'] = 'All $a attempts on this question.';
-$string['gradingattempt'] = 'Attempt number $a->attempt for $a->fullname.';
+$string['gradingattempt'] = 'Attempt number $a->attempt for $a->fullname';
 $string['gradingnextungraded'] = 'Next $a ungraded attempts';
 $string['gradingnotallowed'] = 'You do not have permission to manually grade responses in this quiz';
 $string['gradingungraded'] = '$a ungraded attempts';
index a6e2ee51b82d1f3aa72a91d6e5185ceb262a81b4..1a16128807021a57232f544e6b420765b492c0af 100644 (file)
@@ -1729,26 +1729,38 @@ function get_question_image($question) {
     return $img;
 }
 
-function question_print_comment_fields($question, $state, $prefix, $cmoptions) {
+function question_print_comment_fields($question, $state, $prefix, $cmoptions, $caption = '') {
     $idprefix = preg_replace('/[^-_a-zA-Z0-9]/', '', $prefix);
     $grade = question_format_grade($cmoptions, $state->last_graded->grade);
     $maxgrade = question_format_grade($cmoptions, $question->maxgrade);
     $fieldsize = strlen($maxgrade) - 1;
-    echo '<table class="que comment">' . "\n";
-    echo '<tr valign="top">' . "\n";
-    echo '<th><label for="' . $idprefix . '_comment_box">' .
-            get_string('comment', 'quiz') . "</label></th>\n";
-    echo '<td>';
-    print_textarea(can_use_html_editor(), 15, 60, 630, 300, $prefix . '[comment]',
-            $state->manualcomment, 0, false, $idprefix . '_comment_box');
-    echo "</td>\n";
-    echo "</tr>\n";
-    echo '<tr valign="top">' . "\n";
-    echo '<th><label for="' .  $idprefix . '_grade_field">' . get_string('grade', 'quiz') . "</label></th>\n";
-    echo '<td><input type="text" name="' . $prefix . '[grade]" size="' . $fieldsize .
-            '" id="' . $idprefix . '_grade_field" value="' . $grade . '" />/' . $maxgrade . "</td>\n";
-    echo "</tr>\n";
-    echo "</table>\n";
+    if (empty($caption)) {
+        $caption = format_string($question->name);
+    }
+    ?>
+<fieldset class="que comment clearfix">
+    <legend class="ftoggler"><?php echo $caption; ?></legend>
+    <div class="fcontainer clearfix">
+        <div class="fitem">
+            <div class="fitemtitle">
+                <label for="<?php echo $idprefix; ?>_comment_box"><?php print_string('comment', 'quiz'); ?></label>
+            </div>
+            <div class="felement fhtmleditor">
+                <?php print_textarea(can_use_html_editor(), 15, 60, 630, 300, $prefix . '[comment]',
+                        $state->manualcomment, 0, false, $idprefix . '_comment_box'); ?>
+            </div>
+        </div>
+        <div class="fitem">
+            <div class="fitemtitle">
+                <label for="<?php echo $idprefix; ?>_grade_field"><?php print_string('grade', 'quiz'); ?></label>
+            </div>
+            <div class="felement ftext">
+                <input type="text" name="<?php echo $prefix; ?>[grade]" size="<?php echo $fieldsize; ?>" id="<?php echo $idprefix; ?>_grade_field" value="<?php echo $grade; ?>" /> / <?php echo $maxgrade; ?>
+            </div>
+        </div>
+    </div>
+</fieldset>
+    <?php
 }
 
 /**
index 9a04eb040c877f5209f3d29116b1818971ab457f..541fe508c6dc4b8cfb8a5d5cb7333e4ccf7529c8 100644 (file)
@@ -740,10 +740,19 @@ class quiz_attempt extends quiz {
     }
 
     public function question_print_comment_fields($questionid, $prefix) {
+        global $DB;
+
         $this->ensure_question_loaded($questionid);
         $this->ensure_state_loaded($questionid);
+
+    /// Work out a nice title.
+        $student = $DB->get_record('user', array('id' => $this->get_userid()));
+        $a = new object();
+        $a->fullname = fullname($student, true);
+        $a->attempt = $this->get_attempt_number();
+
         question_print_comment_fields($this->questions[$questionid],
-                $this->states[$questionid], $prefix, $this->quiz);
+                $this->states[$questionid], $prefix, $this->quiz, get_string('gradingattempt', 'quiz_grading', $a));
     }
 
     // Private methods =====================================================================
index 1a68477865a3210cc46722fa04061e13afb66387..49b585d637d4ebfeb3189aac25600e6c1e295870 100644 (file)
@@ -10,8 +10,8 @@
     require_once('../../config.php');
     require_once('locallib.php');
 
-    $attemptid =required_param('attempt', PARAM_INT); // attempt id
-    $questionid =required_param('question', PARAM_INT); // question id
+    $attemptid = required_param('attempt', PARAM_INT); // attempt id
+    $questionid = required_param('question', PARAM_INT); // question id
 
     $attemptobj = new quiz_attempt($attemptid);
 
@@ -46,9 +46,7 @@
     /// If success, notify and print a close button.
         if (!is_string($error)) {
             notify(get_string('changessaved'), 'notifysuccess');
-            close_window_button('closewindow', false, true);
-            print_footer();
-            exit;
+            close_window(2, true);
         }
 
     /// Otherwise, display the error and fall throug to re-display the form.
     }
 
 /// Print the comment form.
-    echo '<form method="post" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
+    echo '<form method="post" class="mform" id="manualgradingform" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
     $attemptobj->question_print_comment_fields($questionid, 'response');
-    echo '<input type="hidden" name="attempt" value="' . $attemptobj->get_uniqueid() . '" />';
-    echo '<input type="hidden" name="question" value="' . $questionid . '" />';
-    echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
-    echo '<input type="submit" name="submit" value="' . get_string('save', 'quiz') . '" />';
+?>
+<div>
+    <input type="hidden" name="attempt" value="<?php echo $attemptobj->get_uniqueid(); ?>" />
+    <input type="hidden" name="question" value="<?php echo $questionid; ?>" />
+    <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
+</div>
+<fieldset class="hidden">
+    <div>
+        <div class="fitem">
+            <div class="fitemtitle">
+                <div class="fgrouplabel"><label> </label></div>
+            </div>
+            <fieldset class="felement fgroup">
+                <input id="id_submitbutton" type="submit" name="submit" value="<?php print_string('save', 'quiz'); ?>"/>
+                <input id="id_cancel" type="button" value="<?php print_string('cancel'); ?>" onclick="close_window"/>
+            </fieldset>
+        </div>
+    </div>
+</fieldset>
+<?php
     echo '</form>';
 
 /// End of the page.
-    print_footer();
+    print_footer('empty');
 ?>
index da9be0362fbb076d94211b8d4d1f693005350615..88932c05a42dfef47a1ed084e8abc1a4a04ec7fd 100644 (file)
@@ -371,7 +371,7 @@ class quiz_grading_report extends quiz_default_report {
 
             // Display the form with one part for each selected attempt
 
-            echo '<form method="post" action="report.php">'.
+            echo '<form method="post" action="report.php" class="mform" id="manualgradingform">'.
                 '<input type="hidden" name="mode" value="grading" />'.
                 '<input type="hidden" name="q" value="'.$quiz->id.'" />'.
                 '<input type="hidden" name="sesskey" value="'.sesskey().'" />'.
@@ -390,10 +390,10 @@ class quiz_grading_report extends quiz_default_report {
                 $options->readonly = 1;
 
                 if (question_state_is_graded($state)) {
-                    $gradedclass = ' class="highlightgraded" ';
+                    $gradedclass = 'main highlightgraded';
                     $gradedstring = ' ' . get_string('graded','quiz_grading');
                 } else {
-                    $gradedclass = '';
+                    $gradedclass = 'main';
                     $gradedstring = '';
                 }
                 $a = new object();
@@ -402,8 +402,7 @@ class quiz_grading_report extends quiz_default_report {
 
                 // print the user name, attempt count, the question, and some more hidden fields
                 echo '<div class="boxaligncenter" width="80%" style="clear:left;padding:15px;">';
-                echo "<span$gradedclass>" . get_string('gradingattempt', 'quiz_grading', $a);
-                echo $gradedstring . '</span>';
+                print_heading(get_string('gradingattempt', 'quiz_grading', $a) . $gradedstring, '', 3, $gradedclass);
 
                 // Print the question, without showing any previous comment.
                 $copy = $state->manualcomment;
@@ -413,8 +412,8 @@ class quiz_grading_report extends quiz_default_report {
 
                 // The print the comment and grade fields, putting back the previous comment.
                 $state->manualcomment = $copy;
-                question_print_comment_fields($question, $state,
-                        'manualgrades[' . $attempt->uniqueid . ']', $quiz);
+                question_print_comment_fields($question, $state, 'manualgrades[' . $attempt->uniqueid . ']',
+                        $quiz, get_string('manualgrading', 'quiz'));
 
                 echo '</div>';
             }
index 811e93d79481b1918cc906abf9c0018a0422080d..86a83d891bd64ad329956111ef3431085576c79b 100644 (file)
@@ -935,7 +935,7 @@ class default_questiontype {
             $strcomment = get_string('commentorgrade', 'quiz');
             $commentlink = link_to_popup_window($options->questioncommentlink .
                     '?attempt=' . $state->attempt . '&amp;question=' . $actualquestionid,
-                    'commentquestion', $strcomment, 450, 650, $strcomment, 'none', true);
+                    'commentquestion', $strcomment, 480, 750, $strcomment, 'none', true);
             $commentlink = '<div class="commentlink">'. $commentlink .'</div>';
         }
 
index 731e6b7754da337f388a2b7dd2e9a12137f6ed71..0f62c356bfb488043314ad4e9f4acc33d3375443 100644 (file)
@@ -2978,7 +2978,16 @@ body.notes .notesgroup {
   margin-top: 10px;
   border-bottom: 1px solid #555;
 }
-
+#mod-quiz-comment #manualgradingform,
+#mod-quiz-report #manualgradingform {
+  width: 100%;
+}
+#mod-quiz-report #manualgradingform .que {
+  margin-bottom: 0.7em;
+}
+.mform .que.comment .fitemtitle {
+  width: 20%;
+}
 /***
  *** Completion progress report
  ***/