function checkImportedParticpation($currentgroup, $alerts) { global $DB, $CFG, $COURSE, $USER; $averages = $DB->get_record_sql('SELECT avg(coalesce(t3.msgchars,0)) as avgmsgsize FROM (SELECT user_id, coalesce(length(message),0) as msgchars FROM (SELECT userid FROM `mdl_groups_members` WHERE groupid = ' . $currentgroup . ') t0 LEFT JOIN `mdl_project_user_mapping` t1 ON t0.userid = t1.user_id LEFT JOIN `mdl_project_history_imp_detail` t2 ON t2.user = t1.skype WHERE group_id = ' . $currentgroup . ' ) t3'); $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 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 user_id, sum(length(message)) as Schar FROM `mdl_project_history_imp_detail` t1 LEFT JOIN `mdl_project_user_mapping` t2 ON t1.user = t2.skype WHERE group_id = ' . $currentgroup . ' AND length(message) < ' . $message->size_small . ' GROUP BY user_id) t3 ON t0.userid = t3.user_id LEFT JOIN (SELECT user_id, sum(length(message)) as Mchar FROM `mdl_project_history_imp_detail` t4 LEFT JOIN `mdl_project_user_mapping` t5 ON t4.user = t5.skype WHERE group_id = ' . $currentgroup . ' AND length(message) BETWEEN ' . $message->size_small . ' AND ' . $message->size_large . ' GROUP BY user_id) t6 ON t0.userid = t6.user_id LEFT JOIN (SELECT user_id, sum(length(message)) as Lchar FROM `mdl_project_history_imp_detail` t7 LEFT JOIN `mdl_project_user_mapping` t8 ON t7.user = t8.skype WHERE group_id = ' . $currentgroup . ' AND length(message) > ' . $message->size_large . ' GROUP BY user_id) t9 ON t0.userid = t9.user_id LEFT JOIN (SELECT user_id, sum(length(message)) as Tchar FROM `mdl_project_history_imp_detail` t10 LEFT JOIN `mdl_project_user_mapping` t11 ON t10.user = t11.skype WHERE group_id = ' . $currentgroup . ' AND length(message) >= ' . $message->size_small . ' GROUP BY user_id) t12 ON t0.userid = t12.user_id'); $stats = new stdClass(); $stats = $DB->get_record_sql('SELECT sum(coalesce(t3.msgchars,0)) as sum FROM (SELECT user_id, coalesce(length(message),0) as msgchars FROM (SELECT userid FROM `mdl_groups_members` WHERE groupid = ' . $currentgroup . ') t0 LEFT JOIN `mdl_project_user_mapping` t1 ON t0.userid = t1.user_id LEFT JOIN `mdl_project_history_imp_detail` t2 ON t2.user = t1.skype WHERE group_id = ' . $currentgroup . ' ) t3'); //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); $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; } } } if (!empty($charCount[$USER->id]->alert)) { $msg = ""; if ($charCount[$USER->id]->alert == "High") { if ($alerts->import_alert + $config->highimportalertsfreq * 60 * 60 * 24 > time()) { return; } // $msg .= $USER->firstname.", You are a high participator in the Skype conversations.<br /><br />We have determined you are rather active in the imported Skype chats.<br /><br /> // As an additional challenge, try incorporating others in to the discussion, especially "; // $msg .= displayUsersAsText($low_participators); // $msg .= " who's not participating as much during the Skype chats."; $msg .= $USER->firstname . ", you are contributing really a lot to the Skype conversations! This is great!<br /><br />\n\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\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 is not participating as much!"; $alert_icon = "info.png"; } else { if ($alerts->import_alert + $config->lowimportalertsfreq * 60 * 60 * 24 > time()) { return; } // $msg = $USER->firstname.", You are a low participator in the Skype conversations.<br /><br />During your next Skype meeting, try posting more in-depth, detailed ideas, concepts or thoughts to expand on your posts and contribute as equally as others."; $msg = $USER->firstname . ", it seems that you have not contributed much to the Skype conversations 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.<br /><br />\n\t\t\tTry to share some ideas, concerns or thoughts with your team members in the next Skype meeting!"; $alert_icon = "alert_icon.png"; } $html = '<div id="dialog-message" title="' . $charCount[$USER->id]->alert . ' Skype 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, width: 350, buttons: { Ok: function() { $( this ).dialog( "close" ); } } }); }); </script>'; add_to_log($COURSE->id, 'project', 'alert-skype', $charCount[$USER->id]->alert); echo $html; $DB->set_field('project_user_mapping', 'import_alert', time(), array('user_id' => $USER->id)); } //end if alert check }
function getLowParticipators($groupid, $timestamp) { global $DB; $sql = 'SELECT userid FROM `mdl_chat_messages_current` WHERE groupid = ' . $groupid . ' AND timestamp BETWEEN ' . ($timestamp - 1) . ' AND ' . ($timestamp + 1) . ' AND message LIKE "alert-low%"'; $users = $DB->get_records_sql($sql); $users_list = ""; foreach ($users as $userid => $user) { $users_list .= ucfirst(studentidToName($userid)) . ", "; } //end for return rtrim($users_list, ", "); }
} //Increament Total Meetings for all users after skype has been imported $total_meetings = $DB->get_records('project_user_mapping', array('group_id' => $currentgroup), null, 'group_id,meetings_total', 0, 1); $inc_total = $total_meetings[$currentgroup]->meetings_total; $DB->set_field('project_user_mapping', 'meetings_total', ++$inc_total, array('group_id' => $currentgroup)); //reset users meeting alert $DB->set_field('project_user_mapping', 'meeting_alert', 0, array('group_id' => $currentgroup)); //If all all mapped, redirect page, skipping form if (!$unmapped) { redirect('view.php?id=' . $cmid); } $user_map = array(); //Create the array $user_map[0] = ""; //Add Blank option foreach ($mapped_users as $member) { //Fill the array with usernames $user_map[$member->user_id] = studentidToName($member->user_id); } //end for each $mapped_form = new history_map_users(null, array('group_members' => $user_map, 'convo_members' => $names_unique, 'history' => $history)); } echo $OUTPUT->header(); echo $OUTPUT->heading(format_string('Chat History Import'), 2); if ($mapped) { $mapped_form->display(); } $mform->display(); //$strlastmodified = get_string("lastmodified"); //echo "<div class=\"modified\">$strlastmodified: ".userdate($project->timemodified)."</div>"; echo $OUTPUT->footer();