Exemplo n.º 1
0
function mediaboard_show_slide($p)
{
    global $id, $course, $USER, $searchtext, $CFG, $DB, $OUTPUT, $cm, $mediaboard;
    $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
    echo $OUTPUT->box_start('generalbox');
    $data_ = $DB->get_record("mediaboard_files", array("id" => $p));
    if ($item = $DB->get_record("mediaboard_items", array("fileid" => $p, "type" => "photo"))) {
        if (mediaboard_isiphone()) {
            $fmslink2 = new moodle_url("/mod/mediaboard/html5mediaboard_iphone.php", array("id" => $item->id));
        } else {
            $fmslink2 = new moodle_url("/mod/mediaboard/html5mediaboard.php", array("id" => $item->id));
        }
        $fmshtml2 = '<div style="margin: 10px;"><h3><a href="view.php?id=' . $id . '&p=' . $data_->id . '">' . $data_->name . '</a></h3></div>' . '<iframe src="' . $fmslink2 . '" style="border: medium none;" height="433px" scrolling="no" width="508px">
  &lt;p&gt;Your browser does not support iframes.&lt;/p&gt;
           </iframe>';
        $height = "200px";
    } else {
        $fmshtml2 = '<div style="margin: 10px;"><h3><a href="view.php?id=' . $id . '&p=' . $data_->id . '">' . $data_->name . '</a></h3></div>';
        $height = "100px";
        $fmshtml2 .= html_writer::tag('div', mediaboard_player($data_->id));
    }
    $fmshtml = "";
    $fmshtml .= '<div style="padding:20px 0 20px 0;">';
    $datauser = $DB->get_record("user", array("id" => $data_->userid));
    $picture = $OUTPUT->user_picture($datauser, array($course->id));
    $fmshtml .= '<div><div style="background-color: #eee;padding: 10px;">
    <div style="float:left;margin: 0 20px 0 0">' . $picture . '</div><div style="float:left;"><strong><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $id . '&course=' . $course->id . '">' . fullname($datauser) . " ({$datauser->username})</a></strong><br />";
    if ($data_->userid == $USER->id) {
        $fmshtml .= '<a href="view.php?id=' . $id . '&delete=' . $data_->id . '" onclick="return confirm(\'Are you sure you want to delete?\')">' . get_string('mediaboard_delete', 'mediaboard') . '</a>&nbsp;&nbsp;
        <a href="edit.php?id=' . $id . '&idrec=' . $data_->id . '">' . get_string('mediaboard_edit_title', 'mediaboard') . '</a> &nbsp;&nbsp;';
    } else {
        if (has_capability('mod/mediaboard:teacher', $contextmodule)) {
            $fmshtml .= '<a href="view.php?id=' . $id . '&delete=' . $data_->id . '" onclick="return confirm(\'Are you sure you want to delete?\')">' . get_string('mediaboard_delete', 'mediaboard') . '</a>&nbsp;&nbsp;';
        }
    }
    if ($data_->multiplechoicequestions != "no") {
        $fmshtml .= '<a href="question_test.php?id=' . $id . '&p=' . $data_->id . '" target="questionpreview" onclick="this.target=\'questionpreview\'; return openpopup(\'/mod/mediaboard/question_test.php?id=' . $id . '&p=' . $data_->id . '\', \'questionpreview\', \'scrollbars=yes,resizable=yes,width=600,height=700\', 0);">' . get_string('mediaboard_questions', 'mediaboard') . '</a>&nbsp;&nbsp;';
    } else {
        if ($USER->id == $data_->userid) {
            $fmshtml .= '<a href="questions.php?id=' . $id . '&p=' . $data_->id . '">' . get_string('mediaboard_questionsadd', 'mediaboard') . '</a>&nbsp;&nbsp;';
        }
    }
    if ($data_->file != "no") {
        $fmshtml .= '<a href="' . $CFG->wwwroot . '/mod/mediaboard/file.php?/presentation/' . $course->id . '/' . $data_->id . '/' . $data_->file . '">' . get_string('mediaboard_ppt', 'mediaboard') . '</a>&nbsp;&nbsp;';
    }
    $comments = $DB->count_records("mediaboard_comments", array("fileid" => $data_->id));
    $fmshtml .= '<a href="view.php?id=' . $id . '&p=' . $data_->id . '#comments">' . get_string('mediaboard_comments', 'mediaboard', $comments) . '</a>&nbsp;&nbsp;';
    if (has_capability('mod/mediaboard:teacher', $contextmodule) && $mediaboard->grademethod == "default") {
        $catdata = $DB->get_record("grade_items", array("courseid" => $cm->course, "iteminstance" => $cm->instance, "itemmodule" => 'mediaboard'));
        if ($grid = $DB->get_record("grade_grades", array("itemid" => $catdata->id, "userid" => $data_->userid))) {
            $rateteacher = round($grid->finalgrade, 1);
        }
        $levels = array("-");
        for ($i = 1; $i <= $catdata->grademax; $i++) {
            $levels[] = $i;
        }
        if ($currentr = $DB->get_record("mediaboard_ratings", array("fileid" => $data_->id, "userid" => $USER->id))) {
            $cr = $currentr->rating;
        } else {
            $cr = '';
        }
        $fmshtml .= '</div><div style="float:left;margin: 0 0 0 20px">Grade: </div> <div style="float:left;">' . html_writer::select($levels, 'rating', $cr, true, array("class" => "mediaboard_rate_box", "data-url" => "{$data_->id}")) . '</div>  <div style="float:right;"><small>' . date("F d, Y @ H:i", $data_->timemodified) . '</small></div>  <div style="clear:both;"></div></div></div></div>';
    } else {
        if ($mediaboard->grademethod == "like") {
            /*
             * !!!!! ???????? LIKE ? ?????????
             */
            $fileid = $data_->id;
            $deletelike = "";
            $o = "";
            if (has_capability('mod/mediaboard:teacher', $contextmodule)) {
                $deletelike = html_writer::tag('div', html_writer::link(new moodle_url('/mod/mediaboard/deletelikes.php', array("id" => $cm->id, "a" => "delete", "fileid" => $fileid)), get_string("delete", "mediaboard")));
            }
            if ($crlike = $DB->count_records("mediaboard_likes", array("fileid" => $fileid))) {
                $o .= html_writer::tag('div', $crlike, array('class' => 'vs-like-grade'));
            }
            //. " " . $deletelike;
            if ($crlike = $DB->get_record("mediaboard_likes", array("fileid" => $fileid, "userid" => $USER->id))) {
                $o .= html_writer::link(new moodle_url('/mod/mediaboard/view.php', array("id" => $id, "p" => $fileid, "act" => "dellike")), html_writer::empty_tag("img", array("src" => new moodle_url('/mod/mediaboard/img/flike.png'), "alt" => get_string("likethis", "mediaboard"), "title" => get_string("dislike", "mediaboard"), "class" => "vs-like-dis")));
            } else {
                $o .= html_writer::link(new moodle_url('/mod/mediaboard/view.php', array("id" => $id, "p" => $fileid, "act" => "addlike")), html_writer::empty_tag("img", array("src" => new moodle_url('/mod/mediaboard/img/flike.png'), "alt" => get_string("likethis", "mediaboard"), "title" => get_string("like", "mediaboard"))));
            }
            $fmshtml .= '</div><div style="float:left;">' . $o . '</div><div style="clear:both;"></div>  <div style="float:right;"><small>' . date("F d, Y @ H:i", $data_->timemodified) . '</small></div>  <div style="clear:both;"></div></div></div></div>';
        } else {
            $fmshtml .= '</div><div style="clear:both;"></div>  <div style="float:right;"><small>' . date("F d, Y @ H:i", $data_->timemodified) . '</small></div>  <div style="clear:both;"></div></div></div></div>';
        }
    }
    $fmshtml .= $fmshtml2;
    //$fmshtml .= '</div><div style="height:'.$height.';">'.$picture .'</div></div><div style="clear:both;"></div>';
    $fmshtml .= '<div style="background-color:#eaf0df">' . $OUTPUT->box_start('generalbox');
    if (strstr($data_->text, "{FMS:MEDIABOARD=")) {
        $data_->text = str_replace("{FMS:MEDIABOARD=" . $fmslink . "}", $fmshtml, $data_->text);
    } else {
        $data_->text = $fmshtml . "<br />" . format_text($data_->text);
    }
    if ($searchtext) {
        $data_->text = str_replace($searchtext, '<strong>' . $searchtext . '</strong>', $data_->text);
    }
    echo $data_->text;
    echo $OUTPUT->box_end() . "</div>";
    echo $OUTPUT->box_end();
}
Exemplo n.º 2
0
/*
$lists = $DB->get_records ("mediaboard_files", array("userid" => $user->id), 'time DESC');

foreach ($lists as $list) {
  if ($cml = get_coursemodule_from_id('mediaboard', $list->instance)) {
    if ($cml->course == $cm->course && $cml->instance == $cm->instance) {
      
    }
  }
}
*/

if ($data = $DB->get_records("mediaboard_files", array("instance"=>$cm->id, "userid"=>$user->id))){
  foreach($data as $data_){
    if ($item = $DB->get_record("mediaboard_items", array("fileid"=>$data_->id))) {
        if (mediaboard_isiphone())
          $fmslink2 = new moodle_url("/mod/mediaboard/html5mediaboard_iphone.php", array("id"=>$item->id));
        else
          $fmslink2 = new moodle_url("/mod/mediaboard/html5mediaboard.php", array("id"=>$item->id));
          
        $fmshtml2 = '<iframe src="'.$fmslink2.'" style="border: medium none;" height="433px" scrolling="no" width="508px">
  &lt;p&gt;Your browser does not support iframes.&lt;/p&gt;
           </iframe>';
        
        $height = "200px";
    } else {
        $fmshtml2 = '<div style="margin: 10px;"><h3><a href="view.php?id='.$id.'&p='.$data_->id.'">'.$data_->name.'</a></h3></div>';
        $height = "100px";
        $fmshtml2 .= html_writer::tag('div', mediaboard_player($data_->id));
    }