| |
|||
Сначала с учетом идентификатора ContentID программа получает из базы данных очередную страницу с текстовым материалом:
("Select SectionContentID, SectionContentTitle, " _ & "SectionContent from SectionContents Where " _ & "SectionContentID = (Select Min(SectionContentID) " _ & "From SectionContents Where SectionContentID > " _ & Session("CurrentSectionContentID") _ & " and CourseSectionID = " _ & Session("CourseSectionID") & ")", DBConn) DBCommand.Fill(DSPageData, _ "SectionContent")
DSPageData.Tables("SectionContent"). _ Rows(0).Item("SectionContentID")
Rows(O).Item("SectionContentTitle") _ & "<br><br>" _ & DSPageData.Tables("SectionContent"). _ Rows(O).Item("SectionContent") На странице Тест специальный код выводит тест для указанного раздела, а также подсчитывает количество набранных баллов. Это наиболее сложный код из числа рассмотренных, поскольку тесты содержат разное количество вопросов и заранее неизвестно, сколько их нужно будет вывести в данном случае. В связи с этим необходимо обеспечить динамическое добавление элементов управления для отображения надлежащего количества вопросов. Рассмотрим набор элементов управления на странице Тест. В первом элементе Label выводится название раздела:
id="lblTitle" BorderWidth="7px" BorderStyle=7 Width="90%" Font-Size="25pt" Font-Name="Tahoma" runat="server" />
id="lblMessage" Font-Size="12pt" Font-Name="Tahoma" Font-Bold="True" Text="Ответьте на каждый вопрос и нажмите кнопку ОК." runat="server" />
id="pnlQuestions" Width="90%" runat="server" > </asp:Panel>
id-"butOK" text=" OK "' ' Type="Submit" OnClick="SubmitBtn_Click" runat="server" />
If Len(Session("StudentID")) = 0 Then Response.Redirect{"./index.aspx") End If If Len(Session("CourseSectioniD")) - 0 Then Response.Redirect("./home_room.aspx") End If Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet Dim I as Integer Dim J as Integer Dim TempID as String DBConn - New OleDbConnection("Provider=sqloledb;" _ & "seryer-localhost;" _ & "Initial Catalog-INETC9;" & "User Id=sa;" _ & "Password=yourpassword;") : DBCommand = New OleDbDataAdapter _ ("Select SectionName from CourseSections Where " _ & "CourseSectioniD = " & Session("CourseSectioniD") _ , DBConn) DBCommand.Fill(DSPageData, _ "SectionName") IblTitle.Text = "<сеntег>Раздел ," _ & DSPageData.Tables("SectionName"). _ Rows(O).Item("SectionName") _ & "</center>" DBCoiranand = New OleDbDataAdapter _ ("Select SectionQuestionID, QuestionText " _ & "From SectionQuestions Where CourseSectionID = " _ & Session ("CourseSectionID"), DBConn) DBCoiranand.Fill(DSPageData, _ "QuizQuestions") For I = 0 to DSPageData.Tables("QuizQuestions"). _ Rows.Count = 1 Dim IcHTML = New LiteralControl IcHTML.Text = "<B>" & DSPageData.Tables("QuizQuestions"). _ Rows (I) .Item("QuestionText") & " " pnlQuestions.Controls.Add(IcHTML) Dim MyDDL = New DropDownList TempID = DSPageData.Tables("QuizQuestions"). _ Rows(I).ItemC'SectionQuestionID") MyDDL.ID = "Q" S TempID; DBCoiranand = New OleDbDataAdapter _ ("Select AnswerText " _ & "From QuestionAnswers Where SectionQuestionID = " _ & TempID, DBConn) DBCommand.Fill(DSPageData, _ TempID) For J = 0 to DSPageData.Tables(TempID). _ Rows.Count - 1 Dim Myltem = New Listltem Myltem.Text = DSPageData.Tables(TempID). _ Rows(J).Item("AnswerText") MyDDL.Items.Add(Myltem) Next pnlQuestions.Controls.Add(MyDDL) Dim lcHTML2 = New LiteralControl lcHTML2.Text = "<BR><BR>" pnlQuestions.Controls.Add(lcHTML2) Next End Sub |
|||