Beispiel #1
0
require_once '../../include/baseTheme.php';
require_once 'include/course_settings.php';

$is_link = false;

if ($_GET['rtype'] == 'blogpost') {
	$setting_id = SETTING_BLOG_RATING_ENABLE;
} elseif ($_GET['rtype'] == 'course') {
    $setting_id = SETTING_COURSE_RATING_ENABLE;
} elseif ($_GET['rtype'] == 'forum_post') {
    $setting_id = SETTING_FORUM_RATING_ENABLE;
} elseif ($_GET['rtype'] == 'link') {
    $is_link = true; //there is no rating setting for social bookmarks, rating is always enabled
}

if ($is_link || setting_get($setting_id, $course_id) == 1) {
    if (Rating::permRate($is_editor, $uid, $course_id, $_GET['rtype'])) {
        $widget = $_GET['widget'];
        $rtype = $_GET['rtype'];
        $rid = intval($_GET['rid']);
        $value = intval($_GET['value']);
        
        //response array
        $response = array();
        
        $rating = new Rating($widget, $rtype, $rid);
        $had_rated = $rating->userHasRated($uid);
        $action = $rating->castRating($value, $uid);
        
        if ($widget == 'up_down') {
            $up_value = $rating->getUpRating();
Beispiel #2
0
 /**
  * Check if a user has permission to rate course resources
  * @param isEditor boolean showing if user is teacher
  * @param uid the user id
  * @param courseId the course id
  * @return boolean
  */
 public static function permRate($isEditor, $uid, $courseId, $rtype)
 {
     if ($rtype == 'course') {
         if (course_status($courseId) == COURSE_OPEN and setting_get(SETTING_COURSE_ANONYMOUS_RATING_ENABLE, $courseId) == 1) {
             return true;
         }
     }
     if ($isEditor) {
         //teacher is always allowed to rate
         return true;
     } else {
         //students allowed to rate
         $sql = "SELECT COUNT(`user_id`) as c FROM `course_user` WHERE `course_id` = ?d AND `user_id` = ?d";
         $result = Database::get()->querySingle($sql, $courseId, $uid);
         if ($result->c > 0) {
             //user is course member
             return true;
         } else {
             //user is not course member
             return false;
         }
     }
 }
Beispiel #3
0
 
 if (setting_get(SETTING_BLOG_STUDENT_POST, $course_id) == 1) {
     $checkTeach = "";
     $checkStud = "checked ";
 } else {
     $checkTeach = "checked ";
     $checkStud = "";
 }
 if (setting_get(SETTING_BLOG_COMMENT_ENABLE, $course_id) == 1) {
 	$checkCommentDis = "";
 	$checkCommentEn = "checked ";
 } else {
 	$checkCommentDis = "checked ";
 	$checkCommentEn = "";
 }
 if (setting_get(SETTING_BLOG_RATING_ENABLE, $course_id) == 1) {
 	$checkRatingDis = "";
 	$checkRatingEn = "checked ";
 } else {
 	$checkRatingDis = "checked ";
 	$checkRatingEn = "";
 }
 if (!$sharing_allowed) {
     $sharing_radio_dis = " disabled";
     $sharing_dis_label = "<tr><td><em>";
     if (!get_config('enable_social_sharing_links')) {
         $sharing_dis_label .= $langSharingDisAdmin;
     }
     if (course_status($course_id) != COURSE_OPEN) {
         $sharing_dis_label .= " ".$langSharingDisCourse;
     }
Beispiel #4
0
$main_content .= "</div>";

if (!empty($addon)) {
    $main_content .= "<div class='course_info'><h1>$langCourseAddon</h1><p>$addon</p></div>";
}
if (setting_get(SETTING_COURSE_COMMENT_ENABLE, $course_id) == 1) {
    commenting_add_js();
    $comm = new Commenting('course', $course_id);
    $main_content .= $comm->put($course_code, $is_editor, $uid);
}
if (setting_get(SETTING_COURSE_RATING_ENABLE, $course_id) == 1) {
    $rating = new Rating('fivestar', 'course', $course_id);
    $rating_content = $rating->put($is_editor, $uid, $course_id);
}
if (is_sharing_allowed($course_id)) {
    if (setting_get(SETTING_COURSE_SHARING_ENABLE, $course_id) == 1) {
        $social_content = print_sharing_links($urlServer."courses/$course_code", $currentCourseName);
    }
}
$panel_footer = "";
if(isset($rating_content) || isset($social_content)) {
    $panel_footer .= "                
                <div class='panel-footer'>
                    <div class='row'>";
    if(isset($rating_content)){
     $panel_footer .=
            "<div class='col-sm-6'>
                $rating_content
            </div>";       
    }
    if(isset($social_content)){
Beispiel #5
0
* ======================================================================== */
$require_current_course = TRUE;

require_once '../../include/baseTheme.php';
require_once 'include/course_settings.php';
require_once 'class.comment.php';
require_once 'class.commenting.php';


if ($_POST['rtype'] == 'blogpost') {
    $setting_id = SETTING_BLOG_COMMENT_ENABLE;
} elseif ($_POST['rtype'] == 'course') {
    $setting_id = SETTING_COURSE_COMMENT_ENABLE;
}

if (setting_get($setting_id, $course_id) == 1) {
    //response array
    //[0] -> status, [1] -> message, other positions -> other data 
    $response = array();
    
    if ($_POST['action'] == 'new') {
        if (Commenting::permCreate($is_editor, $uid, $course_id)) {
            $comment = new Comment();
            if ($comment->create($_POST['commentText'], $uid, $_POST['rtype'], intval($_POST['rid']))) {
                $post_actions = '<div class="pull-right">';
                $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$course_code.'\', \'editLoad\', '.$_POST['rid'].', \''.$_POST['rtype'].'\', \'\', '.$comment->getId().')">';
                $post_actions .= icon('fa-edit', $langModify).'</a> ';
                $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$course_code.'\', \'delete\', '.$_POST['rid'].', \''.$_POST['rtype'].'\', \''.$langCommentsDelConfirm.'\', '.$comment->getId().')">';
                $post_actions .= icon('fa-times', $langDelete).'</a>';
                $post_actions .='</div>';   
                
Beispiel #6
0
require_once 'include/action.php';
$action = new action();
$action->record(MODULE_ID_GROUPS);
/* * *********************************** */

$toolName = $langGroups;
$totalRegistered = 0;
unset($message);

unset($_SESSION['secret_directory']);
unset($_SESSION['forum_id']);

$user_groups = user_group_info($uid, $course_id);

//check if social bookmarking is enabled for this course
$social_bookmarks_enabled = setting_get(SETTING_COURSE_SOCIAL_BOOKMARKS_ENABLE, $course_id);

if ($is_editor) {

	if (isset($_GET['urlview'])) {
		$urlview = urlencode($_GET['urlview']);
	} else {
		$urlview = '';
	}
	
	if (isset($_GET['socialview'])) {
		$socialview = true;
		$socialview_param = '&amp;socialview';
	} else {
		$socialview = false;
		$socialview_param = '';
Beispiel #7
0
        $checkAnonRatingDis = '';
        $checkAnonRatingEn = 'checked ';
    } else {
        $checkAnonRatingDis = 'checked ';
        $checkAnonRatingEn = '';
    }
    // USER COMMENTS
    if (setting_get(SETTING_COURSE_COMMENT_ENABLE, $course_id) == 1) {
        $checkCommentDis = "";
        $checkCommentEn = "checked ";
    } else {
        $checkCommentDis = "checked ";
        $checkCommentEn = "";
    }
    // ABUSE REPORT
    if (setting_get(SETTING_COURSE_ABUSE_REPORT_ENABLE, $course_id) == 1) {
        $checkAbuseReportDis = "";
        $checkAbuseReportEn = "checked ";
    } else {
        $checkAbuseReportDis = "checked ";
        $checkAbuseReportEn = "";
    }    
    $tool_content .= "<div class='form-wrapper'>
	<form class='form-horizontal' role='form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code' onsubmit='return validateNodePickerForm();'>
	<fieldset>
	<div class='form-group'>
            <label for='fcode' class='col-sm-2 control-label'>$langCode</label>
            <div class='col-sm-10'>
                <input type='text' class='form-control' name='fcode' id='fcode' value='$public_code'>
            </div>
        </div>
Beispiel #8
0
/**
 * display available links (if any)
 * @global type $id
 * @global type $course_id
 * @global type $course_code
 * @global type $tool_content
 * @global type $langNoCategory
 * @global type $langCategorisedLinks
 * @global type $langComments
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoLinksExist
 * @global type $langLinks
 * @global type $course_code
 */
function list_links() {
    global $id, $course_id, $course_code, $tool_content,
    $langNoCategory, $langCategorisedLinks, $langDescr, $langAddModulesButton,
    $langChoice, $langNoLinksExist, $langLinks, $course_code, $langSocialCategory;
    
    $result = Database::get()->queryArray("SELECT * FROM link WHERE course_id = ?d", $course_id);
    if (count($result) == 0) {
        $tool_content .= "<div class='alert alert-warning'>$langNoLinksExist</div>";
    } else {
        $tool_content .= "<form action='insert.php?course=$course_code' method='post'>
				<input type='hidden' name='id' value='$id' />" .
                "<table class='table-default'>" .
                "<tr class='list-header'>" .
                "<th class='text-left' style='width:'>&nbsp;$langLinks</th>" .
                "<th class='text-left'>$langDescr</th>" .
                "<th width='10'>$langChoice</th>" .
                "</tr>";
        $sql = Database::get()->queryArray("SELECT * FROM link_category WHERE course_id = ?d", $course_id);
        if (count($sql) > 0) {
                        
            foreach ($sql as $catrow) {
                $tool_content .= "<tr>";
                $tool_content .= "<td><b>".icon('fa-folder-o')."&nbsp;".
                        q($catrow->name) . "</b></td>";
                $tool_content .= "<td >" . standard_text_escape($catrow->description) . "</td>";
                $tool_content .= "<td class='text-center'><input type='checkbox' name='catlink[]' value='$catrow->id' /></td>";
                $tool_content .= "</tr>";
                $sql2 = Database::get()->queryArray("SELECT * FROM link WHERE course_id = ?d AND category = ?d", $course_id, $catrow->id);                
                foreach ($sql2 as $linkcatrow) {
                    $tool_content .= "<tr>";
                    $tool_content .= "<td>&nbsp;&nbsp;&nbsp;&nbsp;".icon('fa-link')."&nbsp;&nbsp;<a href='" . q($linkcatrow->url) . "' target='_blank'>" .
                            q(($linkcatrow->title == '') ? $linkcatrow->url : $linkcatrow->title) . "</a></td>";
                    $tool_content .= "<td>" . standard_text_escape($linkcatrow->description) . "</td>";
                    $tool_content .= "<td class='text-center'><input type='checkbox' name='link[]' value='$linkcatrow->id' /></td>";
                    $tool_content .= "</tr>";
                }
            }
        }
        $result = Database::get()->queryArray("SELECT * FROM link WHERE course_id = ?d AND category = 0", $course_id);
        $linkinfo = array();        
        foreach ($result as $row) {
            $linkinfo[] = array(
                'id' => $row->id,
                'url' => $row->url,
                'title' => ($row->title == '') ? $row->url : $row->title,
                'comment' => $row->description,
                'category' => $row->category);
        }
        if (count($linkinfo) > 0) {
            $tool_content .= "<tr>" .
                    "<td colspan='3'><b>$langNoCategory</b></td>" .
                    "</tr>";
            foreach ($linkinfo as $entry) {
                $tool_content .= "<tr>" .
                        "<td>&nbsp;&nbsp;&nbsp;&nbsp;".icon('fa-link')."&nbsp;&nbsp;<a href='" . q($entry['url']) . "' target=_blank>" . q($entry['title']) . "</a></td>" .
                        "<td>" . standard_text_escape($entry['comment']) . "</td>" .
                        "<td class='text-center'><input type='checkbox' name='link[]' value='$entry[id]' /></td>";
                "</tr>";
            }
        }
        if (setting_get(SETTING_COURSE_SOCIAL_BOOKMARKS_ENABLE, $course_id) == 1) {
            $result = Database::get()->queryArray("SELECT * FROM link WHERE course_id = ?d AND category = -2", $course_id);
            $linkinfo = array();
            foreach ($result as $row) {
                $linkinfo[] = array(
                        'id' => $row->id,
                        'url' => $row->url,
                        'title' => ($row->title == '') ? $row->url : $row->title,
                        'comment' => $row->description,
                        'category' => $row->category);
            }
            if (count($linkinfo) > 0) {
                $tool_content .= "<tr>" .
                        "<td colspan='3'><b>$langSocialCategory</b></td>" .
                        "</tr>";
                foreach ($linkinfo as $entry) {
                    $tool_content .= "<tr>" .
                            "<td>&nbsp;&nbsp;&nbsp;&nbsp;".icon('fa-link')."&nbsp;&nbsp;<a href='" . q($entry['url']) . "' target=_blank>" . q($entry['title']) . "</a></td>" .
                            "<td>" . standard_text_escape($entry['comment']) . "</td>" .
                            "<td class='text-center'><input type='checkbox' name='link[]' value='$entry[id]' /></td>";
                    "</tr>";
                }
            } 
        }
        $tool_content .= "</table>";
        $tool_content .= "<div class='text-right'>" .
                "<input class='btn btn-primary' type='submit' name='submit_link' value='$langAddModulesButton' /></div></form>";
    }
}
Beispiel #9
0
/**
 * Check if flag should be shown or not
 * @param string $rtype
 * @param int $rid
 * @param int $course_id
 * @param int $uid
 * @param boolean $is_editor
 * @return boolean
 */
function abuse_report_show_flag ($rtype, $rid, $course_id, $is_editor) {
    
    global $uid;
    if ($uid == 0) { //do not show for not logged in users
        return false;
    }

    if (setting_get(SETTING_COURSE_ABUSE_REPORT_ENABLE, $course_id) != 1) { // abuse report disabled for course
        return false;
    } elseif ($is_editor) { //do not show for editor
        return false;
    } else {
        //check if there is already an open report for this resource from this user
        $result = Database::get()->querySingle("SELECT COUNT(`id`) AS c FROM `abuse_report` WHERE `rtype` = ?s 
                AND `rid` = ?d AND `user_id` = ?d AND `status` = ?d", $rtype, $rid, $_SESSION['uid'], 1);
        if ($result->c != 0) {
            return false;
        }
        
        //check for each resource type if resource exists and user is author
        if ($rtype == 'comment') {
            $result = Database::get()->querySingle("SELECT `user_id` FROM `comments` WHERE `id` = ?d", $rid);
            if ($result) {
                if ($result->user_id == $_SESSION['uid']) {
                    return false;
                }
            } else {
                return false;
            }
        } elseif ($rtype == 'forum_post') {
            $result = Database::get()->querySingle("SELECT `poster_id` FROM `forum_post` WHERE `id` = ?d", $rid);
            if ($result) {
                if ($result->poster_id == $_SESSION['uid']) {
                    return false;
                }
            } else {
                return false;
            }
        } elseif ($rtype == 'link') {
            $result = Database::get()->querySingle("SELECT `user_id` FROM `link` WHERE `id` = ?d", $rid);
            if ($result) {
                if ($result->user_id == $_SESSION['uid']) {
                    return false;
                }
            } else {
                return false;
            }
        } else { //unknown rtype
            return false;
        }
    }
    
    return true;
}
Beispiel #10
0
                             <textarea class='form-control' rows='5' name='description'>$form_description</textarea>
                         </div>
                     </div>
                     <div class='form-group'>
                         <div class='col-sm-10 col-sm-offset-2'>
                             <input type='submit' class='btn btn-primary' name='submitCategory' value='$form_legend' />
                             <a href='$_SERVER[SCRIPT_NAME]?course=$course_code' class='btn btn-default'>$langCancel</a>
                         </div>
                     </div>
                     </fieldset>
                  ". generate_csrf_token_form_field() ."
                 </form>
             </div>";
 } elseif ($action == 'settings') {
     $navigation[] = array('url' => "$_SERVER[SCRIPT_NAME]?course=$course_code", 'name' => $langLinks);
     if (setting_get(SETTING_COURSE_SOCIAL_BOOKMARKS_ENABLE, $course_id) == 1) {
         $checkDis = "";
         $checkEn = "checked ";
     } else {
         $checkDis = "checked ";
         $checkEn = "";
     }
     $tool_content .= "<div class = 'form-wrapper'>";
     $tool_content .= "<form class = 'form-horizontal' role='form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code'>";
     $tool_content .= "<fieldset>                               
                           <div class='form-group'>
                               <label class='col-sm-3'>$langSocialBookmarksFunct</label>
                               <div class='col-sm-9'> 
                                   <div class='radio'>
                                       <label>
                                           <input type='radio' value='1' name='settings_radio' $checkEn>$langActivate
Beispiel #11
0
         }
     } else {
         $user_stats[$myrow->poster_id] = '';
     }
 }
 $tool_content .= "<td valign='top'>" . display_user($myrow->poster_id) . $user_stats[$myrow->poster_id] . "</td>";
 $message = $myrow->post_text;
 // support for math symbols
 $message = mathfilter($message, 12, "../../courses/mathimg/");
 if ($count == 0) {
     $postTitle = "<b>{$langPostTitle}: </b>" . q($topic_subject);
 } else {
     $postTitle = "";
 }
 $rate_str = "";
 if (setting_get(SETTING_FORUM_RATING_ENABLE, $course_id)) {
     $rating = new Rating('thumbs_up', 'forum_post', $myrow->id);
     $rate_str = $rating->put($is_editor, $uid, $course_id);
 }
 $anchor_link = "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;topic={$topic}&amp;forum={$forum}&amp;post_id={$myrow->id}#{$myrow->id}'>#{$myrow->id}</a><br/>";
 if ($myrow->parent_post_id == -1) {
     $parent_post_link = "<br/>{$langForumPostParentDel}";
 } elseif ($myrow->parent_post_id != 0) {
     $parent_post_link = "{$langForumPostParent}<a href='viewtopic.php?course={$course_code}&amp;topic={$topic}&amp;forum={$forum}&amp;post_id={$myrow->parent_post_id}#{$myrow->parent_post_id}'>#{$myrow->parent_post_id}</a><br/><br/>";
 } else {
     $parent_post_link = "";
 }
 $tool_content .= "<td>\n\t  <div>\n\t    <a name='" . $myrow->id . "'></a>" . $anchor_link;
 $tool_content .= "<b>{$langSent}: </b>" . $myrow->post_time . "<br>{$postTitle}\n\t  </div>\n\t  <br />{$message}<br />" . $parent_post_link . $rate_str . "\n\t</td>";
 $dyntools = !$is_editor ? array() : array(array('title' => $langModify, 'url' => "editpost.php?course={$course_code}&amp;post_id=" . $myrow->id . "&amp;topic={$topic}&amp;forum={$forum}", 'icon' => 'fa-edit'), array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;post_id={$myrow->id}&amp;topic={$topic}&amp;forum={$forum}&amp;delete=on", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmDelete));
 if ($topic_locked != 1) {
Beispiel #12
0
 if (course_status($course_id) != COURSE_OPEN) {
     $radio_dis = ' disabled';
     $rating_dis_label = $langRatingAnonDisCourse;
 } else {
     $radio_dis = '';
     $rating_dis_label = '';
 }
 if (setting_get(SETTING_COURSE_ANONYMOUS_RATING_ENABLE, $course_id) == 1) {
     $checkDis = '';
     $checkEn = 'checked ';
 } else {
     $checkDis = 'checked ';
     $checkEn = '';
 }
 // USER COMMENTS
 if (setting_get(SETTING_COURSE_COMMENT_ENABLE, $course_id) == 1) {
     $checkDis = "";
     $checkEn = "checked ";
 } else {
     $checkDis = "checked ";
     $checkEn = "";
 }
 $tool_content .= "<div class='form-wrapper'>\n\t<form class='form-horizontal' role='form' method='post' action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' onsubmit='return validateNodePickerForm();'>\n\t<fieldset>\n\t<div class='form-group'>\n            <label for='fcode' class='col-sm-2 control-label'>{$langCode}</label>\n            <div class='col-sm-10'>\n                <input type='text' class='form-control' name='fcode' id='fcode' value='{$public_code}'>\n            </div>\n        </div>\n        <div class='form-group'>\t    \n            <label for='title' class='col-sm-2 control-label'>{$langCourseTitle}:</label>\n            <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='title' id='title' value='" . q($title) . "'>\n\t    </div>\n        </div>\n        <div class='form-group'>\n            <label for='titulary' class='col-sm-2 control-label'>{$langTeachers}:</label>\n            <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='titulary' id='titulary' value='{$titulary}'>\n\t    </div>\n        </div>\n        <div class='form-group'>\n\t    <label for='Faculty' class='col-sm-2 control-label'>{$langFaculty}:</label>\n            <div class='col-sm-10'>";
 $allow_only_defaults = get_config('restrict_teacher_owndep') && !$is_admin ? true : false;
 list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $course->getDepartmentIds($c->id), 'allow_only_defaults' => $allow_only_defaults));
 $head_content .= $js;
 $tool_content .= $html;
 @($tool_content .= "</div></div>\n\t    <div class='form-group'>\n\t\t<label for='course_keywords' class='col-sm-2 control-label'>{$langCourseKeywords}</label>\n\t\t<div class='col-sm-10'>\n                    <input type='text' class='form-control' name='course_keywords' id='course_keywords' value='{$course_keywords}'>\n                </div>\n\t    </div>        \n\t    <div class='form-group'>\n                <label class='col-sm-2 control-label'>{$langCourseFormat}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='simple' id='simple'" . ($c->view_type == "simple" ? " checked" : "") . ">\n                        {$langCourseSimpleFormat}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='units' id='units'" . ($c->view_type == "units" ? " checked" : "") . ">\n                        {$langWithCourseUnits}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='weekly' id='weekly'" . ($c->view_type == "weekly" ? " checked" : "") . ">\n                        {$langCourseWeeklyFormat}\n                      </label>\n                    </div>                         \n                </div>                    \n            </div>\n            <div class='form-group'>\n                <div class='col-sm-10 col-sm-offset-2' id='weeklyDates'>\n                        {$langStartDate} \n                        <input class='dateInForm form-control' type='text' name='start_date' value='" . ($c->start_date != "0000-00-00" ? $c->start_date : "") . "' readonly>                       \n                        {$langEndDate}\n                        <input class='dateInForm form-control' type='text' name='finish_date' value='" . ($c->finish_date != "0000-00-00" ? $c->finish_date : "") . "' readonly>\n                </div>\n            </div>");
 if ($isOpenCourseCertified) {
     $tool_content .= "<input type='hidden' name='course_license' value='{$course_license}'>";
 }