locked
trying to make a TEST RRS feed

  • Question

  • User-735851359 posted

    Hello,

    I am showing the questions taking from the database:

    @for(int i=0;i<info.Count;i++){        
    <ul class="nospace push50 clear">
        @{j=i+1;}
        <li>
        <p>
        <strong>@j : @Html.Raw(info[i].Question)</strong>
        </p>
        <br>
        <input type="radio" name=@info[i].QuestionID value="A" >@Html.Raw(info[i].Choice1)<br>
        <input type="radio" name=@info[i].QuestionID value="B" >@Html.Raw(info[i].Choice2)<br> 
        <input type="radio" name=@info[i].QuestionID value="C" >@Html.Raw(info[i].Choice3)<br>
        <input type="radio" name=@info[i].QuestionID value="D" >@Html.Raw(info[i].Choice4)<br>
        @{cvp = "c" + info[i].QuestionID;}
        <input type="hidden" name=@cvp value=@info[i].Answer><br/>
        </li>       
    </ul>        
    }    

    I have problems with naming and requesting and counting correct answers:

            for(int i=0;i<info.Count;i++){ 
                t = Request["info[i].QuestionID"];
                ans += t;
                ss = "c" + t;
                if (t == Request["ss"]){
                    count++;
                };
            }

    the variable ans should collect the given answers : ABBDE...

    The variable count should count the correct ones.

    Thanx in advance

    Wednesday, May 21, 2014 12:50 PM

Answers

  • User-735851359 posted

    I got the result as following;

        @{sr = "s" + info[i].QuestionID;}
        <input type="radio" name="@sr" value="1" >@Html.Raw(info[i].Choice1)<br>
        <input type="radio" name="@sr" value="2" >@Html.Raw(info[i].Choice2)<br>
        <input type="radio" name="@sr" value="3" >@Html.Raw(info[i].Choice3)<br>
        <input type="radio" name="@sr" value="4" >@Html.Raw(info[i].Choice4)<br>
        @{cvp = "c" + info[i].QuestionID;}
        <input type="hidden" name="@cvp" value="@info[i].Answer"><br/>
            for(int i=0;i<info.Count;i++){ 
                ss = "s" + info[i].QuestionID.ToString();
                soru = Request[ss].AsInt();
     
                cc = "c" + info[i].QuestionID.ToString();
                cevap = Request[cc].AsInt();
     
                answers = answers + soru.ToString();
                if (soru == cevap){
                    count++;
                };
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 22, 2014 2:38 AM

All replies

  • User938738290 posted

    ayanmesut

    <input type="radio" name=@info[i].QuestionID value="A" >@Html.Raw(info[i].Choice1)<br>   
    t = Request["info[i].QuestionID"];

    When naming your radio buttons, your code evaluates the expression @info[i].QuestionID and sets the Name attribute of the radio button HTML elements to that.

    When pulling the form value from the request, it looks for a key that is the literal "info[i].QuestionID".  You may be missing an @ symbol here.

    Wednesday, May 21, 2014 1:15 PM
  • User-735851359 posted

    I got the result as following;

        @{sr = "s" + info[i].QuestionID;}
        <input type="radio" name="@sr" value="1" >@Html.Raw(info[i].Choice1)<br>
        <input type="radio" name="@sr" value="2" >@Html.Raw(info[i].Choice2)<br>
        <input type="radio" name="@sr" value="3" >@Html.Raw(info[i].Choice3)<br>
        <input type="radio" name="@sr" value="4" >@Html.Raw(info[i].Choice4)<br>
        @{cvp = "c" + info[i].QuestionID;}
        <input type="hidden" name="@cvp" value="@info[i].Answer"><br/>
            for(int i=0;i<info.Count;i++){ 
                ss = "s" + info[i].QuestionID.ToString();
                soru = Request[ss].AsInt();
     
                cc = "c" + info[i].QuestionID.ToString();
                cevap = Request[cc].AsInt();
     
                answers = answers + soru.ToString();
                if (soru == cevap){
                    count++;
                };
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 22, 2014 2:38 AM