Get data from array and auto assign to users

First of all im new to yii framework… Currently i want to write a function to automatically assign short listed submissions user to evaluators so they can mark their submissions profiles.

For example




    Total submission users: 20

    Total evaluators: 11

    Evaluator per submission: 3

I want to get the array of total submission users, and also total evaluators… then i want to assign submissions automatically to them, Below is something that i want.




    submission 1

    	Assigned to evaluator 1, evaluator 2, evaluator 3.

    

    submission 2

    	Assigned to evaluator 4, evaluator 5, evaluator 6.

    

    submission 3

    	Assigned to evaluator 7, evaluator 8, evaluator 9.

    

    submission 4

    	Assigned to evaluator 10, evaluator 11, evaluator 1.

    

    submission 5

    	Assigned to evaluator 2, evaluator 3, evaluator 4.

    .

    .


    .

    submission 20

    	Assigned to evaluator 3, evaluator 4, evaluator 5.



and so on until all submissions are evaluated are automatically assigned… Currently im doing everything manually by going to first evaluator profile, then assign sumission to him, then go to second evaluator and then assign submission to him, it will take lot of time if i have more than 50 evaluators and 200+ submissions that i want automated.

Im new to yii so not sure how to do all that… here is my code for new function…




         public function actionAutoAssign($id){

        $evaluator_list = ApplicantsController::model()->findAllByAttributes(array('user_type'=>'evaluator'));

        $applicants_list = ApplicantsController::model()->findAllByAttributes(array('appl_status'=>'Short listed'));

        $award_id = Awards::model()->actionCurrentAward();

        $evalperSub =3 ;

        $status = '';


        $model = new Evaluation();

        $model->setScenario('evalassign');

        foreach($applicants_list as $key=>$val){

            $model->app_id = $val;

            foreach($evaluator_list as $key2=>$val2){

                $model->eval_id .= $val2;

            }

            $model->assign_date = date('Y-m-d H:i:s');

            $model->award_id = $award_id;

            if($model->validate()){

                $model2 = null;

                $model2 = HmcApplicants::model()->find('id=:applId',array('applId'=>$val));

                $model2->appl_status = 'Under Evaluation Now';

                $model2->update($val);


                if($model->save(FALSE)){

                    $status = 'ok';

                }

                if($status=='ok') {

                    //also add Award Default Score

                    $count = ApplicantAwards::model()->countByAttributes(array(

                        'app_id' => $val, 'award_id' => $award_id

                    ));

                }

                if($count>0){

                    $model4 = ApplicantAwards::model()->find('app_id=:applId and award_id=:awardID',array('applId'=>$id,'awardID'=>$award_id));

                    $model4->app_id = $id;

                    $model4->award_id = $award_id;

                    $model4->score = 0;

                    $model4->update();

                }else{

                    $model4 = new ApplicantAwards();

                    $model4->app_id = $id;

                    $model4->award_id = $award_id;

                    $model4->score = 0;

                    $model4->save();

                }

            }


        }

    }



Im not really sure how to do this in yii, im trying but confused with how to use arrays that im doing above, and how to automatically assign one submission to 3 evalutors like i have described above.