Exemple #1
0
    /**
     * Returns html to display the content of mod_folder
     * (Description, folder files and optionally Edit button)
     *
     * @param stdClass $folder record from 'folder' table (please note
     *     it may not contain fields 'revision' and 'timemodified')
     * @return string
     */
    public function display_folder(stdClass $folder) {
        $output = '';
        $folderinstances = get_fast_modinfo($folder->course)->get_instances_of('folder');
        if (!isset($folderinstances[$folder->id]) ||
                !($cm = $folderinstances[$folder->id]) ||
                !$cm->uservisible ||
                !($context = context_module::instance($cm->id)) ||
                !has_capability('mod/folder:view', $context)) {
            // some error in parameters or module is not visible to the user
            // don't throw any errors in renderer, just return empty string
            return $output;
        }

        if (trim($folder->intro)) {
            if ($folder->display != FOLDER_DISPLAY_INLINE) {
                $output .= $this->output->box(format_module_intro('folder', $folder, $cm->id),
                        'generalbox', 'intro');
            } else if ($cm->showdescription) {
                // for "display inline" do not filter, filters run at display time.
                $output .= format_module_intro('folder', $folder, $cm->id, false);
            }
        }

        $output .= $this->output->box($this->render(new folder_tree($folder, $cm)),
                'generalbox foldertree');

        // Do not append the edit button on the course page.
        if ($folder->display != FOLDER_DISPLAY_INLINE && has_capability('mod/folder:managefiles', $context)) {
            $output .= $this->output->container(
                    $this->output->single_button(new moodle_url('/mod/folder/edit.php',
                    array('id' => $cm->id)), get_string('edit')),
                    'mdl-align folder-edit-button');
        }
        return $output;
    }
 /**
  * Get media html for resource.
  *
  * @param $resource
  * @param $context
  * @param \cm_info $cm
  * @return string
  */
 private function get_media_html($resource, $context, \cm_info $cm)
 {
     global $OUTPUT, $PAGE;
     $fs = get_file_storage();
     $files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false);
     if (count($files) < 1) {
         $content = $OUTPUT->notification(get_string('filenotfound', 'resource'));
     } else {
         $file = reset($files);
         unset($files);
         $mediarenderer = $PAGE->get_renderer('core', 'media');
         $embedoptions = array(\core_media::OPTION_TRUSTED => true, \core_media::OPTION_BLOCK => true);
         $path = '/' . $context->id . '/mod_resource/content/' . $resource->revision . $file->get_filepath() . $file->get_filename();
         $moodleurl = new \moodle_url('/pluginfile.php' . $path);
         $embedhtml = $mediarenderer->embed_url($moodleurl, $resource->name, 0, 0, $embedoptions);
         // Modal title.
         $content = "<h5 class='snap-lightbox-title'>" . format_string($resource->name) . "</h5>";
         // Grid me up.
         if (!empty($resource->intro)) {
             $lightboxgrid = "<div class='col-sm-8'>{$embedhtml}</div>";
             $lightboxgrid .= "<div class='col-sm-4 snap-lightbox-description'>" . format_module_intro('resource', $resource, $cm->id) . "</div>";
         } else {
             $lightboxgrid = "<div class='col-sm-12'>{$embedhtml}</div>";
         }
         $content .= "<div class='row'>{$lightboxgrid}</div>";
     }
     return $content;
 }
Exemple #3
0
function outputIntro($url, $course, $cm, $resop)
{
    global $PAGE, $OUTPUT;
    // Print the page header.
    $PAGE->set_url($url);
    /*assign module does set_url here and the rest in own class ?
     * we try it first without own class and traditional output
     * */
    $PAGE->set_title(format_string($resop->name));
    $PAGE->set_heading(format_string($course->fullname));
    /*
     * Other things you may want to set - remove if not needed.
     * $PAGE->set_cacheable(false);
     * $PAGE->set_focuscontrol('some-html-id');
     * $PAGE->add_body_class('resop-'.$somevar);
     */
    // Output starts here.
    echo $OUTPUT->header();
    // Conditions to show the intro can change to look for own settings or whatever.
    if ($resop->intro) {
        echo $OUTPUT->box(format_module_intro('resop', $resop, $cm->id), 'generalbox mod_introbox', 'resopintro');
    }
    // Replace the following lines with you own code.
    //wahrscheinlich sollte ich hier einen renderer einsetzen, aber die Thematik ist mir im moment
    //zu komplex
    //echo $OUTPUT->heading(get_string('modulename','resop'));
    echo $OUTPUT->box_start();
    //show some links if no action is set
    //var_dump($urlparams);
}
 /**
  * Render the header.
  *
  * @param ratingallocate_header $header
  * @return string
  */
 public function render_ratingallocate_header(ratingallocate_header $header)
 {
     $o = '';
     $this->page->set_heading($this->page->course->fullname);
     $this->page->requires->css('/mod/ratingallocate/styles.css');
     $o .= $this->output->header();
     $heading = format_string($header->ratingallocate->name, false, array('context' => $header->context));
     $o .= $this->output->heading($heading);
     if ($header->showintro) {
         $intro_text = format_module_intro('ratingallocate', $header->ratingallocate, $header->coursemoduleid);
         if ($intro_text) {
             $o .= $this->output->box_start('generalbox boxaligncenter', 'intro');
             $o .= $intro_text;
             $o .= $this->output->box_end();
         }
     }
     //$o .= $this->notifications;
     if (!empty($this->notifications)) {
         $o .= $this->output->box_start('box generalbox boxaligncenter');
         foreach ($this->notifications as $elem) {
             $o .= html_writer::div(format_text($elem));
         }
         $o .= $this->output->box_end();
     }
     return $o;
 }
