Exemplo n.º 1
0
function blended_delete_teams(grade_item $item)
{
    global $DB;
    $delgroups = blended_get_teams($item, false);
    foreach ($delgroups as $delgroup) {
        blended_delete_team($delgroup);
    }
    $DB->delete_records('blended_assign_grouping', array('id_item' => $item->id));
}
Exemplo n.º 2
0
function blended_delete_sign_member_or_group($idteam, $member, $option)
{
    global $DB;
    $blended_teams = $DB->get_records('blended_team');
    foreach ($blended_teams as $blended_team) {
        if ($blended_team->id_team == $idteam) {
            $f = $blended_team;
        }
    }
    $g = $DB->get_record('groups', array('id' => $idteam));
    $l = $DB->get_record('blended_assign_grouping', array('id_assign' => $f->id_assignment));
    if ($option == 'member') {
        $del = groups_remove_member($idteam, $member->userid);
        blended_delete_team_member($idteam, $member->id);
    }
    if ($option == 'group') {
        $del = groups_delete_group($idteam);
        groups_unassign_grouping($l->id_grouping, $idteam);
        blended_delete_team($idteam, $f->id_assignment);
        blended_delete_team_member($idteam);
        //Se debe realizar la comprobación de que si no hay mas equipos se borre el agrupamiento
        if (!($teams = $DB->get_records('groupings_groups', array('groupingid' => $l->id_grouping)))) {
            groups_delete_grouping($l->id_grouping);
            $DB->delete_records('blended_assign_grouping', array('id_grouping' => $l->id_grouping));
        }
    }
}
Exemplo n.º 3
0
     // Se obtiene el valor del checkbox que marca los que desea eliminar
     $deleteuser = optional_param($member->id, 'nodelete', PARAM_ALPHA);
     // Si el líder elimina al miembro
     if ($deleteuser == 'delete') {
         // Si el lider del equipo se elimina a si mismo
         $choosenewleader = $member->id == $team_leader;
         blended_remove_team_member($team, $member->id);
         $a = new stdClass();
         $a->username = fullname($member);
         $a->teamname = $team->name;
         echo $OUTPUT->notification(get_string('userremovedfromteam', 'blended', $a));
     }
 }
 // Si el lider elimina todos los miembros del equipo se borra el equipo
 if (!($members = blended_get_team_members($id_team))) {
     blended_delete_team($id_team);
     echo $OUTPUT->notification(get_string('teamremoved', 'blended', $team));
 } else {
     foreach ($members as $member) {
         // Si el lider del equipo se elimina a si mismo, y quedan miembros,
         // el siguiente miembro pasa a ser el nuevo lider del equipo
         if ($choosenewleader) {
             blended_set_team_leaderid($id_team, $member->id);
             $a = new stdClass();
             $a->username = fullname($member);
             $a->teamname = blended_get_team($id_team)->name;
             echo $OUTPUT->notication(get_string('userpromotedtoleader', 'blended', $a));
             break;
         }
     }
     // Fin foreach select new leader