Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::modifyGroup ( const QString &  yearName,
const QString &  initialGroupName,
const QString &  finalGroupName,
int  finalNumberOfStudents 
)

Modifies this students group (name, number of students) and takes care of all related activities and constraints. Returns true on success, false on failure (if not found)

Definition at line 1128 of file rules.cpp.

References activitiesList, internalStructureComputed, modifySubgroup(), searchGroup(), searchStudentsSet(), ConstraintStudentsSetIntervalMaxDaysPerWeek::students, ConstraintStudentsSetNoGaps::students, ConstraintStudentsSetNHoursDaily::students, ConstraintStudentsSetNotAvailable::students, ConstraintActivitiesPreferredTimes::studentsName, timeConstraintsList, and yearsList.

Referenced by modifyYear().

{
      assert(searchGroup(yearName, initialGroupName)>=0);
      assert(searchStudentsSet(finalGroupName)==NULL || initialGroupName==finalGroupName);

      StudentsYear* sty;
      for(sty=this->yearsList.first(); sty; sty=this->yearsList.next())
            if(sty->name==yearName)
                  break;
      assert(sty);
      StudentsGroup* stg;
      for(stg=sty->groupsList.first(); stg; stg=sty->groupsList.next())
            if(stg->name==initialGroupName){
                  stg->name=finalGroupName;
                  stg->numberOfStudents=finalNumberOfStudents;

                  for(StudentsSubgroup* sts=stg->subgroupsList.first(); sts; sts=stg->subgroupsList.next()){
                        if(sts->name.right(12)==" WHOLE GROUP" && sts->name.left(sts->name.length()-12)==initialGroupName)
                              this->modifySubgroup(sty->name, stg->name, sts->name, stg->name+" WHOLE GROUP", sts->numberOfStudents);
                  }

                  break;
            }
      assert(stg);

      //TODO: improve this part
      for(Activity* act=this->activitiesList.first(); act; act=this->activitiesList.next())
            act->renameStudents(initialGroupName, finalGroupName);

      for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ctr=this->timeConstraintsList.next()){
            if(ctr->type==CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE){
                  ConstraintStudentsSetNotAvailable* crt_constraint=(ConstraintStudentsSetNotAvailable*)ctr;
                  if(initialGroupName == crt_constraint->students)
                        crt_constraint->students=finalGroupName;
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_N_HOURS_DAILY){
                  ConstraintStudentsSetNHoursDaily* crt_constraint=(ConstraintStudentsSetNHoursDaily*)ctr;
                  if(initialGroupName == crt_constraint->students)
                        crt_constraint->students=finalGroupName;
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_NO_GAPS){
                  ConstraintStudentsSetNoGaps* crt_constraint=(ConstraintStudentsSetNoGaps*)ctr;
                  if(initialGroupName == crt_constraint->students)
                        crt_constraint->students=finalGroupName;
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK){
                  ConstraintStudentsSetIntervalMaxDaysPerWeek* crt_constraint=(ConstraintStudentsSetIntervalMaxDaysPerWeek*)ctr;
                  if(initialGroupName == crt_constraint->students)
                        crt_constraint->students=finalGroupName;
            }
            else if(ctr->type==CONSTRAINT_ACTIVITIES_PREFERRED_TIMES){
                  ConstraintActivitiesPreferredTimes* crt_constraint=(ConstraintActivitiesPreferredTimes*)ctr;
                  if(initialGroupName == crt_constraint->studentsName)
                        crt_constraint->studentsName=finalGroupName;
            }
      }

      this->internalStructureComputed=false;

      return true;
}


Generated by  Doxygen 1.6.0   Back to index