function add_txt($file, $name, $uid, $textassoc = null, $start = 0, $end = 0) { // open the file $filestr = open_file($file); // =========== GENERALIZE THIS PLZ ======================================= // arrayify the text into canonical array form $acanon = str_to_array($filestr, "[^a-zA-Z0-9_\\s]"); // get the hash of the text $hash = count_words($acanon); // get counts of uniques, hapax, ... $counts = get_counts($hash); // get a unique text hash to be used as location data $thash = file_id($uid, $name, $filestr); // must build aarray to send to db add function $data['name'] = $name; $data['words'] = $hash; $data['user'] = $uid; $data['counts'] = $counts; $data['start'] = $start; $data['end'] = $end ? $end : $counts['total'] - 1; $data['assoc'] = $textassoc; $data['canon'] = $filestr; $data['hash'] = $thash; // call the add function in MODQUERY and retrive the text_id $tid = add_text_to_db($data); return $tid; }
} if ($entry = get_record('journal_entries', 'userid', $USER->id, 'journal', $journal->id)) { if (empty($entry->text)) { echo '<p align="center"><b>' . get_string('blankentry', 'journal') . '</b></p>'; } else { echo format_text($entry->text, $entry->format); } } else { echo '<span class="warning">' . get_string('notstarted', 'journal') . '</span>'; } print_simple_box_end(); if ($timenow < $timefinish) { if (!empty($entry->modified)) { echo '<div class="lastedit"><strong>' . get_string('lastedited') . ':</strong> '; echo userdate($entry->modified); echo ' (' . get_string('numwords', '', count_words($entry->text)) . ')'; echo "</div>"; } if (!empty($journal->days)) { echo '<div class="editend"><strong>' . get_string('editingends', 'journal') . ':</strong> '; echo userdate($timefinish) . '</div>'; } } else { echo '<div class="editend"><strong>' . get_string('editingended', 'journal') . ':</strong> '; echo userdate($timefinish) . '</div>'; } if (!empty($entry->entrycomment) or !empty($entry->rating)) { $grades = make_grades_menu($journal->assessed); print_heading(get_string('feedback')); journal_print_feedback($course, $entry, $grades); }
function save_review($req, $rrow, $prow, $contact, &$tf = null) { global $Conf, $Opt; $newsubmit = @$req["ready"] && !@$req["unready"] && (!$rrow || !$rrow->reviewSubmitted); $submit = $newsubmit || $rrow && $rrow->reviewSubmitted; $admin = $contact->allow_administer($prow); if (!$contact->timeReview($prow, $rrow) && (!isset($req['override']) || !$admin)) { return Conf::msg_error("The <a href='" . hoturl("deadlines") . "'>deadline</a> for entering this review has passed." . ($admin ? " Select the “Override deadlines” checkbox and try again if you really want to override the deadline." : "")); } $q = array(); $diff_view_score = VIEWSCORE_FALSE; $wc = 0; foreach ($this->forder as $field => $f) { if (isset($req[$field]) && (!$f->round_mask || $f->is_round_visible($rrow))) { $fval = $req[$field]; if ($f->has_options) { if ($f->parse_is_empty($fval)) { $fval = 0; } else { if (!($fval = $f->parse_value($fval, false))) { continue; } } } else { $fval = rtrim($fval); if ($fval != "") { $fval .= "\n"; } // Check for valid UTF-8; re-encode from Windows-1252 or Mac OS $fval = convert_to_utf8($fval); if ($f->include_word_count()) { $wc += count_words($fval); } } if ($rrow && strcmp($rrow->{$field}, $fval) != 0 && strcmp(cleannl($rrow->{$field}), cleannl($fval)) != 0) { $diff_view_score = max($diff_view_score, $f->view_score); } $q[] = "{$field}='" . sqlq($fval) . "'"; } } // get the current time $now = time(); if ($rrow && $rrow->reviewModified && $rrow->reviewModified > $now) { $now = $rrow->reviewModified + 1; } // potentially assign review ordinal (requires table locking since // mySQL is stupid) $locked = false; if ($newsubmit) { $diff_view_score = max($diff_view_score, VIEWSCORE_AUTHOR); $q[] = "reviewSubmitted={$now}, reviewNeedsSubmit=0"; if (!$rrow || !$rrow->reviewOrdinal) { $result = $Conf->qe("lock tables PaperReview write"); if (!$result) { return $result; } $locked = true; $result = $Conf->qe("select coalesce(max(reviewOrdinal), 0) from PaperReview where paperId={$prow->paperId} group by paperId"); if ($result) { $crow = edb_row($result); $q[] = "reviewOrdinal=coalesce(reviewOrdinal, " . ($crow[0] + 1) . ")"; } Dbl::free($result); $q[] = "timeDisplayed={$now}"; } } // check whether used a review token $usedReviewToken = $contact->review_token_cid($prow, $rrow); // blind? reviewer type? edit version? $reviewBlind = $Conf->is_review_blind(!!@$req["blind"]); if ($rrow && $reviewBlind != $rrow->reviewBlind) { $diff_view_score = max($diff_view_score, VIEWSCORE_ADMINONLY); } $q[] = "reviewBlind=" . ($reviewBlind ? 1 : 0); if ($rrow && $rrow->reviewType == REVIEW_EXTERNAL && $contact->contactId == $rrow->contactId && $contact->isPC && !$usedReviewToken) { $q[] = "reviewType=" . REVIEW_PC; } if ($rrow && $diff_view_score > VIEWSCORE_FALSE && isset($req["version"]) && ctype_digit($req["version"]) && $req["version"] > defval($rrow, "reviewEditVersion")) { $q[] = "reviewEditVersion=" . ($req["version"] + 0); } if ($diff_view_score > VIEWSCORE_FALSE && $Conf->sversion >= 98) { $q[] = "reviewWordCount=" . $wc; } if (isset($req["reviewFormat"]) && $Conf->sversion >= 104 && @$Opt["formatInfo"]) { $fmt = null; foreach ($Opt["formatInfo"] as $k => $f) { if (@$f["name"] && strcasecmp($f["name"], $req["reviewFormat"]) == 0) { $fmt = (int) $k; } } if (!$fmt && $req["reviewFormat"] && preg_match('/\\A(?:plain\\s*)?(?:text)?\\z/i', $f["reviewFormat"])) { $fmt = 0; } $q[] = "reviewFormat=" . ($fmt === null ? "null" : $fmt); } // notification $notification_bound = $now - 10800; $notify = $notify_author = false; if (!$rrow || $diff_view_score > VIEWSCORE_FALSE) { $q[] = "reviewModified=" . $now; // do not notify on updates within 3 hours if ($submit && $diff_view_score > VIEWSCORE_ADMINONLY) { if (!$rrow || !$rrow->reviewNotified || $rrow->reviewNotified < $notification_bound) { $q[] = $notify = "reviewNotified=" . $now; } if ((!$rrow || !$rrow->reviewAuthorNotified || $rrow->reviewAuthorNotified < $notification_bound) && $diff_view_score >= VIEWSCORE_AUTHOR && Contact::can_some_author_view_submitted_review($prow)) { $q[] = $notify_author = "reviewAuthorNotified=" . $now; } } } // actually affect database if ($rrow) { $result = $Conf->qe("update PaperReview set " . join(", ", $q) . " where reviewId={$rrow->reviewId}"); $reviewId = $rrow->reviewId; $contactId = $rrow->contactId; } else { $result = Dbl::qe_raw("insert into PaperReview set paperId={$prow->paperId}, contactId={$contact->contactId}, reviewType=" . REVIEW_PC . ", requestedBy={$contact->contactId}, reviewRound=" . $Conf->current_round() . ", " . join(", ", $q)); $reviewId = $result ? $result->insert_id : null; $contactId = $contact->contactId; } // unlock tables even if problem if ($locked) { $Conf->qe("unlock tables"); } if (!$result) { return $result; } // update caches Contact::update_rights(); // look up review ID if (!$reviewId) { return $reviewId; } $req['reviewId'] = $reviewId; // log updates -- but not if review token is used if (!$usedReviewToken && $diff_view_score > VIEWSCORE_FALSE) { $text = "Review {$reviewId} "; if ($rrow && $contact->contactId != $rrow->contactId) { $text .= "by {$rrow->email} "; } $text .= $newsubmit ? "submitted" : ($submit ? "updated" : "saved draft"); $contact->log_activity($text, $prow); } // potentially email chair, reviewers, and authors if ($submit) { $rrow = $Conf->reviewRow(["reviewId" => $reviewId]); } if ($submit && ($notify || $notify_author) && $rrow) { $tmpl = $newsubmit ? "@reviewsubmit" : "@reviewupdate"; $submitter = $contact; if ($contactId != $submitter->contactId) { $submitter = Contact::find_by_id($contactId); } // construct mail $this->mailer_info = array("template" => $tmpl, "rrow" => $rrow, "reviewer_contact" => $submitter, "reviewNumber" => $prow->paperId . unparseReviewOrdinal($rrow->reviewOrdinal), "check_function" => "HotCRPMailer::check_can_view_review", "diff_view_score" => $diff_view_score); $this->mailer_preps = array(); if ($Conf->timeEmailChairAboutReview()) { HotCRPMailer::send_manager($tmpl, $prow, $this->mailer_info); } $prow->notify(WATCHTYPE_REVIEW, array($this, "review_watch_callback"), $contact); if (count($this->mailer_preps)) { HotCRPMailer::send_combined_preparations($this->mailer_preps); } unset($this->mailer_info, $this->mailer_preps); } // if external, forgive the requestor from finishing their review if ($rrow && $rrow->reviewType < REVIEW_SECONDARY && $rrow->requestedBy && $submit) { $Conf->q("update PaperReview set reviewNeedsSubmit=0 where paperId={$prow->paperId} and contactId={$rrow->requestedBy} and reviewType=" . REVIEW_SECONDARY . " and reviewSubmitted is null"); } if ($tf !== null) { $what = "#{$prow->paperId}" . ($rrow && $rrow->reviewSubmitted ? unparseReviewOrdinal($rrow->reviewOrdinal) : ""); if ($newsubmit) { $tf["newlySubmitted"][] = $what; } else { if ($diff_view_score > VIEWSCORE_FALSE && $submit) { $tf["updated"][] = $what; } else { if ($diff_view_score > VIEWSCORE_FALSE) { $tf["savedDraft"][] = $what; } else { $tf["unchanged"][] = $what; } } } if ($notify_author) { $tf["authorNotified"][] = $what; } } return $result; }
/** * Print a forum post * * @global object * @global object * @uses FORUM_MODE_THREADED * @uses PORTFOLIO_FORMAT_PLAINHTML * @uses PORTFOLIO_FORMAT_FILE * @uses PORTFOLIO_FORMAT_RICHHTML * @uses PORTFOLIO_ADD_TEXT_LINK * @uses CONTEXT_MODULE * @param object $post The post to print. * @param object $discussion * @param object $forum * @param object $cm * @param object $course * @param boolean $ownpost Whether this post belongs to the current user. * @param boolean $reply Whether to print a 'reply' link at the bottom of the message. * @param boolean $link Just print a shortened version of the post as a link to the full post. * @param string $footer Extra stuff to print after the message. * @param string $highlight Space-separated list of terms to highlight. * @param int $post_read true, false or -99. If we already know whether this user * has read this post, pass that in, otherwise, pass in -99, and this * function will work it out. * @param boolean $dummyifcantsee When forum_user_can_see_post says that * the current user can't see this post, if this argument is true * (the default) then print a dummy 'you can't see this post' post. * If false, don't output anything at all. * @param bool|null $istracked * @return void */ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost = false, $reply = false, $link = false, $footer = "", $highlight = "", $postisread = null, $dummyifcantsee = true, $istracked = null, $return = false) { global $USER, $CFG, $OUTPUT; require_once $CFG->libdir . '/filelib.php'; // String cache static $str; // This is an extremely hacky way to ensure we only print the 'unread' anchor // the first time we encounter an unread post on a page. Ideally this would // be moved into the caller somehow, and be better testable. But at the time // of dealing with this bug, this static workaround was the most surgical and // it fits together with only printing th unread anchor id once on a given page. static $firstunreadanchorprinted = false; $modcontext = context_module::instance($cm->id); $post->course = $course->id; $post->forum = $forum->id; $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id); if (!empty($CFG->enableplagiarism)) { require_once $CFG->libdir . '/plagiarismlib.php'; $post->message .= plagiarism_get_links(array('userid' => $post->userid, 'content' => $post->message, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum)); } // caching if (!isset($cm->cache)) { $cm->cache = new stdClass(); } if (!isset($cm->cache->caps)) { $cm->cache->caps = array(); $cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext); $cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext); $cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext); $cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext); $cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext); $cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext); $cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext); $cm->cache->caps['mod/forum:exportpost'] = has_capability('mod/forum:exportpost', $modcontext); $cm->cache->caps['mod/forum:exportownpost'] = has_capability('mod/forum:exportownpost', $modcontext); } if (!isset($cm->uservisible)) { $cm->uservisible = \core_availability\info_module::is_user_visible($cm, 0, false); } if ($istracked && is_null($postisread)) { $postisread = forum_tp_is_post_read($USER->id, $post); } if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) { $output = ''; if (!$dummyifcantsee) { if ($return) { return $output; } echo $output; return; } $output .= html_writer::tag('a', '', array('id' => 'p' . $post->id)); $output .= html_writer::start_tag('div', array('class' => 'forumpost clearfix', 'role' => 'region', 'aria-label' => get_string('hiddenforumpost', 'forum'))); $output .= html_writer::start_tag('div', array('class' => 'row header')); $output .= html_writer::tag('div', '', array('class' => 'left picture')); // Picture if ($post->parent) { $output .= html_writer::start_tag('div', array('class' => 'topic')); } else { $output .= html_writer::start_tag('div', array('class' => 'topic starter')); } $output .= html_writer::tag('div', get_string('forumsubjecthidden', 'forum'), array('class' => 'subject', 'role' => 'header')); // Subject. $output .= html_writer::tag('div', get_string('forumauthorhidden', 'forum'), array('class' => 'author', 'role' => 'header')); // Author. $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); // row $output .= html_writer::start_tag('div', array('class' => 'row')); $output .= html_writer::tag('div', ' ', array('class' => 'left side')); // Groups $output .= html_writer::tag('div', get_string('forumbodyhidden', 'forum'), array('class' => 'content')); // Content $output .= html_writer::end_tag('div'); // row $output .= html_writer::end_tag('div'); // forumpost if ($return) { return $output; } echo $output; return; } if (empty($str)) { $str = new stdClass(); $str->edit = get_string('edit', 'forum'); $str->delete = get_string('delete', 'forum'); $str->reply = get_string('reply', 'forum'); $str->parent = get_string('parent', 'forum'); $str->pruneheading = get_string('pruneheading', 'forum'); $str->prune = get_string('prune', 'forum'); $str->displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode); $str->markread = get_string('markread', 'forum'); $str->markunread = get_string('markunread', 'forum'); } $discussionlink = new moodle_url('/mod/forum/discuss.php', array('d' => $post->discussion)); // Build an object that represents the posting user $postuser = new stdClass(); $postuserfields = explode(',', user_picture::fields()); $postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields); $postuser->id = $post->userid; $postuser->fullname = fullname($postuser, $cm->cache->caps['moodle/site:viewfullnames']); $postuser->profilelink = new moodle_url('/user/view.php', array('id' => $post->userid, 'course' => $course->id)); // Prepare the groups the posting user belongs to if (isset($cm->cache->usersgroups)) { $groups = array(); if (isset($cm->cache->usersgroups[$post->userid])) { foreach ($cm->cache->usersgroups[$post->userid] as $gid) { $groups[$gid] = $cm->cache->groups[$gid]; } } } else { $groups = groups_get_all_groups($course->id, $post->userid, $cm->groupingid); } // Prepare the attachements for the post, files then images list($attachments, $attachedimages) = forum_print_attachments($post, $cm, 'separateimages'); // Determine if we need to shorten this post $shortenpost = $link && strlen(strip_tags($post->message)) > $CFG->forum_longpost; // Prepare an array of commands $commands = array(); // Add a permalink. $permalink = new moodle_url($discussionlink); $permalink->set_anchor('p' . $post->id); $commands[] = array('url' => $permalink, 'text' => get_string('permalink', 'forum')); // SPECIAL CASE: The front page can display a news item post to non-logged in users. // Don't display the mark read / unread controls in this case. if ($istracked && $CFG->forum_usermarksread && isloggedin()) { $url = new moodle_url($discussionlink, array('postid' => $post->id, 'mark' => 'unread')); $text = $str->markunread; if (!$postisread) { $url->param('mark', 'read'); $text = $str->markread; } if ($str->displaymode == FORUM_MODE_THREADED) { $url->param('parent', $post->parent); } else { $url->set_anchor('p' . $post->id); } $commands[] = array('url' => $url, 'text' => $text); } // Zoom in to the parent specifically if ($post->parent) { $url = new moodle_url($discussionlink); if ($str->displaymode == FORUM_MODE_THREADED) { $url->param('parent', $post->parent); } else { $url->set_anchor('p' . $post->parent); } $commands[] = array('url' => $url, 'text' => $str->parent); } // Hack for allow to edit news posts those are not displayed yet until they are displayed $age = time() - $post->created; if (!$post->parent && $forum->type == 'news' && $discussion->timestart > time()) { $age = 0; } if ($forum->type == 'single' and $discussion->firstpost == $post->id) { if (has_capability('moodle/course:manageactivities', $modcontext)) { // The first post in single simple is the forum description. $commands[] = array('url' => new moodle_url('/course/modedit.php', array('update' => $cm->id, 'sesskey' => sesskey(), 'return' => 1)), 'text' => $str->edit); } } else { if ($ownpost && $age < $CFG->maxeditingtime || $cm->cache->caps['mod/forum:editanypost']) { $commands[] = array('url' => new moodle_url('/mod/forum/post.php', array('edit' => $post->id)), 'text' => $str->edit); } } if ($cm->cache->caps['mod/forum:splitdiscussions'] && $post->parent && $forum->type != 'single') { $commands[] = array('url' => new moodle_url('/mod/forum/post.php', array('prune' => $post->id)), 'text' => $str->prune, 'title' => $str->pruneheading); } if ($forum->type == 'single' and $discussion->firstpost == $post->id) { // Do not allow deleting of first post in single simple type. } else { if ($ownpost && $age < $CFG->maxeditingtime && $cm->cache->caps['mod/forum:deleteownpost'] || $cm->cache->caps['mod/forum:deleteanypost']) { $commands[] = array('url' => new moodle_url('/mod/forum/post.php', array('delete' => $post->id)), 'text' => $str->delete); } } if ($reply) { $commands[] = array('url' => new moodle_url('/mod/forum/post.php#mformforum', array('reply' => $post->id)), 'text' => $str->reply); } if ($CFG->enableportfolios && ($cm->cache->caps['mod/forum:exportpost'] || $ownpost && $cm->cache->caps['mod/forum:exportownpost'])) { $p = array('postid' => $post->id); require_once $CFG->libdir . '/portfoliolib.php'; $button = new portfolio_add_button(); $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id), 'mod_forum'); if (empty($attachments)) { $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML); } else { $button->set_formats(PORTFOLIO_FORMAT_RICHHTML); } $porfoliohtml = $button->to_html(PORTFOLIO_ADD_TEXT_LINK); if (!empty($porfoliohtml)) { $commands[] = $porfoliohtml; } } // Finished building commands // Begin output $output = ''; if ($istracked) { if ($postisread) { $forumpostclass = ' read'; } else { $forumpostclass = ' unread'; // If this is the first unread post printed then give it an anchor and id of unread. if (!$firstunreadanchorprinted) { $output .= html_writer::tag('a', '', array('id' => 'unread')); $firstunreadanchorprinted = true; } } } else { // ignore trackign status if not tracked or tracked param missing $forumpostclass = ''; } $topicclass = ''; if (empty($post->parent)) { $topicclass = ' firstpost starter'; } if (!empty($post->lastpost)) { $forumpostclass .= ' lastpost'; } // Flag to indicate whether we should hide the author or not. $authorhidden = forum_is_author_hidden($post, $forum); $postbyuser = new stdClass(); $postbyuser->post = $post->subject; $postbyuser->user = $postuser->fullname; $discussionbyuser = get_string('postbyuser', 'forum', $postbyuser); $output .= html_writer::tag('a', '', array('id' => 'p' . $post->id)); // Begin forum post. $output .= html_writer::start_div('forumpost clearfix' . $forumpostclass . $topicclass, ['role' => 'region', 'aria-label' => $discussionbyuser]); // Begin header row. $output .= html_writer::start_div('row header clearfix'); // User picture. if (!$authorhidden) { $picture = $OUTPUT->user_picture($postuser, ['courseid' => $course->id]); $output .= html_writer::div($picture, 'left picture'); $topicclass = 'topic' . $topicclass; } // Begin topic column. $output .= html_writer::start_div($topicclass); $postsubject = $post->subject; if (empty($post->subjectnoformat)) { $postsubject = format_string($postsubject); } $output .= html_writer::div($postsubject, 'subject', ['role' => 'heading', 'aria-level' => '2']); if ($authorhidden) { $bytext = userdate($post->modified); } else { $by = new stdClass(); $by->date = userdate($post->modified); $by->name = html_writer::link($postuser->profilelink, $postuser->fullname); $bytext = get_string('bynameondate', 'forum', $by); } $bytextoptions = ['role' => 'heading', 'aria-level' => '2']; $output .= html_writer::div($bytext, 'author', $bytextoptions); // End topic column. $output .= html_writer::end_div(); // End header row. $output .= html_writer::end_div(); // Row with the forum post content. $output .= html_writer::start_div('row maincontent clearfix'); // Show if author is not hidden or we have groups. if (!$authorhidden || $groups) { $output .= html_writer::start_div('left'); $groupoutput = ''; if ($groups) { $groupoutput = print_group_picture($groups, $course->id, false, true, true); } if (empty($groupoutput)) { $groupoutput = ' '; } $output .= html_writer::div($groupoutput, 'grouppictures'); $output .= html_writer::end_div(); // Left side. } $output .= html_writer::start_tag('div', array('class' => 'no-overflow')); $output .= html_writer::start_tag('div', array('class' => 'content')); $options = new stdClass(); $options->para = false; $options->trusted = $post->messagetrust; $options->context = $modcontext; if ($shortenpost) { // Prepare shortened version by filtering the text then shortening it. $postclass = 'shortenedpost'; $postcontent = format_text($post->message, $post->messageformat, $options); $postcontent = shorten_text($postcontent, $CFG->forum_shortpost); $postcontent .= html_writer::link($discussionlink, get_string('readtherest', 'forum')); $postcontent .= html_writer::tag('div', '(' . get_string('numwords', 'moodle', count_words($post->message)) . ')', array('class' => 'post-word-count')); } else { // Prepare whole post $postclass = 'fullpost'; $postcontent = format_text($post->message, $post->messageformat, $options, $course->id); if (!empty($highlight)) { $postcontent = highlight($highlight, $postcontent); } if (!empty($forum->displaywordcount)) { $postcontent .= html_writer::tag('div', get_string('numwords', 'moodle', count_words($post->message)), array('class' => 'post-word-count')); } $postcontent .= html_writer::tag('div', $attachedimages, array('class' => 'attachedimages')); } // Output the post content $output .= html_writer::tag('div', $postcontent, array('class' => 'posting ' . $postclass)); $output .= html_writer::end_tag('div'); // Content $output .= html_writer::end_tag('div'); // Content mask $output .= html_writer::end_tag('div'); // Row $output .= html_writer::start_tag('div', array('class' => 'row side')); $output .= html_writer::tag('div', ' ', array('class' => 'left')); $output .= html_writer::start_tag('div', array('class' => 'options clearfix')); if (!empty($attachments)) { $output .= html_writer::tag('div', $attachments, array('class' => 'attachments')); } // Output ratings if (!empty($post->rating)) { $output .= html_writer::tag('div', $OUTPUT->render($post->rating), array('class' => 'forum-post-rating')); } // Output the commands $commandhtml = array(); foreach ($commands as $command) { if (is_array($command)) { $commandhtml[] = html_writer::link($command['url'], $command['text']); } else { $commandhtml[] = $command; } } $output .= html_writer::tag('div', implode(' | ', $commandhtml), array('class' => 'commands')); // Output link to post if required if ($link) { if (forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext)) { $langstring = 'discussthistopic'; } else { $langstring = 'viewthediscussion'; } if ($post->replies == 1) { $replystring = get_string('repliesone', 'forum', $post->replies); } else { $replystring = get_string('repliesmany', 'forum', $post->replies); } if (!empty($discussion->unread) && $discussion->unread !== '-') { $replystring .= ' <span class="sep">/</span> <span class="unread">'; if ($discussion->unread == 1) { $replystring .= get_string('unreadpostsone', 'forum'); } else { $replystring .= get_string('unreadpostsnumber', 'forum', $discussion->unread); } $replystring .= '</span>'; } $output .= html_writer::start_tag('div', array('class' => 'link')); $output .= html_writer::link($discussionlink, get_string($langstring, 'forum')); $output .= ' (' . $replystring . ')'; $output .= html_writer::end_tag('div'); // link } // Output footer if required if ($footer) { $output .= html_writer::tag('div', $footer, array('class' => 'footer')); } // Close remaining open divs $output .= html_writer::end_tag('div'); // content $output .= html_writer::end_tag('div'); // row $output .= html_writer::end_tag('div'); // forumpost // Mark the forum post as read if required if ($istracked && !$CFG->forum_usermarksread && !$postisread) { forum_tp_mark_post_read($USER->id, $post, $forum->id); } if ($return) { return $output; } echo $output; return; }
} if ($assignment->assignmenttype != 'online') { print_error('invalidtype', 'assignment'); } $assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course); if ($submission = $assignmentinstance->get_submission($user->id)) { print_header(fullname($user, true) . ': ' . $assignment->name); echo $OUTPUT->box_start('generalbox boxaligcenter', 'dates'); echo '<table>'; if ($assignment->timedue) { echo '<tr><td class="c0">' . get_string('duedate', 'assignment') . ':</td>'; echo ' <td class="c1">' . userdate($assignment->timedue) . '</td></tr>'; } echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>'; echo ' <td class="c1">' . userdate($submission->timemodified); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')</td></tr>'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')</td></tr>'; } } echo '</table>'; echo $OUTPUT->box_end(); echo $OUTPUT->box(format_text($submission->data1, $submission->data2), 'generalbox boxaligncenter boxwidthwide'); echo $OUTPUT->close_window_button(); echo $OUTPUT->footer(); } else { print_string('emptysubmission', 'assignment'); }
/** * Test function count_words(). */ public function test_count_words() { $count = count_words("one two three'four"); $this->assertEquals(3, $count); $count = count_words('one+two three’four'); $this->assertEquals(3, $count); $count = count_words('one"two three-four'); $this->assertEquals(3, $count); $count = count_words('one@two three_four'); $this->assertEquals(4, $count); $count = count_words('one\\two three/four'); $this->assertEquals(4, $count); $count = count_words(' one ... two three...four '); $this->assertEquals(4, $count); $count = count_words('one.2 3,four'); $this->assertEquals(4, $count); $count = count_words('1³ £2 €3.45 $6,789'); $this->assertEquals(4, $count); $count = count_words('one—two ブルース カンベッル'); $this->assertEquals(4, $count); $count = count_words('one…two ブルース … カンベッル'); $this->assertEquals(4, $count); }
</p> <h3><a data-id="<?php the_ID(); ?> " class="posttitle" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <p><?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 100, "..."); ?> </p> <p class="here"> <span class="icon-letter"><?php echo count_words($text); ?> </span> <span class="icon-view"><?php echo getPostViews(get_the_ID()); ?> </span> <?php tz_printLikes(get_the_ID()); ?> </p> </div> </div>
/** * Formatting for log info * * @param stdClass $submission The new submission * @return string */ public function format_for_log(stdClass $submission) { // format the info for each submission plugin add_to_log $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); $onlinetextloginfo = ''; $text = format_text($onlinetextsubmission->onlinetext, $onlinetextsubmission->onlineformat, array('context' => $this->assignment->get_context())); $onlinetextloginfo .= get_string('numwordsforlog', 'assignsubmission_onlinetext', count_words($text)); return $onlinetextloginfo; }
private function chunker(&$text, $style = "") { $errors = null; $text = collapse_spaces($text); $textarr = split_string($text); $chunksarr = split_on_spaces($textarr, $this->spaces); if ($style == "clean") { $chunksarr = remove_junk($chunksarr); } $chunkhashes = null; foreach ($chunksarr as $end => &$chunkarr) { $chunkhashes[$end] = count_words($chunkarr); } if (!$chunkhashes) { $errors[] = "Could not hash chunks. Huh."; trigger_error("Could not hash chunks. Huh."); return $errors; } // if cleaned style, remove all bad words and lc $max = array_pop(array_keys($textarr)) + 1; $maxlen = strlen("{$max}"); $pad = "%0{$maxlen}s"; foreach ($chunksarr as $end => $chunkarr) { $endpad = $end + 1; $endpad = sprintf($pad, $endpad); $out = $this->write_txt($chunkarr, $endpad, $style); $out2 = $this->write_csv($chunkhashes[$end], $endpad, $style); if ($out || $out2) { $errors = array_merge($out, $out2, $errors); } } if ($errors) { rrmdir($this->folder); trigger_error("Something in the chunking process went wrong."); } return $errors; }
} require_login($course->id, false, $cm); if ($USER->id != $user->id && !has_capability('mod/problemstatement:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { error("You can not view this problemstatement"); } $problemstatementinstance = new problemstatement($cm->id, $problemstatement, $cm, $course); if ($submission = $problemstatementinstance->get_submission($user->id)) { print_header(fullname($user, true) . ': ' . $problemstatement->name); print_simple_box_start('center', '', '', '', 'generalbox', 'dates'); echo '<table>'; if ($problemstatement->timedue) { echo '<tr><td class="c0">' . get_string('duedate', 'problemstatement') . ':</td>'; echo ' <td class="c1">' . userdate($problemstatement->timedue) . '</td></tr>'; } echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>'; echo ' <td class="c1">' . userdate($submission->timemodified); /// Decide what to count //if ($CFG->problemstatement_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words($submission->programtext)) . ')</td></tr>'; //} else if ($CFG->problemstatement_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters($submission->programtext)) . ')</td></tr>'; //} echo '</table>'; print_simple_box_end(); print_simple_box(highlight_syntax($submission->programtext, $submission->langid), 'center', '100%'); print_simple_box(format_text($submission->submissioncomment, 0), 'center', '100%'); close_window_button(); print_footer('none'); } else { print_string('emptysubmission', 'problemstatement'); }
/** * @param stdClass $post * @param stdClass $cm * @return string * @author Mark Nielsen */ public function post_message($post, $cm, $search = '') { $options = new stdClass(); $options->para = false; $options->trusted = $post->messagetrust; $options->context = context_module::instance($cm->id); list($attachments, $attachedimages) = hsuforum_print_attachments($post, $cm, 'separateimages'); $message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', context_module::instance($cm->id)->id, 'mod_hsuforum', 'post', $post->id); $postcontent = format_text($message, $post->messageformat, $options, $cm->course); if (!empty($search)) { $postcontent = highlight($search, $postcontent); } if (!empty($attachments)) { $postcontent .= "<div class='attachments'>" . $attachments . "</div>"; } if (!empty($attachedimages)) { $postcontent .= "<div class='attachedimages'>" . $attachedimages . "</div>"; } $forum = hsuforum_get_cm_forum($cm); if (!empty($forum->displaywordcount)) { $postcontent .= "<div class='post-word-count'>" . get_string('numwords', 'moodle', count_words($post->message)) . "</div>"; } $postcontent = "<div class='posting'>" . $postcontent . "</div>"; return $postcontent; }
<?php echo comment_form_input_text(); ?> </label></p> <p><?php echo comment_form_button(); ?> </p> </form> </section> <?php } ?> <section class="footnote"> <p>This article is my <?php echo numeral(article_id() + 1); ?> oldest. It is <?php echo count_words(article_html()); ?> words long. <?php echo article_custom_field('attribution'); ?> </p> </section>
function print_user_files($userid, $return = false) { global $OUTPUT; if (!($submission = $this->get_submission($userid))) { return ''; } $link = html_link::make("/mod/assignment/type/online/file.php?id={$this->cm}->id&userid={$submission->userid}", shorten_text(trim(strip_tags(format_text($submission->data1, $submission->data2))), 15)); $link->add_action(new popup_action('click', $link->url, 'file' . $userid, array('height' => 450, 'width' => 580))); $link->title = get_string('submission', 'assignment'); $popup = $OUTPUT->link($link); $output = '<div class="files">' . '<img align="middle" src="' . $OUTPUT->old_icon_url('f/html') . '" height="16" width="16" alt="html" />' . $popup . '</div>'; ///Stolen code from file.php echo $OUTPUT->box_start('generalbox boxaligncenter', 'wordcount'); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')'; } } echo $OUTPUT->box_end(); echo $OUTPUT->box(format_text($submission->data1, $submission->data2), 'generalbox boxaligncenter boxwidthwide'); ///End of stolen code from file.php if ($return) { //return $output; } //echo $output; }
<?php function count_words($content) { $word = str_word_count($content, 1); return $word; } $content = file_get_contents('/var/www/test1.txt'); $words = count_words($content); $result = array_count_values($words); ksort($result); //echo $content; echo "<pre>"; print_r($result); echo "</pre>"; //$name = $_get['input_name']; //$fp = @fopen(dirname(__file__).'/'.$name, 'rb'); // $fp = @fopen('/var/www/test1.txt', 'rb'); // if (!$fp) { // echo '1111111111'; // exit; // } // while (!feof($fp)) { // $content = fgets($fp); // echo $content.'<br />'; // } // fclose($fp); ?>
/** * Print a forum post * * @param object $post The post to print. * @param integer $courseid The course this post belongs to. * @param boolean $ownpost Whether this post belongs to the current user. * @param boolean $reply Whether to print a 'reply' link at the bottom of the message. * @param boolean $link Just print a shortened version of the post as a link to the full post. * @param object $ratings -- I don't really know -- * @param string $footer Extra stuff to print after the message. * @param string $highlight Space-separated list of terms to highlight. * @param int $post_read true, false or -99. If we already know whether this user * has read this post, pass that in, otherwise, pass in -99, and this * function will work it out. * @param boolean $dummyifcantsee When forum_user_can_see_post says that * the current user can't see this post, if this argument is true * (the default) then print a dummy 'you can't see this post' post. * If false, don't output anything at all. */ function forum_print_post(&$post, $courseid, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = -99, $dummyifcantsee = true) { global $USER, $CFG; static $stredit, $strdelete, $strreply, $strparent, $strprune; static $strpruneheading, $displaymode; static $strmarkread, $strmarkunread, $istracked; if (empty($post->modcontext)) { // Have to generate it, which is expensive! Should always be set. if (empty($post->forum)) { $discussion = get_record('forum_discussions', 'id', $post->discussion); $post->forum = $discussion->forum; } if (!($cm = get_coursemodule_from_instance('forum', $post->forum))) { error('Course Module ID was incorrect'); } $post->modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } if (!forum_user_can_see_post($post->forum, $post->discussion, $post)) { if (!$dummyifcantsee) { return; } echo '<a id="p' . $post->id . '"></a>'; echo '<table cellspacing="0" class="forumpost">'; echo '<tr class="header"><td class="picture left">'; // print_user_picture($post->userid, $courseid, $post->picture); echo '</td>'; if ($post->parent) { echo '<td class="topic">'; } else { echo '<td class="topic starter">'; } echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>'; echo '<div class="author">'; print_string('forumauthorhidden', 'forum'); echo '</div></td></tr>'; echo '<tr><td class="left side">'; echo ' '; // Actual content echo '</td><td class="content">' . "\n"; echo get_string('forumbodyhidden', 'forum'); echo '</td></tr></table>'; return; } if (empty($stredit)) { $stredit = get_string('edit', 'forum'); $strdelete = get_string('delete', 'forum'); $strreply = get_string('reply', 'forum'); $strparent = get_string('parent', 'forum'); $strpruneheading = get_string('pruneheading', 'forum'); $strprune = get_string('prune', 'forum'); $displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode); $strmarkread = get_string('markread', 'forum'); $strmarkunread = get_string('markunread', 'forum'); if (!empty($post->forum)) { $istracked = forum_tp_can_track_forums($post->forum) && forum_tp_is_tracked($post->forum); } else { $istracked = false; } } if ($istracked) { if ($post_read == -99) { // If we don't know yet... // The front page can display a news item post to non-logged in users. This should // always appear as 'read'. $post_read = empty($USER) || forum_tp_is_post_read($USER->id, $post); } if ($post_read) { $read_style = ' read'; } else { $read_style = ' unread'; echo '<a name="unread"></a>'; } } else { $read_style = ''; } echo '<a id="p' . $post->id . '"></a>'; echo '<table cellspacing="0" class="forumpost' . $read_style . '">'; // Picture $postuser = new object(); $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; echo '<tr class="header"><td class="picture left">'; print_user_picture($postuser, $courseid); echo '</td>'; if ($post->parent) { echo '<td class="topic">'; } else { echo '<td class="topic starter">'; } if (!empty($post->subjectnoformat)) { echo '<div class="subject">' . $post->subject . '</div>'; } else { echo '<div class="subject">' . format_string($post->subject) . '</div>'; } echo '<div class="author">'; $fullname = fullname($post, has_capability('moodle/site:viewfullnames', $post->modcontext)); $by = new object(); $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $courseid . '">' . $fullname . '</a>'; $by->date = userdate($post->modified); print_string('bynameondate', 'forum', $by); echo '</div></td></tr>'; echo '<tr><td class="left side">'; if ($group = groups_get_all_groups($courseid, $post->userid)) { print_group_picture($group, $courseid, false, false, true); } else { echo ' '; } // Actual content echo '</td><td class="content">' . "\n"; if ($post->attachment) { $post->course = $courseid; $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion); echo '<div class="attachments">'; $attachedimages = forum_print_attachments($post); echo '</div>'; } else { $attachedimages = ''; } $options = new Object(); $options->para = false; $options->trusttext = true; if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) { // Print shortened version echo format_text(forum_shorten_post($post->message), $post->format, $options, $courseid); $numwords = count_words(strip_tags($post->message)); echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">'; echo get_string('readtherest', 'forum'); echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>'; } else { // Print whole message if ($highlight) { echo highlight($highlight, format_text($post->message, $post->format, $options, $courseid)); } else { echo format_text($post->message, $post->format, $options, $courseid); } echo $attachedimages; } // Commands $commands = array(); if ($istracked) { // SPECIAL CASE: The front page can display a news item post to non-logged in users. // Don't display the mark read / unread controls in this case. if ($CFG->forum_usermarksread && !empty($USER)) { if ($post_read) { $mcmd = '&mark=unread&postid=' . $post->id; $mtxt = $strmarkunread; } else { $mcmd = '&mark=read&postid=' . $post->id; $mtxt = $strmarkread; } if ($displaymode == FORUM_MODE_THREADED) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>'; } else { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>'; } } } if ($post->parent) { // Zoom in to the parent specifically if ($displaymode == FORUM_MODE_THREADED) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->parent . '">' . $strparent . '</a>'; } else { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->parent . '">' . $strparent . '</a>'; } } if (!isset($post->forumtype)) { $post->forumtype = get_field('forum', 'type', 'id', $post->forum); } $age = time() - $post->created; // Hack for allow to edit news posts those are not displayed yet until they are displayed if (!$post->parent && $post->forumtype == 'news' && get_field_sql("SELECT id FROM {$CFG->prefix}forum_discussions WHERE id = {$post->discussion} AND timestart > " . time())) { $age = 0; } $editanypost = has_capability('mod/forum:editanypost', $post->modcontext); if ($ownpost or $editanypost) { if ($age < $CFG->maxeditingtime or $editanypost) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?edit=' . $post->id . '">' . $stredit . '</a>'; } } if (has_capability('mod/forum:splitdiscussions', $post->modcontext) && $post->parent && $post->forumtype != 'single') { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?prune=' . $post->id . '" title="' . $strpruneheading . '">' . $strprune . '</a>'; } if ($ownpost and $age < $CFG->maxeditingtime and has_capability('mod/forum:deleteownpost', $post->modcontext) or has_capability('mod/forum:deleteanypost', $post->modcontext)) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?delete=' . $post->id . '">' . $strdelete . '</a>'; } if ($reply) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . $strreply . '</a>'; } echo '<div class="commands">'; echo implode(' | ', $commands); echo '</div>'; // Ratings $ratingsmenuused = false; if (!empty($ratings) and !empty($USER->id)) { echo '<div class="ratings">'; $useratings = true; if ($ratings->assesstimestart and $ratings->assesstimefinish) { if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) { $useratings = false; } } if ($useratings) { $mypost = $USER->id == $post->userid; $canviewallratings = has_capability('mod/forum:viewanyrating', $post->modcontext); if ($canviewallratings and !$mypost) { forum_print_ratings_mean($post->id, $ratings->scale, $canviewallratings); if (!empty($ratings->allow)) { echo ' '; forum_print_rating_menu($post->id, $USER->id, $ratings->scale); $ratingsmenuused = true; } } else { if ($mypost) { forum_print_ratings_mean($post->id, $ratings->scale, true); } else { if (!empty($ratings->allow)) { forum_print_rating_menu($post->id, $USER->id, $ratings->scale); $ratingsmenuused = true; } } } } echo '</div>'; } // Link to post if required if ($link) { echo '<div class="link">'; if ($post->replies == 1) { $replystring = get_string('repliesone', 'forum', $post->replies); } else { $replystring = get_string('repliesmany', 'forum', $post->replies); } echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . get_string('discussthistopic', 'forum') . '</a> (' . $replystring . ')'; echo '</div>'; } if ($footer) { echo '<div class="footer">' . $footer . '</div>'; } echo '</td></tr></table>' . "\n\n"; if ($istracked && !$CFG->forum_usermarksread && !empty($post->forum)) { forum_tp_mark_post_read($USER->id, $post, $post->forum); } return $ratingsmenuused; }
/** * Compare word count of onlinetext submission to word limit, and return result. * * @param string $submissiontext Onlinetext submission text from editor * @return string Error message if limit is enabled and exceeded, otherwise null */ public function check_word_count($submissiontext) { global $OUTPUT; $wordlimitenabled = $this->get_config('wordlimitenabled'); $wordlimit = $this->get_config('wordlimit'); if ($wordlimitenabled == 0) { return null; } // Count words and compare to limit. $wordcount = count_words($submissiontext); if ($wordcount <= $wordlimit) { return null; } else { $errormsg = get_string('wordlimitexceeded', 'assignsubmission_onlinetext', array('limit' => $wordlimit, 'count' => $wordcount)); return $OUTPUT->error_text($errormsg); } }
function fetchResponses($contextid, $submissionid, $submissiontype, $submissiontext, $submissionfile, $checkfordata = false, $embed = false, $countwords = false) { global $CFG; $responsestring = ""; //if we are showing a list of files we want to use text links not players //a whole page of players will crash a browser. //modify Justin 20120525 lists of flowplayers/jw players will break if embedded and // flowplayers should have image link load deferral anyway if ($CFG->filter_poodll_defaultplayer == 'pd' && $embed == 'true') { //if($embed){ $embed = 'true'; $embedstring = get_string('clicktoplay', 'assignment_poodllonline'); } else { $embedstring = 'clicktoplay'; $embed = 'false'; } //if this is a playback area, for teacher, show a string if no file if ($checkfordata && empty($submissionfile) && $submissiontype != OM_REPLYTEXTONLY) { $responsestring .= "Nothing to play"; } else { //The path to any media file we should play //temporatily used custom logic because of a strange moodle bug that only i noticed. should be ok in 2,3 though //so i reverted to standard pluginfile.php Justin 20120626 //20120802 removed the forcedownload because not necessary and also was causing parsing difficulty in poodllresourcelib.php fetchVideoSplash method $mediapath = $CFG->wwwroot . '/pluginfile.php' . '/' . $contextid . '/mod_assignment/submission/' . $submissionid . '/' . $submissionfile; //$mediapath = $CFG->wwwroot.'/pluginfile.php' . '/'.$contextid.'/mod_assignment/submission/'.$submissionid.'/'. $submissionfile . '?forcedownload=1'; //$mediapath = $CFG->wwwroot.'/filter/poodll/poodllfilelib.php?datatype=poodllpluginfile&contextid='. $contextid .'&itemid='.$submissionid.'¶mone='. $submissionfile; $mediapath = urlencode($mediapath); //check if we need media output switch ($submissiontype) { case OM_REPLYVOICEONLY: case OM_REPLYMP3VOICE: $responsestring .= format_text('{POODLL:type=audio,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML); break; case OM_REPLYVIDEOONLY: $responsestring .= format_text('{POODLL:type=video,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML); break; case OM_REPLYVOICETHENTEXT: $responsestring .= format_text('{POODLL:type=audio,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML); break; case OM_REPLYVIDEOTHENTEXT: $responsestring .= format_text('{POODLL:type=video,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML); break; case OM_REPLYWHITEBOARD: $responsestring .= "<img alt=\"submittedimage\" src=\"" . urldecode($mediapath) . "\" />"; break; } //end of switch } //end of if (checkfordata ...) //check if we need text output switch ($submissiontype) { case OM_REPLYVIDEOONLY: case OM_REPLYVOICEONLY: case OM_REPLYWHITEBOARD: case OM_REPLYMP3VOICE: break; case OM_REPLYVOICETHENTEXT: case OM_REPLYVIDEOTHENTEXT: //add a clear line if we have text after audio or video player if (empty($submissiontext)) { break; } else { $responsestring .= "<br />"; } case OM_REPLYTEXTONLY: default: //if we are coming from print user files we also print the word count. if ($countwords) { /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { $responsestring .= ' (' . get_string('numwords', '', count_words(format_text($submissiontext, FORMAT_HTML))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { $responsestring .= ' (' . get_string('numletters', '', count_letters(format_text($submissiontext, FORMAT_HTML))) . ')'; } } } //finally we print the text response $responsestring .= format_text($submissiontext, FORMAT_HTML); } //end of switch return $responsestring; }
/** * Print a forum post * * @param object $post The post to print. * @param integer $courseid The course this post belongs to. * @param boolean $ownpost Whether this post belongs to the current user. * @param boolean $reply Whether to print a 'reply' link at the bottom of the message. * @param boolean $link Just print a shortened version of the post as a link to the full post. * @param object $ratings -- I don't really know -- * @param string $footer Extra stuff to print after the message. * @param string $highlight Space-separated list of terms to highlight. * @param int $post_read true, false or -99. If we already know whether this user * has read this post, pass that in, otherwise, pass in -99, and this * function will work it out. * @param boolean $dummyifcantsee When forum_user_can_see_post says that * the current user can't see this post, if this argument is true * (the default) then print a dummy 'you can't see this post' post. * If false, don't output anything at all. */ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = null, $dummyifcantsee = true, $istracked = null) { global $USER, $CFG; static $stredit, $strdelete, $strreply, $strparent, $strprune; static $strpruneheading, $displaymode; static $strmarkread, $strmarkunread; $post->course = $course->id; $post->forum = $forum->id; // caching if (!isset($cm->cache)) { $cm->cache = new object(); } if (!isset($cm->cache->caps)) { $cm->cache->caps = array(); $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); $cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext); $cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext); $cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext); $cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext); $cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext); $cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext); $cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext); } if (!isset($cm->uservisible)) { $cm->uservisible = coursemodule_visible_for_user($cm); } if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) { if (!$dummyifcantsee) { return; } echo '<a id="p' . $post->id . '"></a>'; echo '<table cellspacing="0" class="forumpost">'; echo '<tr class="header"><td class="picture left">'; // print_user_picture($post->userid, $courseid, $post->picture); echo '</td>'; if ($post->parent) { echo '<td class="topic">'; } else { echo '<td class="topic starter">'; } echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>'; echo '<div class="author">'; print_string('forumauthorhidden', 'forum'); echo '</div></td></tr>'; echo '<tr><td class="left side">'; echo ' '; // Actual content echo '</td><td class="content">' . "\n"; echo get_string('forumbodyhidden', 'forum'); echo '</td></tr></table>'; return; } if (empty($stredit)) { $stredit = get_string('edit', 'forum'); $strdelete = get_string('delete', 'forum'); $strreply = get_string('reply', 'forum'); $strparent = get_string('parent', 'forum'); $strpruneheading = get_string('pruneheading', 'forum'); $strprune = get_string('prune', 'forum'); $displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode); $strmarkread = get_string('markread', 'forum'); $strmarkunread = get_string('markunread', 'forum'); } $read_style = ''; // ignore trackign status if not tracked or tracked param missing if ($istracked) { if (is_null($post_read)) { debugging('fetching post_read info'); $post_read = forum_tp_is_post_read($USER->id, $post); } if ($post_read) { $read_style = ' read'; } else { $read_style = ' unread'; echo '<a name="unread"></a>'; } } echo '<a id="p' . $post->id . '"></a>'; echo '<table cellspacing="0" class="forumpost' . $read_style . '">'; // Picture $postuser = new object(); $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; echo '<tr class="header"><td class="picture left">'; print_user_picture($postuser, $course->id); echo '</td>'; if ($post->parent) { echo '<td class="topic">'; } else { echo '<td class="topic starter">'; } if (!empty($post->subjectnoformat)) { echo '<div class="subject">' . $post->subject . '</div>'; } else { echo '<div class="subject">' . format_string($post->subject) . '</div>'; } echo '<div class="author">'; $fullname = fullname($postuser, $cm->cache->caps['moodle/site:viewfullnames']); $by = new object(); $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $course->id . '">' . $fullname . '</a>'; $by->date = userdate($post->modified); print_string('bynameondate', 'forum', $by); echo '</div></td></tr>'; echo '<tr><td class="left side">'; if (isset($cm->cache->usersgroups)) { $groups = array(); if (isset($cm->cache->usersgroups[$post->userid])) { foreach ($cm->cache->usersgroups[$post->userid] as $gid) { $groups[$gid] = $cm->cache->groups[$gid]; } } } else { $groups = groups_get_all_groups($course->id, $post->userid, $cm->groupingid); } if ($groups) { print_group_picture($groups, $course->id, false, false, true); } else { echo ' '; } // Actual content echo '</td><td class="content">' . "\n"; if ($post->attachment) { echo '<div class="attachments">'; $attachedimages = forum_print_attachments($post); echo '</div>'; } else { $attachedimages = ''; } $options = new object(); $options->para = false; $options->trusttext = true; if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) { // Print shortened version echo format_text(forum_shorten_post($post->message), $post->format, $options, $course->id); $numwords = count_words(strip_tags($post->message)); echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">'; echo get_string('readtherest', 'forum'); echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>'; } else { // Print whole message if ($highlight) { echo highlight($highlight, format_text($post->message, $post->format, $options, $course->id)); } else { echo format_text($post->message, $post->format, $options, $course->id); } echo $attachedimages; } // Commands $commands = array(); if ($istracked) { // SPECIAL CASE: The front page can display a news item post to non-logged in users. // Don't display the mark read / unread controls in this case. if ($CFG->forum_usermarksread and isloggedin()) { if ($post_read) { $mcmd = '&mark=unread&postid=' . $post->id; $mtxt = $strmarkunread; } else { $mcmd = '&mark=read&postid=' . $post->id; $mtxt = $strmarkread; } if ($displaymode == FORUM_MODE_THREADED) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>'; } else { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>'; } } } if ($post->parent) { // Zoom in to the parent specifically if ($displaymode == FORUM_MODE_THREADED) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->parent . '">' . $strparent . '</a>'; } else { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->parent . '">' . $strparent . '</a>'; } } $age = time() - $post->created; // Hack for allow to edit news posts those are not displayed yet until they are displayed if (!$post->parent and $forum->type == 'news' and $discussion->timestart > time()) { $age = 0; } $editanypost = $cm->cache->caps['mod/forum:editanypost']; if ($ownpost or $editanypost) { if ($age < $CFG->maxeditingtime or $editanypost) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?edit=' . $post->id . '">' . $stredit . '</a>'; } } if ($cm->cache->caps['mod/forum:splitdiscussions'] && $post->parent && $forum->type != 'single') { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?prune=' . $post->id . '" title="' . $strpruneheading . '">' . $strprune . '</a>'; } if ($ownpost and $age < $CFG->maxeditingtime and $cm->cache->caps['mod/forum:deleteownpost'] or $cm->cache->caps['mod/forum:deleteanypost']) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?delete=' . $post->id . '">' . $strdelete . '</a>'; } if ($reply) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . $strreply . '</a>'; } echo '<div class="commands">'; echo implode(' | ', $commands); echo '</div>'; // Ratings $ratingsmenuused = false; if (!empty($ratings) and isloggedin()) { echo '<div class="ratings">'; $useratings = true; if ($ratings->assesstimestart and $ratings->assesstimefinish) { if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) { $useratings = false; } } if ($useratings) { $mypost = $USER->id == $post->userid; $canviewallratings = $cm->cache->caps['mod/forum:viewanyrating']; if (isset($cm->cache->ratings)) { if (isset($cm->cache->ratings[$post->id])) { $allratings = $cm->cache->ratings[$post->id]; } else { $allratings = array(); // no reatings present yet } } else { $allratings = NULL; // not preloaded } if (isset($cm->cache->myratings)) { if (isset($cm->cache->myratings[$post->id])) { $myrating = $cm->cache->myratings[$post->id]; } else { $myrating = FORUM_UNSET_POST_RATING; // no reatings present yet } } else { $myrating = NULL; // not preloaded } if ($canviewallratings and !$mypost) { forum_print_ratings($post->id, $ratings->scale, $forum->assessed, $canviewallratings, $allratings); if (!empty($ratings->allow)) { echo ' '; forum_print_rating_menu($post->id, $USER->id, $ratings->scale, $myrating); $ratingsmenuused = true; } } else { if ($mypost) { forum_print_ratings($post->id, $ratings->scale, $forum->assessed, true, $allratings); } else { if (!empty($ratings->allow)) { forum_print_rating_menu($post->id, $USER->id, $ratings->scale, $myrating); $ratingsmenuused = true; } } } } echo '</div>'; } // Link to post if required if ($link) { echo '<div class="link">'; if ($post->replies == 1) { $replystring = get_string('repliesone', 'forum', $post->replies); } else { $replystring = get_string('repliesmany', 'forum', $post->replies); } echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . get_string('discussthistopic', 'forum') . '</a> (' . $replystring . ')'; echo '</div>'; } if ($footer) { echo '<div class="footer">' . $footer . '</div>'; } echo '</td></tr></table>' . "\n\n"; if ($istracked && !$CFG->forum_usermarksread && !$post_read) { forum_tp_mark_post_read($USER->id, $post, $forum->id); } return $ratingsmenuused; }
/** * Formatting for log info * * @param stdClass $submission The new submission * @return string */ public function format_for_log(stdClass $submission) { // Format the info for each submission plugin (will be logged). $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); $onlinetextloginfo = ''; $onlinetextloginfo .= get_string('numwordsforlog', 'assignsubmission_onlinetext', count_words($onlinetextsubmission->onlinetext)); return $onlinetextloginfo; }
?> </h1> <article> <?php echo article_markdown(); ?> </article> <section class="footnote"> <!-- Unfortunately, CSS means everything's got to be inline. --> <p>This article is my <?php echo numeral(article_number(article_id()), true); ?> oldest. It is <?php echo count_words(article_markdown()); ?> words long<?php if (comments_open()) { ?> , and it’s got <?php echo total_comments() . pluralise(total_comments(), ' comment'); ?> for now.<?php } ?> <?php echo article_custom_field('attribution'); ?> </p> </section>
protected function get_count_display(qtype_essay_question $question, $response){ if (!$question->has_response_limit()) { return ''; } $count = ''; if ($question->wordlimit) { $current = !empty($response) ? count_words($response) : 0; $words = "Words: <span class='current'>$current</span> / $question->wordlimit"; $count .= html_writer::tag('div', $words, array('class' => 'wordcount')); } if ($question->charlimit) { $current = !empty($response) ? strlen($response) : 0; $words = "Characters: <span class='current'>$current</span> / $question->charlimit"; $count .= html_writer::tag('div', $words, array('class' => 'charcount')); } return html_writer::tag('div', $count, array('class' => 'count')); }
function print_user_files($userid, $return = false) { global $OUTPUT, $CFG; if (!($submission = $this->get_submission($userid))) { return ''; } $link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}"); $action = new popup_action('click', $link, 'file' . $userid, array('height' => 450, 'width' => 580)); $popup = $OUTPUT->action_link($link, get_string('popupinnewwindow', 'assignment'), $action, array('title' => get_string('submission', 'assignment'))); $output = '<div class="files">' . '<img align="middle" src="' . $OUTPUT->pix_url('f/html') . '" height="16" width="16" alt="html" />' . $popup . '</div>'; $wordcount = '<p id="wordcount">' . $popup . ' '; /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { $wordcount .= '(' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { $wordcount .= '(' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')'; } } $wordcount .= '</p>'; $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id); return $wordcount . format_text($text, $submission->data2, array('overflowdiv' => true)); }
/** * TODO document */ function forum_print_post(&$post, $courseid, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = -99) { global $USER, $CFG, $SESSION; static $stredit, $strdelete, $strreply, $strparent, $strprune; static $strpruneheading, $threadedmode; static $strmarkread, $strmarkunread, $istracked; if (empty($post->modcontext)) { // Have to generate it, which is expensive! Should always be set. if (empty($post->forum)) { $discussion = get_record('forum_discussions', 'id', $post->discussion); $post->forum = $discussion->forum; } if (!($cm = get_coursemodule_from_instance('forum', $post->forum))) { error('Course Module ID was incorrect'); } $post->modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } if (!forum_user_can_see_post($post->forum, $post->discussion, $post)) { if (empty($SESSION->forum_search)) { // just viewing, return return; } echo '<a id="p' . $post->id . '"></a>'; echo '<table cellspacing="0" class="forumpost">'; echo '<tr class="header"><td class="picture left">'; // print_user_picture($post->userid, $courseid, $post->picture); echo '</td>'; if ($post->parent) { echo '<td class="topic">'; } else { echo '<td class="topic starter">'; } echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>'; echo '<div class="author">'; print_string('forumauthorhidden', 'forum'); echo '</div></td></tr>'; echo '<tr><td class="left side">'; echo ' '; // Actual content echo '</td><td class="content">' . "\n"; echo get_string('forumbodyhidden', 'forum'); echo '</td></tr></table>'; return; } if (empty($stredit)) { $stredit = get_string('edit', 'forum'); $strdelete = get_string('delete', 'forum'); $strreply = get_string('reply', 'forum'); $strparent = get_string('parent', 'forum'); $strpruneheading = get_string('pruneheading', 'forum'); $strprune = get_string('prune', 'forum'); $threadedmode = (!empty($USER->mode) and $USER->mode == FORUM_MODE_THREADED); $strmarkread = get_string('markread', 'forum'); $strmarkunread = get_string('markunread', 'forum'); if (!empty($post->forum)) { $istracked = forum_tp_can_track_forums($post->forum) && forum_tp_is_tracked($post->forum); } else { $istracked = false; } } if ($istracked) { if ($post_read == -99) { // If we don't know yet... // The front page can display a news item post to non-logged in users. This should // always appear as 'read'. $post_read = empty($USER) || forum_tp_is_post_read($USER->id, $post); } if ($post_read) { $read_style = ' read'; } else { $read_style = ' unread'; echo '<a name="unread"></a>'; } } else { $read_style = ''; } echo '<a id="p' . $post->id . '"></a>'; echo '<table cellspacing="0" class="forumpost' . $read_style . ' ' . PM_POST_CLASS . '" id="m' . $post->id . '">'; // Picture $postuser = new object(); $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; echo '<tr class="header"><td class="picture left">'; print_user_picture($postuser, $courseid); echo '</td>'; if ($post->parent) { echo '<td class="topic" colspan="3">'; } else { echo '<td class="topic starter" colspan="3">'; } echo '<div class="subject ' . PM_TITLE_CLASS . '">' . format_string($post->subject) . '</div>'; // #GEOF# Annotations must use a unique value for the user ID // This should be a string, and it should be human-readable and suitable for // outside consumption. I'm therefore using username rather than ID. // If Moodle displayed these values, the fields wouldn'n need to be hidden. $rootpath = $CFG->wwwroot; //parse_url( $CFG->wwwroot ); //$rootpath = $rootpath[ 'path' ]; $refurl = "{$rootpath}/mod/forum/permalink.php?p={$post->id}"; $discussurl = "{$rootpath}/mod/forum/discuss.php?d={$post->discussion}"; // used for summary link // This class author, used by Marginalia, must preceed the one below, used by Moodle. (Well, not in Moodle 1.8) // Unfortunately I can't use that one - it's marked author but it is not, in fact, the author // - it also includes "by", the date, etc. (grrr) #geof# echo "<span style='display:none' class='" . PM_AUTHOR_CLASS . "' title='" . htmlspecialchars($post->username) . "'>" . htmlspecialchars($post->firstname . ' ' . $post->lastname) . "</span>\n"; echo "<abbr style='display:none' class='" . PM_DATE_CLASS . "' title='" . date('Ymd', $post->modified) . 'T' . date('HiO', $post->modified) . "'></abbr>\n"; echo "<a style='display:none' rel='" . PM_URL_REL . "' href='{$refurl}'></a>\n"; echo '<div class="author">'; $fullname = fullname($post, has_capability('moodle/site:viewfullnames', $post->modcontext)); $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $courseid . '">' . $fullname . '</a>'; $by->date = userdate($post->modified); // This, I presume, is to localize string display. Unfortunately it's // unstructured text, so I can't insert the necessary <abbr> element with the date. // Instead that's done in a hidden tag above. print_string('bynameondate', 'forum', $by); echo '</div></td></tr>'; echo '<tr><td class="left side">'; if ($group = user_group($courseid, $post->userid)) { print_group_picture($group, $courseid, false, false, true); } else { echo ' '; } // Actual content echo '</td><td class="content ' . PM_CONTENT_CLASS . '" valign="top">' . "\n"; if ($post->attachment) { $post->course = $courseid; $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion); echo '<div class="attachments">'; $attachedimages = forum_print_attachments($post); echo '</div>'; } else { $attachedimages = ''; } $options = new Object(); $options->para = false; $options->trusttext = true; if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) { // Print shortened version echo format_text(forum_shorten_post($post->message), $post->format, $options, $courseid); $numwords = count_words(strip_tags($post->message)); echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">'; echo get_string('readtherest', 'forum'); echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>'; } else { // Print whole message if ($highlight) { echo highlight($highlight, format_text($post->message, $post->format, $options, $courseid)); } else { echo format_text($post->message, $post->format, $options, $courseid); } echo $attachedimages; } // Commands $commands = array(); if ($istracked) { // SPECIAL CASE: The front page can display a news item post to non-logged in users. // Don't display the mark read / unread controls in this case. if ($CFG->forum_usermarksread && !empty($USER)) { if ($post_read) { $mcmd = '&mark=unread&postid=' . $post->id; $mtxt = $strmarkunread; } else { $mcmd = '&mark=read&postid=' . $post->id; $mtxt = $strmarkread; } if ($threadedmode) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>'; } else { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>'; } } } if ($post->parent) { if ($threadedmode) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->parent . '">' . $strparent . '</a>'; } else { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->parent . '">' . $strparent . '</a>'; } } if (!isset($post->forumtype)) { $post->forumtype = get_field('forum', 'type', 'id', $post->forum); } $age = time() - $post->created; // Hack for allow to edit news posts those are not displayed yet until they are displayed if (!$post->parent && $post->forumtype == 'news' && get_field_sql("SELECT id FROM {$CFG->prefix}forum_discussions WHERE id = {$post->discussion} AND timestart > " . time())) { $age = 0; } $editanypost = has_capability('mod/forum:editanypost', $post->modcontext); if ($ownpost or $editanypost) { if ($age < $CFG->maxeditingtime or $editanypost) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?edit=' . $post->id . '">' . $stredit . '</a>'; } } if (has_capability('mod/forum:splitdiscussions', $post->modcontext) && $post->parent && $post->forumtype != 'single') { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?prune=' . $post->id . '" title="' . $strpruneheading . '">' . $strprune . '</a>'; } if ($ownpost and $age < $CFG->maxeditingtime and has_capability('mod/forum:deleteownpost', $post->modcontext) or has_capability('mod/forum:deleteanypost', $post->modcontext)) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?delete=' . $post->id . '">' . $strdelete . '</a>'; } // The span below is to allow text-decoration:underline, which doesn't seem // to work otherwise (Firefox bug?) $commands[] = "<button class='smartquote'><span>Quote</span></button>"; if ($reply) { $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . $strreply . '</a>'; } echo '<div class="commands">'; echo implode(' | ', $commands); echo '</div>'; // Ratings $ratingsmenuused = false; if (!empty($ratings) and !empty($USER->id)) { echo '<div class="ratings">'; $useratings = true; if ($ratings->assesstimestart and $ratings->assesstimefinish) { if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) { $useratings = false; } } if ($useratings) { $mypost = $USER->id == $post->userid; $canviewallratings = has_capability('mod/forum:viewanyrating', $post->modcontext); if ($canviewallratings and !$mypost) { forum_print_ratings_mean($post->id, $ratings->scale, $canviewallratings); if (!empty($ratings->allow)) { echo ' '; forum_print_rating_menu($post->id, $USER->id, $ratings->scale); $ratingsmenuused = true; } } else { if ($mypost) { forum_print_ratings_mean($post->id, $ratings->scale, true); } else { if (!empty($ratings->allow)) { forum_print_rating_menu($post->id, $USER->id, $ratings->scale); $ratingsmenuused = true; } } } } echo '</div>'; } // Link to post if required if ($link) { echo '<div class="link">'; if ($post->replies == 1) { $replystring = get_string('repliesone', 'forum', $post->replies); } else { $replystring = get_string('repliesmany', 'forum', $post->replies); } echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . get_string('discussthistopic', 'forum') . '</a> (' . $replystring . ')'; echo '</div>'; } if ($footer) { echo '<div class="footer">' . $footer . '</div>'; } // if ( $canannotate ) // { echo "</td><td class='control-margin'><div><button type='button' " . " title='" . htmlspecialchars(get_string('create_button', ANNOTATION_STRINGS)) . "'" . " onclick='window.moodleMarginalia.createAnnotation(event,\"m{$post->id}\")'><span>></span></button></div></td>\n"; echo "<td class='" . AN_NOTES_CLASS . "' valign='top'><div>"; echo "<ol></ol>\n"; echo "</div></td>\n"; // } // else // echo "<td></td><td></td>"; echo '</tr></table>' . "\n\n"; if ($istracked && !$CFG->forum_usermarksread && !empty($post->forum)) { forum_tp_mark_post_read($USER->id, $post, $post->forum); } return $ratingsmenuused; }
function print_user_files($userid, $return = false) { global $CFG; if (!($submission = $this->get_submission($userid))) { return ''; } $output = '<div class="files">' . '<img align="middle" src="' . $CFG->pixpath . '/f/html.gif" height="16" width="16" alt="html" />' . link_to_popup_window('/mod/assignment/type/online/file.php?id=' . $this->cm->id . '&userid=' . $submission->userid, 'file' . $userid, shorten_text(trim(strip_tags(format_text($submission->data1, $submission->data2))), 15), 450, 580, get_string('submission', 'assignment'), 'none', true) . '</div>'; ///Stolen code from file.php print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount'); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')'; } } print_simple_box_end(); print_simple_box(format_text($submission->data1, $submission->data2), 'center', '100%'); ///End of stolen code from file.php if ($return) { //return $output; } //echo $output; }
function view_dates() { global $USER, $CFG, $OUTPUT; if (!$this->mediaboard->timeavailable && !$this->mediaboard->timedue) { return; } echo $OUTPUT->box_start('generalbox boxaligncenter', 'dates'); echo '<table>'; if ($this->mediaboard->timeavailable) { echo '<tr><td class="c0">'.get_string('availabledate','mediaboard').':</td>'; echo ' <td class="c1">'.userdate($this->mediaboard->timeavailable).'</td></tr>'; } if ($this->mediaboard->timedue) { echo '<tr><td class="c0">'.get_string('duedate','mediaboard').':</td>'; echo ' <td class="c1">'.userdate($this->mediaboard->timedue).'</td></tr>'; } $submission = $this->get_submission($USER->id); if ($submission) { echo '<tr><td class="c0">'.get_string('lastedited').':</td>'; echo ' <td class="c1">'.userdate($submission->timemodified); /// Decide what to count if ($CFG->mediaboard_itemstocount == mediaboard_COUNT_WORDS) { echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')</td></tr>'; } else if ($CFG->mediaboard_itemstocount == mediaboard_COUNT_LETTERS) { echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')</td></tr>'; } } echo '</table>'; echo $OUTPUT->box_end(); }
/** * Print a forum post * * @global object * @global object * @uses FORUM_MODE_THREADED * @uses PORTFOLIO_FORMAT_PLAINHTML * @uses PORTFOLIO_FORMAT_FILE * @uses PORTFOLIO_FORMAT_RICHHTML * @uses PORTFOLIO_ADD_TEXT_LINK * @uses CONTEXT_MODULE * @param object $post The post to print. * @param object $discussion * @param object $forum * @param object $cm * @param object $course * @param boolean $ownpost Whether this post belongs to the current user. * @param boolean $reply Whether to print a 'reply' link at the bottom of the message. * @param boolean $link Just print a shortened version of the post as a link to the full post. * @param string $footer Extra stuff to print after the message. * @param string $highlight Space-separated list of terms to highlight. * @param int $post_read true, false or -99. If we already know whether this user * has read this post, pass that in, otherwise, pass in -99, and this * function will work it out. * @param boolean $dummyifcantsee When forum_user_can_see_post says that * the current user can't see this post, if this argument is true * (the default) then print a dummy 'you can't see this post' post. * If false, don't output anything at all. * @param bool|null $istracked * @return void */ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=false, $reply=false, $link=false, $footer="", $highlight="", $postisread=null, $dummyifcantsee=true, $istracked=null, $return=false) { global $USER, $CFG, $OUTPUT; require_once($CFG->libdir . '/filelib.php'); // String cache static $str; $modcontext = context_module::instance($cm->id); $post->course = $course->id; $post->forum = $forum->id; $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id); if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir.'/plagiarismlib.php'); $post->message .= plagiarism_get_links(array('userid' => $post->userid, 'content' => $post->message, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum)); } // caching if (!isset($cm->cache)) { $cm->cache = new stdClass; } if (!isset($cm->cache->caps)) { $cm->cache->caps = array(); $cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext); $cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext); $cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext); $cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext); $cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext); $cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext); $cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext); $cm->cache->caps['mod/forum:exportpost'] = has_capability('mod/forum:exportpost', $modcontext); $cm->cache->caps['mod/forum:exportownpost'] = has_capability('mod/forum:exportownpost', $modcontext); } if (!isset($cm->uservisible)) { $cm->uservisible = coursemodule_visible_for_user($cm); } if ($istracked && is_null($postisread)) { $postisread = forum_tp_is_post_read($USER->id, $post); } if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) { $output = ''; if (!$dummyifcantsee) { if ($return) { return $output; } echo $output; return; } $output .= html_writer::tag('a', '', array('id'=>'p'.$post->id)); $output .= html_writer::start_tag('div', array('class'=>'forumpost clearfix')); $output .= html_writer::start_tag('div', array('class'=>'row header')); $output .= html_writer::tag('div', '', array('class'=>'left picture')); // Picture if ($post->parent) { $output .= html_writer::start_tag('div', array('class'=>'topic')); } else { $output .= html_writer::start_tag('div', array('class'=>'topic starter')); } $output .= html_writer::tag('div', get_string('forumsubjecthidden','forum'), array('class'=>'subject')); // Subject $output .= html_writer::tag('div', get_string('forumauthorhidden','forum'), array('class'=>'author')); // author $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); // row $output .= html_writer::start_tag('div', array('class'=>'row')); $output .= html_writer::tag('div', ' ', array('class'=>'left side')); // Groups $output .= html_writer::tag('div', get_string('forumbodyhidden','forum'), array('class'=>'content')); // Content $output .= html_writer::end_tag('div'); // row $output .= html_writer::end_tag('div'); // forumpost if ($return) { return $output; } echo $output; return; } if (empty($str)) { $str = new stdClass; $str->edit = get_string('edit', 'forum'); $str->delete = get_string('delete', 'forum'); $str->reply = get_string('reply', 'forum'); $str->parent = get_string('parent', 'forum'); $str->pruneheading = get_string('pruneheading', 'forum'); $str->prune = get_string('prune', 'forum'); $str->displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode); $str->markread = get_string('markread', 'forum'); $str->markunread = get_string('markunread', 'forum'); } $discussionlink = new moodle_url('/mod/forum/discuss.php', array('d'=>$post->discussion)); // Build an object that represents the posting user $postuser = new stdClass; $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; $postuser->email = $post->email; // Some handy things for later on $postuser->fullname = fullname($postuser, $cm->cache->caps['moodle/site:viewfullnames']); $postuser->profilelink = new moodle_url('/user/view.php', array('id'=>$post->userid, 'course'=>$course->id)); // Prepare the groups the posting user belongs to if (isset($cm->cache->usersgroups)) { $groups = array(); if (isset($cm->cache->usersgroups[$post->userid])) { foreach ($cm->cache->usersgroups[$post->userid] as $gid) { $groups[$gid] = $cm->cache->groups[$gid]; } } } else { $groups = groups_get_all_groups($course->id, $post->userid, $cm->groupingid); } // Prepare the attachements for the post, files then images list($attachments, $attachedimages) = forum_print_attachments($post, $cm, 'separateimages'); // Determine if we need to shorten this post $shortenpost = ($link && (strlen(strip_tags($post->message)) > $CFG->forum_longpost)); // Prepare an array of commands $commands = array(); // SPECIAL CASE: The front page can display a news item post to non-logged in users. // Don't display the mark read / unread controls in this case. if ($istracked && $CFG->forum_usermarksread && isloggedin()) { $url = new moodle_url($discussionlink, array('postid'=>$post->id, 'mark'=>'unread')); $text = $str->markunread; if (!$postisread) { $url->param('mark', 'read'); $text = $str->markread; } if ($str->displaymode == FORUM_MODE_THREADED) { $url->param('parent', $post->parent); } else { $url->set_anchor('p'.$post->id); } $commands[] = array('url'=>$url, 'text'=>$text); } // Zoom in to the parent specifically if ($post->parent) { $url = new moodle_url($discussionlink); if ($str->displaymode == FORUM_MODE_THREADED) { $url->param('parent', $post->parent); } else { $url->set_anchor('p'.$post->parent); } $commands[] = array('url'=>$url, 'text'=>$str->parent); } // Hack for allow to edit news posts those are not displayed yet until they are displayed $age = time() - $post->created; if (!$post->parent && $forum->type == 'news' && $discussion->timestart > time()) { $age = 0; } if ($forum->type == 'single' and $discussion->firstpost == $post->id) { if (has_capability('moodle/course:manageactivities', $modcontext)) { // The first post in single simple is the forum description. $commands[] = array('url'=>new moodle_url('/course/modedit.php', array('update'=>$cm->id, 'sesskey'=>sesskey(), 'return'=>1)), 'text'=>$str->edit); } } else if (($ownpost && $age < $CFG->maxeditingtime) || $cm->cache->caps['mod/forum:editanypost']) { $commands[] = array('url'=>new moodle_url('/mod/forum/post.php', array('edit'=>$post->id)), 'text'=>$str->edit); } if ($cm->cache->caps['mod/forum:splitdiscussions'] && $post->parent && $forum->type != 'single') { $commands[] = array('url'=>new moodle_url('/mod/forum/post.php', array('prune'=>$post->id)), 'text'=>$str->prune, 'title'=>$str->pruneheading); } if ($forum->type == 'single' and $discussion->firstpost == $post->id) { // Do not allow deleting of first post in single simple type. } else if (($ownpost && $age < $CFG->maxeditingtime && $cm->cache->caps['mod/forum:deleteownpost']) || $cm->cache->caps['mod/forum:deleteanypost']) { $commands[] = array('url'=>new moodle_url('/mod/forum/post.php', array('delete'=>$post->id)), 'text'=>$str->delete); } if ($reply) { $commands[] = array('url'=>new moodle_url('/mod/forum/post.php#mformforum', array('reply'=>$post->id)), 'text'=>$str->reply); } if ($CFG->enableportfolios && ($cm->cache->caps['mod/forum:exportpost'] || ($ownpost && $cm->cache->caps['mod/forum:exportownpost']))) { $p = array('postid' => $post->id); require_once($CFG->libdir.'/portfoliolib.php'); $button = new portfolio_add_button(); $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id), 'mod_forum'); if (empty($attachments)) { $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML); } else { $button->set_formats(PORTFOLIO_FORMAT_RICHHTML); } $porfoliohtml = $button->to_html(PORTFOLIO_ADD_TEXT_LINK); if (!empty($porfoliohtml)) { $commands[] = $porfoliohtml; } } // Finished building commands // Begin output $output = ''; if ($istracked) { if ($postisread) { $forumpostclass = ' read'; } else { $forumpostclass = ' unread'; $output .= html_writer::tag('a', '', array('name'=>'unread')); } } else { // ignore trackign status if not tracked or tracked param missing $forumpostclass = ''; } $topicclass = ''; if (empty($post->parent)) { $topicclass = ' firstpost starter'; } $output .= html_writer::tag('a', '', array('id'=>'p'.$post->id)); $output .= html_writer::start_tag('div', array('class'=>'forumpost clearfix'.$forumpostclass.$topicclass)); $output .= html_writer::start_tag('div', array('class'=>'row header clearfix')); $output .= html_writer::start_tag('div', array('class'=>'left picture')); $output .= $OUTPUT->user_picture($postuser, array('courseid'=>$course->id)); $output .= html_writer::end_tag('div'); $output .= html_writer::start_tag('div', array('class'=>'topic'.$topicclass)); $postsubject = $post->subject; if (empty($post->subjectnoformat)) { $postsubject = format_string($postsubject); } $output .= html_writer::tag('div', $postsubject, array('class'=>'subject')); $by = new stdClass(); $by->name = html_writer::link($postuser->profilelink, $postuser->fullname); $by->date = userdate($post->modified); $output .= html_writer::tag('div', get_string('bynameondate', 'forum', $by), array('class'=>'author')); $output .= html_writer::end_tag('div'); //topic $output .= html_writer::end_tag('div'); //row $output .= html_writer::start_tag('div', array('class'=>'row maincontent clearfix')); $output .= html_writer::start_tag('div', array('class'=>'left')); $groupoutput = ''; if ($groups) { $groupoutput = print_group_picture($groups, $course->id, false, true, true); } if (empty($groupoutput)) { $groupoutput = ' '; } $output .= html_writer::tag('div', $groupoutput, array('class'=>'grouppictures')); $output .= html_writer::end_tag('div'); //left side $output .= html_writer::start_tag('div', array('class'=>'no-overflow')); $output .= html_writer::start_tag('div', array('class'=>'content')); if (!empty($attachments)) { $output .= html_writer::tag('div', $attachments, array('class'=>'attachments')); } $options = new stdClass; $options->para = false; $options->trusted = $post->messagetrust; $options->context = $modcontext; if ($shortenpost) { // Prepare shortened version $postclass = 'shortenedpost'; $postcontent = format_text(forum_shorten_post($post->message), $post->messageformat, $options, $course->id); $postcontent .= html_writer::link($discussionlink, get_string('readtherest', 'forum')); $postcontent .= html_writer::tag('div', '('.get_string('numwords', 'moodle', count_words($post->message)).')', array('class'=>'post-word-count')); } else { // Prepare whole post $postclass = 'fullpost'; $postcontent = format_text($post->message, $post->messageformat, $options, $course->id); if (!empty($highlight)) { $postcontent = highlight($highlight, $postcontent); } if (!empty($forum->displaywordcount)) { $postcontent .= html_writer::tag('div', get_string('numwords', 'moodle', count_words($post->message)), array('class'=>'post-word-count')); } $postcontent .= html_writer::tag('div', $attachedimages, array('class'=>'attachedimages')); } // Output the post content $output .= html_writer::tag('div', $postcontent, array('class'=>'posting '.$postclass)); $output .= html_writer::end_tag('div'); // Content $output .= html_writer::end_tag('div'); // Content mask $output .= html_writer::end_tag('div'); // Row $output .= html_writer::start_tag('div', array('class'=>'row side')); $output .= html_writer::tag('div',' ', array('class'=>'left')); $output .= html_writer::start_tag('div', array('class'=>'options clearfix')); // Output ratings if (!empty($post->rating)) { $output .= html_writer::tag('div', $OUTPUT->render($post->rating), array('class'=>'forum-post-rating')); } // Output the commands $commandhtml = array(); foreach ($commands as $command) { if (is_array($command)) { $commandhtml[] = html_writer::link($command['url'], $command['text']); } else { $commandhtml[] = $command; } } $output .= html_writer::tag('div', implode(' | ', $commandhtml), array('class'=>'commands')); // Output link to post if required if ($link) { if ($post->replies == 1) { $replystring = get_string('repliesone', 'forum', $post->replies); } else { $replystring = get_string('repliesmany', 'forum', $post->replies); } $output .= html_writer::start_tag('div', array('class'=>'link')); $output .= html_writer::link($discussionlink, get_string('discussthistopic', 'forum')); $output .= ' ('.$replystring.')'; $output .= html_writer::end_tag('div'); // link } // Output footer if required if ($footer) { $output .= html_writer::tag('div', $footer, array('class'=>'footer')); } // Close remaining open divs $output .= html_writer::end_tag('div'); // content $output .= html_writer::end_tag('div'); // row $output .= html_writer::end_tag('div'); // forumpost // Mark the forum post as read if required if ($istracked && !$CFG->forum_usermarksread && !$postisread) { forum_tp_mark_post_read($USER->id, $post, $forum->id); } if ($return) { return $output; } echo $output; return; }
function print_user_files($userid, $return = false) { global $CFG; if (!($submission = $this->get_submission($userid))) { return ''; } //Output user input Audio and Text, depending on assignment type. switch ($this->assignment->var3) { case OM_REPLYVOICEONLY: if (!empty($submission->data2)) { //print_simple_box(format_text('{FMS:VOICE='. $submission->data2.'}', FORMAT_HTML), 'center', '100%'); print_simple_box(format_text('{POODLL:type=audio,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%'); } else { echo "No Audio Found."; } break; case OM_REPLYVIDEOONLY: if (!empty($submission->data2)) { //print_simple_box(format_text('{FMS:VIDEO='. $submission->data2.'}', FORMAT_HTML), 'center', '100%'); print_simple_box(format_text('{POODLL:type=video,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%'); } else { echo "No Video Found."; } break; case OM_REPLYVOICETHENTEXT: if (!empty($submission->data2)) { //print_simple_box(format_text('{FMS:VOICE='. $submission->data2.'}', FORMAT_HTML), 'center', '100%'); print_simple_box(format_text('{POODLL:type=audio,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%'); print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount'); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, FORMAT_HTML))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, FORMAT_HTML))) . ')'; } } print_simple_box_end(); //print text print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%'); } else { echo "No Audio Found."; } break; case OM_REPLYVIDEOTHENTEXT: if (!empty($submission->data2)) { //print_simple_box(format_text('{FMS:VIDEO='. $submission->data2.'}', FORMAT_HTML), 'center', '100%'); print_simple_box(format_text('{POODLL:type=video,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%'); print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount'); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, FORMAT_HTML))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, FORMAT_HTML))) . ')'; } } print_simple_box_end(); //print text print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%'); } else { echo "No Video Found."; } break; case OM_REPLYTEXTONLY: default: print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount'); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, FORMAT_HTML))) . ')'; } else { if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, FORMAT_HTML))) . ')'; } } print_simple_box_end(); //print text print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%'); } //end of text and audio output switch }