Exemple #5
0
 /**
  * Returns html to display the content of mod_folder
  * (Description, folder files and optionally Edit button)
  *
  * @param stdClass $folder record from 'folder' table (please note
  *     it may not contain fields 'revision' and 'timemodified')
  * @return string
  */
 public function display_folder(stdClass $folder)
 {
     $output = '';
     $folderinstances = get_fast_modinfo($folder->course)->get_instances_of('folder');
     if (!isset($folderinstances[$folder->id]) || !($cm = $folderinstances[$folder->id]) || !($context = context_module::instance($cm->id))) {
         // Some error in parameters.
         // Don't throw any errors in renderer, just return empty string.
         // Capability to view module must be checked before calling renderer.
         return $output;
     }
     if (trim($folder->intro)) {
         if ($folder->display != FOLDER_DISPLAY_INLINE) {
             $output .= $this->output->box(format_module_intro('folder', $folder, $cm->id), 'generalbox', 'intro');
         } else {
             if ($cm->showdescription) {
                 // for "display inline" do not filter, filters run at display time.
                 $output .= format_module_intro('folder', $folder, $cm->id, false);
             }
         }
     }
     $foldertree = new folder_tree($folder, $cm);
     if ($folder->display == FOLDER_DISPLAY_INLINE) {
         // Display module name as the name of the root directory.
         $foldertree->dir['dirname'] = $cm->get_formatted_name();
     }
     $output .= $this->output->box($this->render($foldertree), 'generalbox foldertree');
     // Do not append the edit button on the course page.
     if ($folder->display != FOLDER_DISPLAY_INLINE && has_capability('mod/folder:managefiles', $context)) {
         $output .= $this->output->container($this->output->single_button(new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)), get_string('edit')), 'mdl-align folder-edit-button');
     }
     return $output;
 }
 /**
  * Renders the videofile page header.
  *
  * @param videofile videofile
  * @return string
  */
 public function video_header($videofile)
 {
     global $CFG;
     $output = '';
     $name = format_string($videofile->get_instance()->name, true, $videofile->get_course());
     $title = $this->page->course->shortname . ': ' . $name;
     $coursemoduleid = $videofile->get_course_module()->id;
     $context = context_module::instance($coursemoduleid);
     // Add videojs css and js files.
     $this->page->requires->css('/mod/videofile/video-js-4.6.3/video-js.min.css');
     $this->page->requires->js('/mod/videofile/video-js-4.6.3/video.js', true);
     // Set the videojs flash fallback url.
     $swfurl = new moodle_url('/mod/videofile/video-js-4.6.3/video-js.swf');
     $this->page->requires->js_init_code('videojs.options.flash.swf = "' . $swfurl . '";');
     // Yui module handles responsive mode video resizing.
     if ($videofile->get_instance()->responsive) {
         $config = get_config('videofile');
         $this->page->requires->yui_module('moodle-mod_videofile-videojs', 'M.mod_videofile.videojs.init', array($videofile->get_instance()->id, $swfurl, $videofile->get_instance()->width, $videofile->get_instance()->height, (bool) $config->limitdimensions));
     }
     // Header setup.
     $this->page->set_title($title);
     $this->page->set_heading($this->page->course->fullname);
     $output .= $this->output->header();
     $output .= $this->output->heading($name, 3);
     if (!empty($videofile->get_instance()->intro)) {
         $output .= $this->output->box_start('generalbox boxaligncenter', 'intro');
         $output .= format_module_intro('videofile', $videofile->get_instance(), $coursemoduleid);
         $output .= $this->output->box_end();
     }
     return $output;
 }
 /**
  *
  */
 public static function update_event_timedue($data)
 {
     global $DB;
     if (!empty($data->timedue)) {
         $event = new \stdClass();
         $event->name = $data->name;
         $event->description = format_module_intro('dataform', $data, $data->coursemodule);
         $event->timestart = $data->timedue;
         if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'dataform', 'instance' => $data->id))) {
             $calendarevent = \calendar_event::load($event->id);
             $calendarevent->update($event);
         } else {
             $event->courseid = $data->course;
             $event->groupid = 0;
             $event->userid = 0;
             $event->modulename = 'dataform';
             $event->instance = $data->id;
             $event->eventtype = 'due';
             $event->timeduration = 0;
             $event->visible = $DB->get_field('course_modules', 'visible', array('module' => $data->module, 'instance' => $data->id));
             \calendar_event::create($event);
         }
     } else {
         $DB->delete_records('event', array('modulename' => 'dataform', 'instance' => $data->id, 'eventtype' => 'due'));
     }
 }
 /**
  * Return introduction
  */
 public function introduction()
 {
     $output = '';
     if (trim($this->hotquestion->instance->intro)) {
         $output .= $this->box_start('generalbox boxaligncenter', 'intro');
         $output .= format_module_intro('hotquestion', $this->hotquestion->instance, $this->hotquestion->cm->id);
         $output .= $this->box_end();
     }
     return $output;
 }
