]> git.mjollnir.org Git - moodle.git/commitdiff
[BugFix] Bug #4852 - HTML editor problems
authormichaelpenne <michaelpenne>
Sat, 11 Mar 2006 00:23:21 +0000 (00:23 +0000)
committermichaelpenne <michaelpenne>
Sat, 11 Mar 2006 00:23:21 +0000 (00:23 +0000)
mod/lesson/action/editpage.php
mod/lesson/action/updatepage.php

index c43dfa79a5136377ad6e34f13fa7f97ff1b7410d..3bb6d345621b9e75ad3d0b965726aca68cf925af 100644 (file)
                 case LESSON_SHORTANSWER:
                 case LESSON_NUMERICAL:                    
                     echo "<tr><td><b>".get_string("answer", "lesson")." $nplus1:</b>\n";
-                    if ($flags & LESSON_ANSWER_EDITOR) {
+                    if ($flags & LESSON_ANSWER_EDITOR and $page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
                         echo " [".get_string("useeditor", "lesson").": ".
                             "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" 
                             checked=\"checked\">";
                         print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
                         use_html_editor("answer[$n]"); // switch on the editor
                     } else {
-                        echo " [".get_string("useeditor", "lesson").": ".
-                            "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">";
-                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
-                        echo "]<br />\n";
-                        print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
+                        if ($page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
+                            echo " [".get_string("useeditor", "lesson").": ".
+                                "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label.
+                            helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
+                            echo "]<br />\n";
+                            print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
+                        } else {
+                            echo "<br />\n";
+                            print_textarea(false, 1, 70, 630, 300, "answer[$n]", $answer->answer);
+                        }
                     }
                     echo "</td></tr>\n";
                     echo "<tr><td><b>".get_string("response", "lesson")." $nplus1:</b>\n";
                 case LESSON_SHORTANSWER:
                 case LESSON_NUMERICAL:
                     echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b>\n";
-                    echo " [".get_string("useeditor", "lesson").": ".
-                        "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
-                    helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
-                    echo "]<br />\n";
-                    print_textarea(false, 10, 70, 630, 300, "answer[$i]");
+                    if ($page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
+                        echo " [".get_string("useeditor", "lesson").": ".
+                            "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
+                        helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
+                        echo "]<br />\n";
+                        print_textarea(false, 10, 70, 630, 300, "answer[$i]");
+                    } else {
+                        echo "<br />\n";
+                        print_textarea(false, 1, 70, 630, 300, "answer[$i]");
+                    }
                     echo "</td></tr>\n";
                     echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b>\n";
                     echo " [".get_string("useeditor", "lesson").": ".
index 5c4ae457dc655feada84c7c0e5f0b4c2b4027856..67759217fd33900b7221437f627805611e0d49b9 100644 (file)
                 if ($form->answerid[$i]) {
                     $oldanswer = new stdClass;
                     $oldanswer->id = clean_param($form->answerid[$i], PARAM_INT);
-                    $oldanswer->flags = optional_param("answereditor[$i]", 0, PARAM_INT) * LESSON_ANSWER_EDITOR +
-                        optional_param("responseeditor[$i]", 0, PARAM_INT) * LESSON_RESPONSE_EDITOR;
+                    if (!isset($form->answereditor[$i])) {
+                        $form->answereditor[$i] = 0;
+                    }
+                    if (!isset($form->responseeditor[$i])) {
+                        $form->responseeditor[$i] = 0;
+                    }
+                    $oldanswer->flags = $form->answereditor[$i] * LESSON_ANSWER_EDITOR +
+                                        $form->responseeditor[$i] * LESSON_RESPONSE_EDITOR;
                     $oldanswer->timemodified = $timenow;
                     $oldanswer->answer = trim($form->answer[$i]);
                     if (isset($form->response[$i])) {
                     $newanswer = new stdClass; // need to clear id if more than one new answer is ben added
                     $newanswer->lessonid = $lesson->id;
                     $newanswer->pageid = $page->id;
-                    $newanswer->flags = optional_param("answereditor[$i]", 0, PARAM_INT) * LESSON_ANSWER_EDITOR +
-                        optional_param("responseeditor[$i]", 0, PARAM_INT) * LESSON_RESPONSE_EDITOR;
+                    if (!isset($form->answereditor[$i])) {
+                        $form->answereditor[$i] = 0;
+                    }
+                    if (!isset($form->responseeditor[$i])) {
+                        $form->responseeditor[$i] = 0;
+                    }
+                    $newanswer->flags = $form->answereditor[$i] * LESSON_ANSWER_EDITOR +
+                                        $form->responseeditor[$i] * LESSON_RESPONSE_EDITOR;
                     $newanswer->timecreated = $timenow;
                     $newanswer->answer = trim($form->answer[$i]);
                     if (isset($form->response[$i])) {
                     } else {
                         $oldanswer = new stdClass;
                         $oldanswer->id = clean_param($form->answerid[$i], PARAM_INT);
-                        $oldanswer->flags = optional_param("answereditor[$i]", 0, PARAM_INT) * LESSON_ANSWER_EDITOR +
-                        optional_param("responseeditor[$i]", 0, PARAM_INT) * LESSON_RESPONSE_EDITOR;
+                        if (!isset($form->answereditor[$i])) {
+                            $form->answereditor[$i] = 0;
+                        }
+                        if (!isset($form->responseeditor[$i])) {
+                            $form->responseeditor[$i] = 0;
+                        }                        
+                        $oldanswer->flags = $form->answereditor[$i] * LESSON_ANSWER_EDITOR +
+                                            $form->responseeditor[$i] * LESSON_RESPONSE_EDITOR;
                         $oldanswer->timemodified = $timenow;
                         $oldanswer->answer = NULL;
                         if (!update_record("lesson_answers", $oldanswer)) {