Esempio n. 1
0
    if (!($chat = $DB->get_record('chat', array('id' => $chat->instance)))) {
        print_error('invalidid', 'chat');
    }
    if (has_capability('mod/chat:chat', $context)) {
        $params['id'] = $chat->id;
        $chattarget = new moodle_url("/mod/chat/gui_{$CFG->chat_method}/index.php", $params);
        $html .= '<tr><td><img src="../../mod/chat/pix/icon.png" width="16px" height="16px"> ';
        $html .= $OUTPUT->action_link($chattarget, $chat->name, new popup_action('click', $chattarget, "chat{$course->id}_{$chat->id}{$groupparam}", array('height' => 500, 'width' => 700)));
        //Create a link with a popout window for the chat.
        $html .= '</td></tr>';
    }
    //End if user can chat
}
//End if chat is setup for course.
//If Forums are setup for Groups, display links to them.
$html .= displayForums();
//Display the previous imported communication history
$html .= "</table><table><tr><td><u>Communication History</u><br/>";
foreach ($history as $history_item) {
    //Iterate through each imported type and display icon, link with time.
    $html .= "<img src='pix/" . $history_item->method . ".png' width='16px' heigh='16px' /> <a href='history_view.php?id=" . $history_item->id . "&p=" . $project->id . "'>" . userdate($history_item->date, get_string('strftimedatetime', 'langconfig')) . "</a> <br />";
}
$html .= "<br/> <a href='history_import.php?cmid=" . $id . "'>+ Import</a>";
//Display a link to import more conversations
$html .= "<br /><br />";
$html .= "</table></table>";
if ($currentgroup == 0 && !isset($adminpage)) {
    $content = $nogrouppage;
} else {
    if (isset($adminpage)) {
        $content = $adminpage;
Esempio n. 2
0
function checkForumParticpation($currentgroup, $alerts)
{
    global $DB, $USER, $COURSE, $CFG;
    $averages = $DB->get_record_sql('SELECT avg(coalesce(t1.msgchars,0)) as avgmsgsize
FROM
	(SELECT userid FROM `mdl_groups_members` WHERE groupid = ' . $currentgroup . ' ) t4
LEFT JOIN
	(SELECT t1.userid, sum(length(message)) as msgchars FROM `mdl_forum_posts` t1
LEFT JOIN `mdl_forum_discussions` t2
	ON t2.id = t1.discussion
	WHERE t2.groupid = ' . $currentgroup . '
	GROUP BY t1.userid) t1
	ON t4.userid = t1.userid');
    $config = get_config('project');
    $message = new stdClass();
    $message->size_small = $averages->avgmsgsize * ($config->smallmsg / 100);
    $message->size_medium = $averages->avgmsgsize * 1.0;
    $message->size_large = $averages->avgmsgsize * ($config->largemsg / 100);
    $charCount = new stdClass();
    $charCount = $DB->get_records_sql('SELECT t0.userid, coalesce(Schar,0) as Schar, coalesce(Mchar,0) as Mchar, coalesce(Lchar,0) as Lchar, coalesce(Tchar,0) as Tchar
FROM
(SELECT userid FROM `mdl_groups_members`
WHERE groupid = ' . $currentgroup . ' ) t0
LEFT JOIN
(SELECT t1.userid, sum(length(message)) as Schar
	FROM `mdl_forum_posts` t1
	LEFT JOIN `mdl_forum_discussions` t2
	ON t2.id = t1.discussion
	WHERE t2.groupid = ' . $currentgroup . ' AND length(message) < ' . $message->size_small . '
	GROUP BY t1.userid) t3
ON t0.userid = t3.userid
LEFT JOIN
(SELECT t4.userid, sum(length(message)) as Mchar
	FROM `mdl_forum_posts` t4
	LEFT JOIN `mdl_forum_discussions` t5
	ON t5.id = t4.discussion
	WHERE t5.groupid = ' . $currentgroup . ' AND length(message) BETWEEN ' . $message->size_small . '  AND ' . $message->size_large . '
	GROUP BY t4.userid) t6
ON t0.userid = t6.userid
LEFT JOIN
(SELECT t7.userid, sum(length(message)) as Lchar
	FROM `mdl_forum_posts` t7
	LEFT JOIN `mdl_forum_discussions` t8
	ON t8.id = t7.discussion
	WHERE t8.groupid = ' . $currentgroup . ' AND length(message) > ' . $message->size_large . '
	GROUP BY t7.userid) t9
ON t0.userid = t9.userid
LEFT JOIN
(SELECT t10.userid, sum(length(message)) as Tchar
	FROM `mdl_forum_posts` t10
	LEFT JOIN `mdl_forum_discussions` t11
	ON t11.id = t10.discussion
	WHERE t11.groupid = ' . $currentgroup . ' AND length(message) >= ' . $message->size_small . '
	GROUP BY t10.userid) t12
ON t0.userid = t12.userid
GROUP BY t0.userid');
    $stats = new stdClass();
    $stats = $DB->get_record_sql('SELECT sum(coalesce(t1.msgchars,0)) as sum
FROM
	(SELECT userid FROM `mdl_groups_members` WHERE groupid = ' . $currentgroup . ' ) t4
LEFT JOIN
	(SELECT t1.userid, sum(length(message)) as msgchars FROM `mdl_forum_posts` t1
LEFT JOIN `mdl_forum_discussions` t2
	ON t2.id = t1.discussion
	WHERE t2.groupid = ' . $currentgroup . ' AND length(message) > ' . $message->size_small . '
	GROUP BY t1.userid) t1
	ON t4.userid = t1.userid');
    //Get number of group members
    $numMembers = $DB->count_records('groups_members', array('groupid' => $currentgroup));
    $stats->avg = $stats->sum / $numMembers;
    $stats->low = $stats->avg * ($config->lowthreshold / 100);
    $stats->high = $stats->avg * ($config->highthreshold / 100);
    //var_dump($stats);
    $low_participators = array();
    foreach ($charCount as $member) {
        if ($member->tchar < $stats->low) {
            $member->alert = "Low";
            $low_participators[$member->userid] = studentidToName($member->userid);
        } else {
            if ($member->tchar > $stats->high) {
                $member->alert = "High";
            } else {
                $member->alert = null;
            }
        }
    }
    //$charCount[$USER->id]->alert = "High";
    //var_dump($charCount);
    if (!empty($charCount[$USER->id]->alert)) {
        if ($charCount[$USER->id]->alert == "High") {
            if ($alerts->forum_alert + $config->highforumalertsfreq * 60 * 60 * 24 > time()) {
                return;
            }
            $msg = $USER->firstname . ", you are contributing really a lot to the group forums! This is great! <br /><br />\n\t\t\t\tHowever, for the group project to be successful, it would be important to get other members' ideas, concerns and thoughts as well. <br /><br />\n\t\t\t\tYou would be a good leader for your group! Try to improve your leadership skills by trying to incorporate others in the discussion, especially ";
            $msg .= rtrim(displayUsersAsText($low_participators), ", ");
            $msg .= " who are not participating as much!";
            $alert_icon = "info.png";
        } else {
            if ($alerts->forum_alert + $config->lowforumalertsfreq * 60 * 60 * 24 > time()) {
                return;
            }
            $msg = $USER->firstname . ", it seems that you have not contributed much to the group forums so far. <br /><br />\n\t\t\tFor the group project to be successful, it is important that each team member contributes to the discussions. Try to share some ideas, concerns or thoughts with your team members by posting to the discussion forum! <br /><br />\n\t\t\tYou can access the current discussions here: ";
            $msg .= "<br /><br /><u>" . displayForums() . "</u>";
            $alert_icon = "alert_icon.png";
        }
        $html = '<div id="dialog-message" title="' . $charCount[$USER->id]->alert . ' Forum Participation Alert!">
			  <p>
				<span  style="float:left; margin:0 7px 10px 0;"><img src="' . $CFG->wwwroot . '/mod/project/pix/' . $alert_icon . '" width="32px" height="32px" /></span>
				' . $msg . '
			  </p>
			</div>
			<script>
			  $(function() {
				$( "#dialog-message" ).dialog({
				  modal: true,
				  buttons: {
					Ok: function() {
					  $( this ).dialog( "close" );
					}
				  }
				});
			  });
			  </script>';
        add_to_log($COURSE->id, 'project', 'alert-forum', $charCount[$USER->id]->alert);
        echo $html;
        $DB->set_field('project_user_mapping', 'forum_alert', time(), array('user_id' => $USER->id));
    }
    //end if alert check
}