Merge branch 'MDL-62620' of git://github.com/stronk7/moodle
authorDavid Monllao <davidm@moodle.com>
Mon, 4 Jun 2018 12:28:15 +0000 (14:28 +0200)
committerDavid Monllao <davidm@moodle.com>
Mon, 4 Jun 2018 12:28:15 +0000 (14:28 +0200)
course/renderer.php
index.php
mod/assign/feedback/editpdf/styles.css
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js
mod/assign/feedback/editpdf/yui/src/editor/js/annotationhighlight.js
mod/assign/feedback/editpdf/yui/src/editor/js/editor.js

index 68767ff..b3cd970 100644 (file)
@@ -2311,6 +2311,208 @@ class core_course_renderer extends plugin_renderer_base {
 
         return $hubdescription;
     }
+
+    /**
+     * Output frontpage summary text and frontpage modules (stored as section 1 in site course)
+     *
+     * This may be disabled in settings
+     *
+     * @return string
+     */
+    public function frontpage_section1() {
+        global $SITE, $USER;
+
+        $output = '';
+        $editing = $this->page->user_is_editing();
+
+        if ($editing) {
+            // Make sure section with number 1 exists.
+            course_create_sections_if_missing($SITE, 1);
+        }
+
+        $modinfo = get_fast_modinfo($SITE);
+        $section = $modinfo->get_section_info(1);
+        if (($section && (!empty($modinfo->sections[1]) or !empty($section->summary))) or $editing) {
+            $output .= $this->box_start('generalbox sitetopic');
+
+            // If currently moving a file then show the current clipboard.
+            if (ismoving($SITE->id)) {
+                $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
+                $output .= '<p><font size="2">';
+                $cancelcopyurl = new moodle_url('/course/mod.php', ['cancelcopy' => 'true', 'sesskey' => sesskey()]);
+                $output .= "$stractivityclipboard&nbsp;&nbsp;(" . html_writer::link($cancelcopyurl, get_string('cancel')) .')';
+                $output .= '</font></p>';
+            }
+
+            $context = context_course::instance(SITEID);
+
+            // If the section name is set we show it.
+            if (trim($section->name) !== '') {
+                $output .= $this->heading(
+                    format_string($section->name, true, array('context' => $context)),
+                    2,
+                    'sectionname'
+                );
+            }
+
+            $summarytext = file_rewrite_pluginfile_urls($section->summary,
+                'pluginfile.php',
+                $context->id,
+                'course',
+                'section',
+                $section->id);
+            $summaryformatoptions = new stdClass();
+            $summaryformatoptions->noclean = true;
+            $summaryformatoptions->overflowdiv = true;
+
+            $output .= format_text($summarytext, $section->summaryformat, $summaryformatoptions);
+
+            if ($editing && has_capability('moodle/course:update', $context)) {
+                $streditsummary = get_string('editsummary');
+                $editsectionurl = new moodle_url('/course/editsection.php', ['id' => $section->id]);
+                $output .= html_writer::link($editsectionurl, $this->pix_icon('t/edit', $streditsummary)) .
+                    "<br /><br />";
+            }
+
+            $output .= $this->course_section_cm_list($SITE, $section);
+
+            $output .= $this->course_section_add_cm_control($SITE, $section->section);
+            $output .= $this->box_end();
+        }
+
+        return $output;
+    }
+
+    /**
+     * Output news for the frontpage (extract from site-wide news forum)
+     *
+     * @param stdClass $newsforum record from db table 'forum' that represents the site news forum
+     * @return string
+     */
+    protected function frontpage_news($newsforum) {
+        global $CFG, $SITE, $SESSION, $USER;
+        require_once($CFG->dirroot .'/mod/forum/lib.php');
+
+        $output = '';
+
+        if (isloggedin()) {
+            $SESSION->fromdiscussion = $CFG->wwwroot;
+            $subtext = '';
+            if (\mod_forum\subscriptions::is_subscribed($USER->id, $newsforum)) {
+                if (!\mod_forum\subscriptions::is_forcesubscribed($newsforum)) {
+                    $subtext = get_string('unsubscribe', 'forum');
+                }
+            } else {
+                $subtext = get_string('subscribe', 'forum');
+            }
+            $suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $newsforum->id, 'sesskey' => sesskey()));
+            $output .= html_writer::tag('div', html_writer::link($suburl, $subtext), array('class' => 'subscribelink'));
+        }
+
+        ob_start();
+        forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
+        $output .= ob_get_contents();
+        ob_end_clean();
+
+        return $output;
+    }
+
+    /**
+     * Renders part of frontpage with a skip link (i.e. "My courses", "Site news", etc.)
+     *
+     * @param string $skipdivid
+     * @param string $contentsdivid
+     * @param string $header Header of the part
+     * @param string $contents Contents of the part
+     * @return string
+     */
+    protected function frontpage_part($skipdivid, $contentsdivid, $header, $contents) {
+        $output = html_writer::link('#' . $skipdivid,
+            get_string('skipa', 'access', core_text::strtolower(strip_tags($header))),
+            array('class' => 'skip-block skip'));
+
+        // Wrap frontpage part in div container.
+        $output .= html_writer::start_tag('div', array('id' => $contentsdivid));
+        $output .= $this->heading($header);
+
+        $output .= $contents;
+
+        // End frontpage part div container.
+        $output .= html_writer::end_tag('div');
+
+        $output .= html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => $skipdivid));
+        return $output;
+    }
+
+    /**
+     * Outputs contents for frontpage as configured in $CFG->frontpage or $CFG->frontpageloggedin
+     *
+     * @return string
+     */
+    public function frontpage() {
+        global $CFG, $SITE;
+
+        $output = '';
+
+        if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
+            $frontpagelayout = $CFG->frontpageloggedin;
+        } else {
+            $frontpagelayout = $CFG->frontpage;
+        }
+
+        foreach (explode(',', $frontpagelayout) as $v) {
+            switch ($v) {
+                // Display the main part of the front page.
+                case FRONTPAGENEWS:
+                    if ($SITE->newsitems) {
+                        // Print forums only when needed.
+                        require_once($CFG->dirroot .'/mod/forum/lib.php');
+                        if (($newsforum = forum_get_course_forum($SITE->id, 'news')) &&
+                                ($forumcontents = $this->frontpage_news($newsforum))) {
+                            $newsforumcm = get_fast_modinfo($SITE)->instances['forum'][$newsforum->id];
+                            $output .= $this->frontpage_part('skipsitenews', 'site-news-forum',
+                                $newsforumcm->get_formatted_name(), $forumcontents);
+                        }
+                    }
+                    break;
+
+                case FRONTPAGEENROLLEDCOURSELIST:
+                    $mycourseshtml = $this->frontpage_my_courses();
+                    if (!empty($mycourseshtml)) {
+                        $output .= $this->frontpage_part('skipmycourses', 'frontpage-course-list',
+                            get_string('mycourses'), $mycourseshtml);
+                        break;
+                    }
+                    // No "break" here. If there are no enrolled courses - continue to 'Available courses'.
+
+                case FRONTPAGEALLCOURSELIST:
+                    $availablecourseshtml = $this->frontpage_available_courses();
+                    if (!empty($availablecourseshtml)) {
+                        $output .= $this->frontpage_part('skipavailablecourses', 'frontpage-available-course-list',
+                            get_string('availablecourses'), $availablecourseshtml);
+                    }
+                    break;
+
+                case FRONTPAGECATEGORYNAMES:
+                    $output .= $this->frontpage_part('skipcategories', 'frontpage-category-names',
+                        get_string('categories'), $this->frontpage_categories_list());
+                    break;
+
+                case FRONTPAGECATEGORYCOMBO:
+                    $output .= $this->frontpage_part('skipcourses', 'frontpage-category-combo',
+                        get_string('courses'), $this->frontpage_combo_list());
+                    break;
+
+                case FRONTPAGECOURSESEARCH:
+                    $output .= $this->box($this->course_search_form('', 'short'), 'mdl-align');
+                    break;
+
+            }
+            $output .= '<br />';
+        }
+
+        return $output;
+    }
 }
 
 /**
index 502093c..01b2b5f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -111,215 +111,27 @@ $PAGE->set_heading($SITE->fullname);
 $courserenderer = $PAGE->get_renderer('core', 'course');
 echo $OUTPUT->header();
 
-// Print Section or custom info.
 $siteformatoptions = course_get_format($SITE)->get_format_options();
 $modinfo = get_fast_modinfo($SITE);
-$modnames = get_module_types_names();
-$modnamesplural = get_module_types_names(true);
 $modnamesused = $modinfo->get_used_module_names();
-$mods = $modinfo->get_cms();
 
+// Print Section or custom info.
 if (!empty($CFG->customfrontpageinclude)) {
+    // Pre-fill some variables that custom front page might use.
+    $modnames = get_module_types_names();
+    $modnamesplural = get_module_types_names(true);
+    $mods = $modinfo->get_cms();
+
     include($CFG->customfrontpageinclude);
 
 } else if ($siteformatoptions['numsections'] > 0) {
-    if ($editing) {
-        // Make sure section with number 1 exists.
-        course_create_sections_if_missing($SITE, 1);
-        // Re-request modinfo in case section was created.
-        $modinfo = get_fast_modinfo($SITE);
-    }
-    $section = $modinfo->get_section_info(1);
-    if (($section && (!empty($modinfo->sections[1]) or !empty($section->summary))) or $editing) {
-        echo $OUTPUT->box_start('generalbox sitetopic');
-
-        // If currently moving a file then show the current clipboard.
-        if (ismoving($SITE->id)) {
-            $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
-            echo '<p><font size="2">';
-            echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true&amp;sesskey=".sesskey()."\">";
-            echo get_string('cancel') . '</a>)';
-            echo '</font></p>';
-        }
-
-        $context = context_course::instance(SITEID);
-
-        // If the section name is set we show it.
-        if (trim($section->name) !== '') {
-            echo $OUTPUT->heading(
-                format_string($section->name, true, array('context' => $context)),
-                2,
-                'sectionname'
-            );
-        }
-
-        $summarytext = file_rewrite_pluginfile_urls($section->summary,
-            'pluginfile.php',
-            $context->id,
-            'course',
-            'section',
-            $section->id);
-        $summaryformatoptions = new stdClass();
-        $summaryformatoptions->noclean = true;
-        $summaryformatoptions->overflowdiv = true;
-
-        echo format_text($summarytext, $section->summaryformat, $summaryformatoptions);
-
-        if ($editing && has_capability('moodle/course:update', $context)) {
-            $streditsummary = get_string('editsummary');
-            echo "<a title=\"$streditsummary\" " .
-                 " href=\"course/editsection.php?id=$section->id\">" . $OUTPUT->pix_icon('t/edit', $streditsummary) .
-                 "</a><br /><br />";
-        }
-
-        $courserenderer = $PAGE->get_renderer('core', 'course');
-        echo $courserenderer->course_section_cm_list($SITE, $section);
-
-        echo $courserenderer->course_section_add_cm_control($SITE, $section->section);
-        echo $OUTPUT->box_end();
-    }
+    echo $courserenderer->frontpage_section1();
 }
 // Include course AJAX.
 include_course_ajax($SITE, $modnamesused);
 
-if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
-    $frontpagelayout = $CFG->frontpageloggedin;
-} else {
-    $frontpagelayout = $CFG->frontpage;
-}
-
-foreach (explode(',', $frontpagelayout) as $v) {
-    switch ($v) {
-        // Display the main part of the front page.
-        case FRONTPAGENEWS:
-            if ($SITE->newsitems) {
-                // Print forums only when needed.
-                require_once($CFG->dirroot .'/mod/forum/lib.php');
-
-                if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
-                    print_error('cannotfindorcreateforum', 'forum');
-                }
-
-                // Fetch news forum context for proper filtering to happen.
-                $newsforumcm = get_coursemodule_from_instance('forum', $newsforum->id, $SITE->id, false, MUST_EXIST);
-                $newsforumcontext = context_module::instance($newsforumcm->id, MUST_EXIST);
-
-                $forumname = format_string($newsforum->name, true, array('context' => $newsforumcontext));
-                echo html_writer::link('#skipsitenews',
-                    get_string('skipa', 'access', core_text::strtolower(strip_tags($forumname))),
-                    array('class' => 'skip-block skip'));
-
-                // Wraps site news forum in div container.
-                echo html_writer::start_tag('div', array('id' => 'site-news-forum'));
-
-                if (isloggedin()) {
-                    $SESSION->fromdiscussion = $CFG->wwwroot;
-                    $subtext = '';
-                    if (\mod_forum\subscriptions::is_subscribed($USER->id, $newsforum)) {
-                        if (!\mod_forum\subscriptions::is_forcesubscribed($newsforum)) {
-                            $subtext = get_string('unsubscribe', 'forum');
-                        }
-                    } else {
-                        $subtext = get_string('subscribe', 'forum');
-                    }
-                    echo $OUTPUT->heading($forumname);
-                    $suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $newsforum->id, 'sesskey' => sesskey()));
-                    echo html_writer::tag('div', html_writer::link($suburl, $subtext), array('class' => 'subscribelink'));
-                } else {
-                    echo $OUTPUT->heading($forumname);
-                }
-
-                forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
-
-                // End site news forum div container.
-                echo html_writer::end_tag('div');
+echo $courserenderer->frontpage();
 
-                echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipsitenews'));
-            }
-        break;
-
-        case FRONTPAGEENROLLEDCOURSELIST:
-            $mycourseshtml = $courserenderer->frontpage_my_courses();
-            if (!empty($mycourseshtml)) {
-                echo html_writer::link('#skipmycourses',
-                    get_string('skipa', 'access', core_text::strtolower(get_string('mycourses'))),
-                    array('class' => 'skip skip-block'));
-
-                // Wrap frontpage course list in div container.
-                echo html_writer::start_tag('div', array('id' => 'frontpage-course-list'));
-
-                echo $OUTPUT->heading(get_string('mycourses'));
-                echo $mycourseshtml;
-
-                // End frontpage course list div container.
-                echo html_writer::end_tag('div');
-
-                echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipmycourses'));
-                break;
-            }
-            // No "break" here. If there are no enrolled courses - continue to 'Available courses'.
-
-        case FRONTPAGEALLCOURSELIST:
-            $availablecourseshtml = $courserenderer->frontpage_available_courses();
-            if (!empty($availablecourseshtml)) {
-                echo html_writer::link('#skipavailablecourses',
-                    get_string('skipa', 'access', core_text::strtolower(get_string('availablecourses'))),
-                    array('class' => 'skip skip-block'));
-
-                // Wrap frontpage course list in div container.
-                echo html_writer::start_tag('div', array('id' => 'frontpage-course-list'));
-
-                echo $OUTPUT->heading(get_string('availablecourses'));
-                echo $availablecourseshtml;
-
-                // End frontpage course list div container.
-                echo html_writer::end_tag('div');
-
-                echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipavailablecourses'));
-            }
-        break;
-
-        case FRONTPAGECATEGORYNAMES:
-            echo html_writer::link('#skipcategories',
-                get_string('skipa', 'access', core_text::strtolower(get_string('categories'))),
-                array('class' => 'skip skip-block'));
-
-            // Wrap frontpage category names in div container.
-            echo html_writer::start_tag('div', array('id' => 'frontpage-category-names'));
-
-            echo $OUTPUT->heading(get_string('categories'));
-            echo $courserenderer->frontpage_categories_list();
-
-            // End frontpage category names div container.
-            echo html_writer::end_tag('div');
-
-            echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipcategories'));
-        break;
-
-        case FRONTPAGECATEGORYCOMBO:
-            echo html_writer::link('#skipcourses',
-                get_string('skipa', 'access', core_text::strtolower(get_string('courses'))),
-                array('class' => 'skip skip-block'));
-
-            // Wrap frontpage category combo in div container.
-            echo html_writer::start_tag('div', array('id' => 'frontpage-category-combo'));
-
-            echo $OUTPUT->heading(get_string('courses'));
-            echo $courserenderer->frontpage_combo_list();
-
-            // End frontpage category combo div container.
-            echo html_writer::end_tag('div');
-
-            echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipcourses'));
-        break;
-
-        case FRONTPAGECOURSESEARCH:
-            echo $OUTPUT->box($courserenderer->course_search_form('', 'short'), 'mdl-align');
-        break;
-
-    }
-    echo '<br />';
-}
 if ($editing && has_capability('moodle/course:create', context_system::instance())) {
     echo $courserenderer->add_new_course_button();
 }
index 52e7536..b23aa66 100644 (file)
@@ -10,7 +10,6 @@
     position: relative;
     min-width: 817px;
     min-height: 400px;
-    cursor: crosshair;
     background-repeat: no-repeat;
     background-color: #ccc;
     margin-left: auto;
     position: inherit;
 }
 
-.assignfeedback_editpdf_widget .drawingregion[data-currenttool=drag] .drawingcanvas {
-    cursor: move;
-}
-
-.assignfeedback_editpdf_widget .drawingregion[data-currenttool=select] .drawingcanvas {
-    cursor: default;
-}
-
 .assignfeedback_editpdf_widget .drawingregion[data-currenttool=select] .commentdrawable textarea,
 .assignfeedback_editpdf_widget .drawingregion[data-currenttool=select] .commentdrawable svg {
     cursor: move;
index 5f704e2..dc22ae1 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js differ
index b3620af..827e3d2 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js differ
index 5f704e2..dc22ae1 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js differ
index 20c5c10..6ba0d9b 100644 (file)
@@ -110,13 +110,13 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
         shape = this.editor.graphic.addShape({
             type: Y.Rect,
             width: bounds.width,
-            height: 16,
+            height: 20,
             stroke: false,
             fill: {
                color: highlightcolour
             },
             x: bounds.x,
-            y: edit.start.y
+            y: edit.start.y - 10
         });
 
         drawable.shapes.push(shape);
@@ -139,9 +139,9 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
         this.gradeid = this.editor.get('gradeid');
         this.pageno = this.editor.currentpage;
         this.x = bounds.x;
-        this.y = edit.start.y;
+        this.y = edit.start.y - 10;
         this.endx = bounds.x + bounds.width;
-        this.endy = edit.start.y + 16;
+        this.endy = edit.start.y + 10;
         this.colour = edit.annotationcolour;
         this.page = '';
 
index 6f94adc..4320b85 100644 (file)
@@ -266,7 +266,7 @@ EDITOR.prototype = {
      * @method refresh_button_state
      */
     refresh_button_state: function() {
-        var button, currenttoolnode, imgurl, drawingregion;
+        var button, currenttoolnode, imgurl, drawingregion, stampimgurl, drawingcanvas;
 
         // Initalise the colour buttons.
         button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON);
@@ -291,9 +291,28 @@ EDITOR.prototype = {
         drawingregion.setAttribute('data-currenttool', this.currentedit.tool);
 
         button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON);
-        button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp),
+        stampimgurl = this.get_stamp_image_url(this.currentedit.stamp);
+        button.one('img').setAttrs({'src': stampimgurl,
                                     'height': '16',
                                     'width': '16'});
+
+        drawingcanvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS);
+        switch (this.currentedit.tool) {
+            case 'drag':
+                drawingcanvas.setStyle('cursor', 'move');
+                break;
+            case 'highlight':
+                drawingcanvas.setStyle('cursor', 'text');
+                break;
+            case 'select':
+                drawingcanvas.setStyle('cursor', 'default');
+                break;
+            case 'stamp':
+                drawingcanvas.setStyle('cursor', 'url(' + stampimgurl + '), crosshair');
+                break;
+            default:
+                drawingcanvas.setStyle('cursor', 'crosshair');
+        }
     },
 
     /**