function easycastms_print_intro($easycastms_media, $cm, $course, $ignoresettings = false)
{
    global $OUTPUT;
    if (!$ignoresettings) {
        if (trim(strip_tags($easycastms_media->intro))) {
            echo $OUTPUT->box_start('mod_introbox', 'easycastmsintro');
            echo format_module_intro('easycastms', $easycastms_media, $cm->id);
            echo $OUTPUT->box_end();
        }
    }
}
Exemple #10
0
/**
 * Given a course_module object, this function returns any
 * "extra" information that may be needed when printing
 * this activity in a course listing.
 * See get_array_of_activities() in course/lib.php
 */
function label_get_coursemodule_info($coursemodule)
{
    global $DB;
    if ($label = $DB->get_record('label', array('id' => $coursemodule->instance), 'id, name, intro, introformat')) {
        if (empty($label->name)) {
            // label name missing, fix it
            $label->name = "label{$label->id}";
            $DB->set_field('label', 'name', $label->name, array('id' => $label->id));
        }
        $info = new object();
        // no filtering hre because this info is cached and filtered later
        $info->extra = urlencode(format_module_intro('label', $label, $coursemodule->id, false));
        $info->name = urlencode($label->name);
        return $info;
    } else {
        return null;
    }
}
 /**
  * @param $course
  * @param $cm
  * @param $forum
  * @param context_module $context
  * @author Mark Nielsen
  */
 public function view($course, $cm, $forum, context_module $context)
 {
     global $USER, $DB, $OUTPUT;
     require_once __DIR__ . '/lib/discussion/sort.php';
     $config = get_config('hsuforum');
     $mode = optional_param('mode', 0, PARAM_INT);
     // Display mode (for single forum)
     $page = optional_param('page', 0, PARAM_INT);
     // which page to show
     $forumicon = "<img src='" . $OUTPUT->pix_url('icon', 'hsuforum') . "' alt='' class='iconlarge activityicon'/> ";
     echo '<div id="hsuforum-header"><h2>' . $forumicon . format_string($forum->name) . '</h2>';
     if (!empty($forum->intro)) {
         echo '<div class="hsuforum_introduction">' . format_module_intro('hsuforum', $forum, $cm->id) . '</div>';
     }
     echo "</div>";
     // Update activity group mode changes here.
     groups_get_activity_group($cm, true);
     $dsort = hsuforum_lib_discussion_sort::get_from_session($forum, $context);
     $dsort->set_key(optional_param('dsortkey', $dsort->get_key(), PARAM_ALPHA));
     hsuforum_lib_discussion_sort::set_to_session($dsort);
     if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
         $a = new stdClass();
         $a->blockafter = $forum->blockafter;
         $a->blockperiod = get_string('secondstotime' . $forum->blockperiod);
         echo $OUTPUT->notification(get_string('thisforumisthrottled', 'hsuforum', $a));
     }
     if ($forum->type == 'qanda' && !has_capability('moodle/course:manageactivities', $context)) {
         echo $OUTPUT->notification(get_string('qandanotify', 'hsuforum'));
     }
     switch ($forum->type) {
         case 'eachuser':
             if (hsuforum_user_can_post_discussion($forum, null, -1, $cm)) {
                 echo '<p class="mdl-align">';
                 print_string("allowsdiscussions", "hsuforum");
                 echo '</p>';
             }
             // Fall through to following cases.
         // Fall through to following cases.
         case 'blog':
         default:
             hsuforum_print_latest_discussions($course, $forum, -1, $dsort->get_sort_sql(), -1, -1, $page, $config->manydiscussions, $cm);
             break;
     }
 }
 function view_intro()
 {
     global $CFG, $USER, $OUTPUT, $DB;
     echo $OUTPUT->box_start('generalbox boxaligncenter', 'intro');
     echo format_module_intro('assignment', $this->assignment, $this->cm->id);
     if ($this->import_checklist_plugin()) {
         $extra = $DB->get_record('assignment_uploadpdf', array('assignment' => $this->assignment->id));
         if ($extra->checklist) {
             $checklist = $DB->get_record('checklist', array('id' => $extra->checklist));
             if ($checklist) {
                 $chklink = $CFG->wwwroot . '/mod/checklist/view.php?checklist=' . $checklist->id;
                 echo '<div><a href="' . $chklink . '" target="_blank"><div style="float: left; dispaly: inline; margin-left: 40px; margin-right: 20px;">' . $checklist->name . ': </div>';
                 checklist_class::print_user_progressbar($checklist->id, $USER->id);
                 echo '</a></div>';
             }
         }
     }
     echo $OUTPUT->box_end();
 }
