there is

  • questions table Questions(id,Vopros,DisciplinaId....) ,
  • Exams Exams(id,...,DisciplinaId,CountQuestions) ,
  • user table Users (id,....,GroupId) with an indication of the group to which the student belongs
  • performance table Uspevaemost (UserId,EkzamenId,VoprosId, [Otvet] )

The algorithm is as follows:

  1. adding data to the Exams-100 exam questions table ( CountQuestions ) by discipline ( DisciplinaId ) for a group ( GroupId ).
  2. Take id students from GroupId
  3. Get id questions from DisciplinaId
  4. Generate data and add to the table Uspevaemost order by rand() indicating limit 100 (CountQuestions) i.e. not all questions need to be recorded, but only 100 randomly for each student, which belongs to this group and for the discipline that is indicated.

In general, piled up and can not cope.

Confused how to write a generation request. Tell me please. thank

    1 answer 1

     $id_ekzamena=$_GET["id_ekzamena"]; //ЭКЗАМЕН $count_voprosov=$_GET["limit"]; //Количество вопросов $id_group=$_GET["id_group"]; //Какой группе студентов добаляем тесты- вернёт айдишники студентов в группе $viborka_studentov =$this->Vipolnit_Zapros("SELECT idstudents as id FROM Studentsingroups WHERE idgroups=".$id_group); //$count =count($viborka_studentov); foreach ($viborka_studentov as $element) { $this->Vipolnit_Zapros("INSERT INTO uspevaemostekzameni (IdVoprosa,IdEkzamena,IdUser) SELECT vopros.id as IdVoprosa,'".$id_ekzamena."' AS IdEkzamena,".$element['id']." AS IdUser FROM vopros ORDER BY RAND() LIMIT ".$count_voprosov); }