Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::modifyYear ( const QString &  initialYearName,
const QString &  finalYearName,
int  finalNumberOfStudents 
)

Modifies this students year (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 952 of file rules.cpp.

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

{
      assert(searchYear(initialYearName)>=0);
      assert(searchStudentsSet(finalYearName)==NULL || initialYearName==finalYearName);

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

      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(initialYearName == crt_constraint->students)
                        crt_constraint->students=finalYearName;
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_N_HOURS_DAILY){
                  ConstraintStudentsSetNHoursDaily* crt_constraint=(ConstraintStudentsSetNHoursDaily*)ctr;
                  if(initialYearName == crt_constraint->students)
                        crt_constraint->students=finalYearName;
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_NO_GAPS){
                  ConstraintStudentsSetNoGaps* crt_constraint=(ConstraintStudentsSetNoGaps*)ctr;
                  if(initialYearName == crt_constraint->students)
                        crt_constraint->students=finalYearName;
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK){
                  ConstraintStudentsSetIntervalMaxDaysPerWeek* crt_constraint=(ConstraintStudentsSetIntervalMaxDaysPerWeek*)ctr;
                  if(initialYearName == crt_constraint->students)
                        crt_constraint->students=finalYearName;
            }
            else if(ctr->type==CONSTRAINT_ACTIVITIES_PREFERRED_TIMES){
                  ConstraintActivitiesPreferredTimes* crt_constraint=(ConstraintActivitiesPreferredTimes*)ctr;
                  if(initialYearName == crt_constraint->studentsName)
                        crt_constraint->studentsName=finalYearName;
            }
      }

      int t=0;
      for(StudentsYear* sty=this->yearsList.first(); sty; sty=this->yearsList.next())
            if(sty->name==initialYearName){
                  sty->name=finalYearName;
                  sty->numberOfStudents=finalNumberOfStudents;
                  t++;
                  
                  for(StudentsGroup* stg=sty->groupsList.first(); stg; stg=sty->groupsList.next()){
                        if(stg->name.right(11)==" WHOLE YEAR" && stg->name.left(stg->name.length()-11)==initialYearName)
                              this->modifyGroup(sty->name, stg->name, sty->name+" WHOLE YEAR", stg->numberOfStudents);
                  }
            }
      assert(t<=1);

      this->internalStructureComputed=false;
      
      if(t==0)
            return false;
      else
            return true;
}


Generated by  Doxygen 1.6.0   Back to index