Exemple #13
0
 /**
  * Display the interview, used by view.php
  *
  * This in turn calls the methods producing individual parts of the page
  */
 function view_intro($interview, $cm)
 {
     global $OUTPUT;
     echo $OUTPUT->box_start('generalbox boxaligncenter', 'intro');
     echo format_module_intro('interview', $interview, $cm->id);
     // If a place or professor has been established it's shown in another box
     if ($interview->location or $interview->teacher) {
         if (!empty($interview->location)) {
             echo '<b>';
             echo get_string('location', 'interview');
             echo '</b>';
             echo ': ' . $interview->location;
         }
         if (!empty($interview->teacher)) {
             echo '<br/>';
             echo '<b>';
             echo get_string('teacher', 'interview');
             echo '</b>';
             echo ': ' . $interview->teacher;
         }
     }
     echo $OUTPUT->box_end();
 }
Exemple #14
0
        echo get_string('feedbackclose', 'feedback').': ';
        echo '</span>';
        echo '<span class="feedback_info_value">';
        echo userdate($feedback->timeclose);
        echo '</span>';
        echo $OUTPUT->box_end();
    }
    echo $OUTPUT->box_end();
}

if (has_capability('mod/feedback:edititems', $context)) {
    echo $OUTPUT->heading(get_string('description', 'feedback'), 4);
}
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
$options = (object)array('noclean'=>true);
echo format_module_intro('feedback', $feedback, $cm->id);
echo $OUTPUT->box_end();

