Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::addSplitActivity ( int  _firstActivityId,
int  _activityGroupId,
const QStringList &  _teachersNames,
const QString &  _subjectName,
const QString &  _subjectTagName,
const QStringList &  _studentsNames,
int  _nSplits,
int  _totalDuration,
int  _durations[],
int  _parities[],
int  _minDayDistance,
int  _preferredDays[],
int  _preferredHours[] 
)

Adds a new split activity to the list of activities. Returns true if successful or false if the maximum number of activities was reached. If _minDayDistance>0, there will automatically added a compulsory ConstraintMinNDaysBetweenActivities. Also, there are automatically added several ConstraintActivityPreferredTime, if necessary

Definition at line 1441 of file rules.cpp.

References activitiesList, addTimeConstraint(), Activity::id, and internalStructureComputed.

{
      assert(_firstActivityId==_activityGroupId);

      int acts[MAX_CONSTRAINT_MIN_N_DAYS_BETWEEN_ACTIVITIES];
      assert(_nSplits<=MAX_CONSTRAINT_MIN_N_DAYS_BETWEEN_ACTIVITIES);

      for(int i=0; i<_nSplits; i++)
            assert(_parities[i]==PARITY_WEEKLY || _parities[i]==PARITY_BIWEEKLY); //weekly or bi-weekly

      for(int i=0; i<_nSplits; i++){
            Activity *act;
            if(i==0)
                  act=new Activity(*this, _firstActivityId+i, _activityGroupId,
                        _teachersNames, _subjectName, _subjectTagName, _studentsNames,
                        _durations[i], _totalDuration, _parities[i]);
            else
                  act=new Activity(*this, _firstActivityId+i, _activityGroupId,
                        _teachersNames, _subjectName, _subjectTagName, _studentsNames,
                        _durations[i], _totalDuration, _parities[i]);

            this->activitiesList.append(act);

            acts[i]=_firstActivityId+i;

            if(_preferredDays[i]>=0 || _preferredHours[i]>=0){
                  TimeConstraint *constr=new ConstraintActivityPreferredTime(1.0, false, act->id, _preferredDays[i], _preferredHours[i]); //non-compulsory constraint
                  bool tmp = this->addTimeConstraint(constr);
                  assert(tmp);
            }
      }

      if(_minDayDistance>0){
            TimeConstraint *constr=new ConstraintMinNDaysBetweenActivities(1.0, true, _nSplits, acts, _minDayDistance); //compulsory constraint
            bool tmp=this->addTimeConstraint(constr);
            assert(tmp);
      }

      this->internalStructureComputed=false;

      return true;
}


Generated by  Doxygen 1.6.0   Back to index