if (has_capability('mod/feedback:edititems', $context)) {
    require_once($CFG->libdir . '/filelib.php');

    $page_after_submit_output = file_rewrite_pluginfile_urls($feedback->page_after_submit,
                                                            'pluginfile.php',
                                                            $context->id,
                                                            'mod_feedback',
                                                            'page_after_submit',
                                                            0);

    echo $OUTPUT->heading(get_string("page_after_submit", "feedback"), 4);
    echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
    echo format_text($page_after_submit_output,
Exemple #15
0
        case 'blog':
            if (!empty($forum->intro)) {
                echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
            }
            echo '<br />';
            if (!empty($showall)) {
                forum_print_latest_discussions($course, $forum, 0, 'plain', '', -1, -1, -1, 0, $cm);
            } else {
                forum_print_latest_discussions($course, $forum, -1, 'plain', '', -1, -1, $page, $CFG->forum_manydiscussions, $cm);
            }
            break;

        default:
            if (!empty($forum->intro)) {
                echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
            }
            echo '<br />';
            if (!empty($showall)) {
                forum_print_latest_discussions($course, $forum, 0, 'header', '', -1, -1, -1, 0, $cm);
            } else {
                forum_print_latest_discussions($course, $forum, -1, 'header', '', -1, -1, $page, $CFG->forum_manydiscussions, $cm);
            }


            break;
    }

    echo $OUTPUT->footer($course);

Exemple #16
0
    /**
     * Updates a new assignment activity
     *
     * Given an object containing all the necessary data,
     * (defined by the form in mod_form.php) this function
     * will update the assignment instance and return the id number
     * The due date is updated in the calendar
     * This is common to all assignment types.
     *
     * @global object
     * @global object
     * @param object $assignment The data from the form on mod_form.php
     * @return bool success
     */
    function update_instance($assignment) {
        global $COURSE, $DB;

        $assignment->timemodified = time();

        $assignment->id = $assignment->instance;
        $assignment->courseid = $assignment->course;

        $DB->update_record('assignment', $assignment);

        if ($assignment->timedue) {
            $event = new stdClass();

            if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {

                $event->name        = $assignment->name;
                $event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
                $event->timestart   = $assignment->timedue;

                $calendarevent = calendar_event::load($event->id);
                $calendarevent->update($event);
            } else {
                $event = new stdClass();
                $event->name        = $assignment->name;
                $event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
                $event->courseid    = $assignment->course;
                $event->groupid     = 0;
                $event->userid      = 0;
                $event->modulename  = 'assignment';
                $event->instance    = $assignment->id;
                $event->eventtype   = 'due';
                $event->timestart   = $assignment->timedue;
                $event->timeduration = 0;

                calendar_event::create($event);
            }
        } else {
            $DB->delete_records('event', array('modulename'=>'assignment', 'instance'=>$assignment->id));
        }

        // get existing grade item
        assignment_grade_item_update($assignment);

        return true;
    }
Exemple #17
0
/**
 * Print url introduction.
 * @param object $url
 * @param object $cm
 * @param object $course
 * @param bool $ignoresettings print even if not specified in modedit
 * @return void
 */
function url_print_intro($url, $cm, $course, $ignoresettings = false)
{
    global $OUTPUT;
    $options = empty($url->displayoptions) ? array() : unserialize($url->displayoptions);
    if ($ignoresettings or !empty($options['printintro'])) {
        if (trim(strip_tags($url->intro))) {
            echo $OUTPUT->box_start('mod_introbox', 'urlintro');
            echo format_module_intro('url', $url, $cm->id);
            echo $OUTPUT->box_end();
        }
    }
}
Exemple #18
0
/**
 * Given a coursemodule object, this function returns the extra
 * information needed to print this activity in various places.
 * For this module we just need to support external urls as
 * activity icons
 *
 * @param stdClass $coursemodule
 * @return cached_cm_info info
 */
function lti_get_coursemodule_info($coursemodule)
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/mod/lti/locallib.php';
    if (!($lti = $DB->get_record('lti', array('id' => $coursemodule->instance), 'icon, secureicon, intro, introformat, name, typeid, toolurl, launchcontainer'))) {
        return null;
    }
    $info = new cached_cm_info();
    if ($coursemodule->showdescription) {
        // Convert intro to html. Do not filter cached version, filters run at display time.
        $info->content = format_module_intro('lti', $lti, $coursemodule->id, false);
    }
    if (!empty($lti->typeid)) {
        $toolconfig = lti_get_type_config($lti->typeid);
    } else {
        if ($tool = lti_get_tool_by_url_match($lti->toolurl)) {
            $toolconfig = lti_get_type_config($tool->id);
        } else {
            $toolconfig = array();
        }
    }
    // We want to use the right icon based on whether the
    // current page is being requested over http or https.
    if (lti_request_is_using_ssl() && (!empty($lti->secureicon) || isset($toolconfig['secureicon']) && !empty($toolconfig['secureicon']))) {
        if (!empty($lti->secureicon)) {
            $info->iconurl = new moodle_url($lti->secureicon);
        } else {
            $info->iconurl = new moodle_url($toolconfig['secureicon']);
        }
    } else {
        if (!empty($lti->icon)) {
            $info->iconurl = new moodle_url($lti->icon);
        } else {
            if (isset($toolconfig['icon']) && !empty($toolconfig['icon'])) {
                $info->iconurl = new moodle_url($toolconfig['icon']);
            }
        }
    }
    // Does the link open in a new window?
    $launchcontainer = lti_get_launch_container($lti, $toolconfig);
    if ($launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW) {
        $launchurl = new moodle_url('/mod/lti/launch.php', array('id' => $coursemodule->id));
        $info->onclick = "window.open('" . $launchurl->out(false) . "', 'lti'); return false;";
    }
    $info->name = $lti->name;
    return $info;
}
Exemple #19
0
    /**
     * Output the quiz intro.
     * @param object $quiz the quiz settings.
     * @param object $cm the course_module object.
     * @return string HTML to output.
     */
    public function quiz_intro($quiz, $cm) {
        if (trim(strip_tags($quiz->intro))) {
            return $this->box(format_module_intro('quiz', $quiz, $cm->id),
                    'generalbox', 'intro');

        } else {
            return '';
        }
    }
Exemple #20
0
/**
 * This creates new events given as timeopen and closeopen by $feedback.
 *
 * @global object
 * @param object $feedback
 * @return void
 */
function feedback_set_events($feedback) {
    global $DB;

    // adding the feedback to the eventtable (I have seen this at quiz-module)
    $DB->delete_records('event', array('modulename'=>'feedback', 'instance'=>$feedback->id));

    if (!isset($feedback->coursemodule)) {
        $cm = get_coursemodule_from_id('feedback', $feedback->id);
        $feedback->coursemodule = $cm->id;
    }

    // the open-event
    if ($feedback->timeopen > 0) {
        $event = new stdClass();
        $event->name         = get_string('start', 'feedback').' '.$feedback->name;
        $event->description  = format_module_intro('feedback', $feedback, $feedback->coursemodule);
        $event->courseid     = $feedback->course;
        $event->groupid      = 0;
        $event->userid       = 0;
        $event->modulename   = 'feedback';
        $event->instance     = $feedback->id;
        $event->eventtype    = 'open';
        $event->timestart    = $feedback->timeopen;
        $event->visible      = instance_is_visible('feedback', $feedback);
        if ($feedback->timeclose > 0) {
            $event->timeduration = ($feedback->timeclose - $feedback->timeopen);
        } else {
            $event->timeduration = 0;
        }

        calendar_event::create($event);
    }

    // the close-event
    if ($feedback->timeclose > 0) {
        $event = new stdClass();
        $event->name         = get_string('stop', 'feedback').' '.$feedback->name;
        $event->description  = format_module_intro('feedback', $feedback, $feedback->coursemodule);
        $event->courseid     = $feedback->course;
        $event->groupid      = 0;
        $event->userid       = 0;
        $event->modulename   = 'feedback';
        $event->instance     = $feedback->id;
        $event->eventtype    = 'close';
        $event->timestart    = $feedback->timeclose;
        $event->visible      = instance_is_visible('feedback', $feedback);
        $event->timeduration = 0;

        calendar_event::create($event);
    }
}
Exemple #21
0
 /**
  * Update the calendar entries for this assignment.
  *
  * @param int $coursemoduleid - Required to pass this in because it might
  *                              not exist in the database yet.
  * @return bool
  */
 public function update_calendar($coursemoduleid)
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/calendar/lib.php';
     // Special case for add_instance as the coursemodule has not been set yet.
     $instance = $this->get_instance();
     if ($instance->duedate) {
         $event = new stdClass();
         $params = array('modulename' => 'assign', 'instance' => $instance->id);
         $event->id = $DB->get_field('event', 'id', $params);
         if ($event->id) {
             $event->name = $instance->name;
             $event->description = format_module_intro('assign', $instance, $coursemoduleid);
             $event->timestart = $instance->duedate;
             $calendarevent = calendar_event::load($event->id);
             $calendarevent->update($event);
         } else {
             $event = new stdClass();
             $event->name = $instance->name;
             $event->description = format_module_intro('assign', $instance, $coursemoduleid);
             $event->courseid = $instance->course;
             $event->groupid = 0;
             $event->userid = 0;
             $event->modulename = 'assign';
             $event->instance = $instance->id;
             $event->eventtype = 'due';
             $event->timestart = $instance->duedate;
             $event->timeduration = 0;
             calendar_event::create($event);
         }
     } else {
         $DB->delete_records('event', array('modulename' => 'assign', 'instance' => $instance->id));
     }
 }
Exemple #22
0
/**
 * This standard function will check all instances of this module
 * and make sure there are up-to-date events created for each of them.
 * If courseid = 0, then every chat event in the site is checked, else
 * only chat events belonging to the course specified are checked.
 * This function is used, in its new format, by restore_refresh_events()
 *
 * @global object
 * @param int $courseid
 * @return bool
 */
function chat_refresh_events($courseid = 0)
{
    global $DB;
    if ($courseid) {
        if (!($chats = $DB->get_records("chat", array("course" => $courseid)))) {
            return true;
        }
    } else {
        if (!($chats = $DB->get_records("chat"))) {
            return true;
        }
    }
    $moduleid = $DB->get_field('modules', 'id', array('name' => 'chat'));
    foreach ($chats as $chat) {
        $cm = get_coursemodule_from_id('chat', $chat->id);
        $event = new object();
        $event->name = $chat->name;
        $event->description = format_module_intro('chat', $chat, $cm->id);
        $event->timestart = $chat->chattime;
        if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id))) {
            update_event($event);
        } else {
            $event->courseid = $chat->course;
            $event->groupid = 0;
            $event->userid = 0;
            $event->modulename = 'chat';
            $event->instance = $chat->id;
            $event->eventtype = $chat->schedule;
            $event->timeduration = 0;
            $event->visible = $DB->get_field('course_modules', 'visible', array('module' => $moduleid, 'instance' => $chat->id));
            add_event($event);
        }
    }
    return true;
}
Exemple #23
0
/// Check to see if groups are being used in this choice
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) {
    groups_get_activity_group($cm, true);
    groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/choice/view.php?id=' . $id);
}
// Check if we want to include responses from inactive users.
$onlyactive = $choice->includeinactive ? false : true;
$allresponses = choice_get_response_data($choice, $cm, $groupmode, $onlyactive);
// Big function, approx 6 SQL calls per user.
if (has_capability('mod/choice:readresponses', $context)) {
    choice_show_reportlink($allresponses, $cm);
}
echo '<div class="clearer"></div>';
if ($choice->intro) {
    echo $OUTPUT->box(format_module_intro('choice', $choice, $cm->id), 'generalbox', 'intro');
}
$timenow = time();
$current = choice_get_my_response($choice);
//if user has already made a selection, and they are not allowed to update it or if choice is not open, show their selected answer.
if (isloggedin() && !empty($current) && (empty($choice->allowupdate) || $timenow > $choice->timeclose)) {
    $choicetexts = array();
    foreach ($current as $c) {
        $choicetexts[] = format_string(choice_get_option_text($choice, $c->optionid));
    }
    echo $OUTPUT->box(get_string("yourselection", "choice", userdate($choice->timeopen)) . ": " . implode('; ', $choicetexts), 'generalbox', 'yourselection');
}
/// Print the form
$choiceopen = true;
if ($choice->timeclose != 0) {
    if ($choice->timeopen > $timenow) {
Exemple #24
0
        print_error('notapproved', 'data');
    }
}
echo $OUTPUT->heading(format_string($data->name));
// Do we need to show a link to the RSS feed for the records?
//this links has been Settings (database activity administration) block
/*if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
      echo '<div style="float:right;">';
      rss_print_link($context->id, $USER->id, 'mod_data', $data->id, get_string('rsstype'));
      echo '</div>';
      echo '<div style="clear:both;"></div>';
  }*/
if ($data->intro and empty($page) and empty($record) and $mode != 'single') {
    $options = new stdClass();
    $options->noclean = true;
    echo $OUTPUT->box(format_module_intro('data', $data, $cm->id), 'generalbox', 'intro');
}
/// Delete any requested records
if ($delete && confirm_sesskey() && (has_capability('mod/data:manageentries', $context) or data_isowner($delete))) {
    if ($confirm = optional_param('confirm', 0, PARAM_INT)) {
        if ($deleterecord = $DB->get_record('data_records', array('id' => $delete))) {
            // Need to check this is valid
            if ($deleterecord->dataid == $data->id) {
                // Must be from this database
                if ($contents = $DB->get_records('data_content', array('recordid' => $deleterecord->id))) {
                    foreach ($contents as $content) {
                        // Delete files or whatever else this field allows
                        if ($field = data_get_field_from_id($content->fieldid, $data)) {
                            // Might not be there
                            $field->delete_content($content->recordid);
                        }
Exemple #25
0
}
// Checking course module instance
if (!($cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid))) {
    print_error('invalidcoursemodule');
}
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$context = context_module::instance($cm->id);
$PAGE->set_url('/mod/wiki/files.php', array('pageid' => $pageid));
require_login($course, true, $cm);
if (!wiki_user_can_view($subwiki, $wiki)) {
    print_error('cannotviewfiles', 'wiki');
}
$PAGE->set_title(get_string('wikifiles', 'wiki'));
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki')));
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($wiki->name));
echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro');
$renderer = $PAGE->get_renderer('mod_wiki');
$tabitems = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments', 'history' => 'history', 'map' => 'map', 'files' => 'files', 'admin' => 'admin');
$options = array('activetab' => 'files');
echo $renderer->tabs($page, $tabitems, $options);
echo $OUTPUT->box_start('generalbox');
echo $renderer->wiki_print_subwiki_selector($PAGE->activityrecord, $subwiki, $page, 'files');
echo $renderer->wiki_files_tree($context, $subwiki);
echo $OUTPUT->box_end();
if (has_capability('mod/wiki:managefiles', $context)) {
    echo $OUTPUT->single_button(new moodle_url('/mod/wiki/filesedit.php', array('subwiki' => $subwiki->id, 'pageid' => $pageid)), get_string('editfiles', 'wiki'), 'get');
}
echo $OUTPUT->footer();
Exemple #26
0
}
add_to_log($course->id, 'subjectplugin', 'view', "view.php?id={$cm->id}", $subjectplugin->name, $cm->id);
/// Print the page header
$PAGE->set_url('/mod/subjectplugin/view.php', array('id' => $cm->id));
$PAGE->set_title(format_string($subjectplugin->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
// other things you may want to set - remove if not needed
//$PAGE->set_cacheable(false);
//$PAGE->set_focuscontrol('some-html-id');
//$PAGE->add_body_class('subjectplugin-'.$somevar);
// Output starts here
echo $OUTPUT->header();
if ($subjectplugin->intro) {
    // Conditions to show the intro can change to look for own settings or whatever
    echo $OUTPUT->box(format_module_intro('subjectplugin', $subjectplugin, $cm->id), 'generalbox mod_introbox', 'subjectpluginintro');
}
if ($course->guest) {
    echo "not allowd";
}
?>


<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.qtip-1.0.0-rc3.js"></script>
 
<script language="JavaScript">

function first()
	{	
		//alert('first');
Exemple #27
0
             $trackedlink = $stryes;
         } else {
             if ($forum->trackingtype === FORUM_TRACKING_OFF || $USER->trackforums == 0) {
                 $trackedlink = '-';
             } else {
                 $aurl = new moodle_url('/mod/forum/settracking.php', array('id' => $forum->id));
                 if (!isset($untracked[$forum->id])) {
                     $trackedlink = $OUTPUT->single_button($aurl, $stryes, 'post', array('title' => $strnotrackforum));
                 } else {
                     $trackedlink = $OUTPUT->single_button($aurl, $strno, 'post', array('title' => $strtrackforum));
                 }
             }
         }
     }
 }
 $forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost);
 if ($cm->sectionnum != $currentsection) {
     $printsection = get_section_name($course, $cm->sectionnum);
     if ($currentsection) {
         $learningtable->data[] = 'hr';
     }
     $currentsection = $cm->sectionnum;
 } else {
     $printsection = '';
 }
 $forumname = format_string($forum->name, true);
 if ($cm->visible) {
     $style = '';
 } else {
     $style = 'class="dimmed"';
 }
/**
 * Prints the header in view.  Used to help prevent FPDF header errors.
 *
 * @param stdClass $course
 * @param stdClass $certificate
 * @param stdClass $cm
 * @return null
 */
function view_header($course, $certificate, $cm)
{
    global $CFG, $DB, $PAGE, $OUTPUT;
    $PAGE->set_title(format_string($certificate->name));
    $PAGE->set_heading(format_string($course->fullname));
    echo $OUTPUT->header();
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (has_capability('mod/certificate:manage', $context)) {
        $numusers = count(certificate_get_issues($certificate->id, 'ci.certdate ASC', '', $cm));
        echo '<div class="reportlink"><a href="report.php?id=' . $cm->id . '">' . get_string('viewcertificateviews', 'certificate', $numusers) . '</a></div>';
    }
    if (!empty($certificate->intro)) {
        echo $OUTPUT->box(format_module_intro('certificate', $certificate, $cm->id), 'generalbox', 'intro');
    }
}
Exemple #29
0
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    $table->head = array($strsectionname, $strname, $strintro);
    $table->align = array('center', 'left', 'left');
} else {
    $table->head = array($strlastmodified, $strname, $strintro);
    $table->align = array('left', 'left', 'left');
}
$modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($books as $book) {
    $cm = $modinfo->get_cm($book->coursemodule);
    if ($usesections) {
        $printsection = '';
        if ($book->section !== $currentsection) {
            if ($book->section) {
                $printsection = get_section_name($course, $book->section);
            }
            if ($currentsection !== '') {
                $table->data[] = 'hr';
            }
            $currentsection = $book->section;
        }
    } else {
        $printsection = html_writer::tag('span', userdate($book->timemodified), array('class' => 'smallinfo'));
    }
    $class = $book->visible ? null : array('class' => 'dimmed');
    // hidden modules are dimmed
    $table->data[] = array($printsection, html_writer::link(new moodle_url('view.php', array('id' => $cm->id)), format_string($book->name), $class), format_module_intro('book', $book, $cm->id));
}
echo html_writer::table($table);
echo $OUTPUT->footer();
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    $table->head = array($strsectionname, $strname, $strintro);
    $table->align = array('center', 'left', 'left');
} else {
    $table->head = array($strlastmodified, $strname, $strintro);
    $table->align = array('left', 'left', 'left');
}
$modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($pages as $page) {
    $cm = $modinfo->cms[$page->coursemodule];
    if ($usesections) {
        $printsection = '';
        if ($page->section !== $currentsection) {
            if ($page->section) {
                $printsection = get_section_name($course, $page->section);
            }
            if ($currentsection !== '') {
                $table->data[] = 'hr';
            }
            $currentsection = $page->section;
        }
    } else {
        $printsection = '<span class="smallinfo">' . userdate($page->timemodified) . "</span>";
    }
    $class = $page->visible ? '' : 'class="dimmed"';
    // hidden modules are dimmed
    $table->data[] = array($printsection, "<a {$class} href=\"view.php?id={$cm->id}\">" . format_string($page->name) . "</a>", format_module_intro('page', $page, $cm->id));
}
echo html_writer::table($table);
echo $OUTPUT->footer();