如果存在关于用户的ID,如何隐藏问题

时间:2018-04-27 11:58:03

标签: html database hide

我有一个问题,做一些调查应用,并遇到了问题。我正在以表格形式提取团队调查问题和用户。例如团队有10名成员。并有一项调查。因此,每个用户都需要回答相同的调查问题。我提取的形式如下:

UserId,UserName 问题1 问题2 问题3 NextUserId,NExtUserName 问题1 问题2 问题3

所以我需要隐藏div用户名和问题,或者只是问题,如果在数据库中已存在关于该用户的问题的答案。我的意思是,如果我在第一个用户的调查中回答,下次当我打开相同的调查时,如果我已经回答了他的话,我不应该再看到相同的用户和有关它的问题。

我的数据库表,我放置我的答案和用户ID如下所示: 有

AnswerAboutUserId - 用户ID,已解答 MemberId - 谁回答了问题 回答 AnswerId QuestionaName

我该怎么做?

在我的控制器和视图下方

控制器:

public function viewSurvey($id)
{
    $object = DB::table('question')->where('survey_id' , '=', $id)->get();
    $date = Survey::where('surveyId' , '=', $id)->get();
    $teams = Auth::user()->teams;

    $survey = Survey::where('surveyId' , '=', $id)
        ->join('team','team.teamId', '=', 'survey.teamId')
        ->join('teammembersall','teammembersall.TeamId', '=', 'team.TeamId')
        ->join('users','users.id', '=', 'teammembersall.UserId')
        ->select('users.*')
        ->get();

    $questions = DB::table('answer')->get();

    return view('survey_details', ['object' => $object, 'date' => $date, 'teams' => $teams, 'survey' => $survey, 'questions' => $questions]);
}

这是我的观点:

 <html>
<head>
    <title>Dynamically Add or Remove input fields in PHP with JQuery</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
            <div class="container">
                <hr>
                <div class="row">
                    <div class="col-md-2">
                    </div>
                    <div class="col-md-8">
                            <br>
                            <div style="display:none">
                            {{  $dates = date('Y-m-d H:i:s') }}
                            </div>

                                <div class="container-survey-logo">
                                    <img src={{url('/img/survey-banner.jpg')}} width="100%" height="auto" alt=""/>
                                    <div class="text-block-survey-date">
                                        @foreach($date as $dat)
                                        <h4>End date:</h4>
                                        <p>{{ $dat->ended_at}}</p>
                                        @endforeach
                                    </div>
                                </div>
                                <div style="display:none;">
                                    @foreach($questions as $quest)
                                        <p>{{ $quest->answerAboutUserId}}</p>
                                    @endforeach
                                </div>
                                @if($dat->ended_at > $dates )
                                @if ($teams = Auth::user())
                                    <div class="survey-theme">
                                        @foreach($survey as $surv)
                                            @if($surv->id != Auth::user()->id)
                                            <form action="/confirmSurveyAnswers" method="post">
                                                {{csrf_field()}}
                                                <br>
                                                <div class="well well-lg">
                                                <h5>
                                                    Questions about member:
                                                    <h2><input style="border:none;background:none" name="surveyName" value="{{ $surv->name}}" readonly></h2>
                                                   <input style="border:none;background:none;display:none" name="surveyUserDataId" value="{{ $surv->id}}" readonly>
                                                 </h5>
                                                <br>
                                                @foreach($object as $object_each)
                                                                <input style="font-size:20px;" type="text" class="form-control" id="exampleInputAnswer" name="questionName[{{$object_each->id}}]" value="{!! $object_each->name !!}" readonly>
                                                        <div class="survey-questions">
                                                            <label class="radio-inline-text">
                                                                Not agree
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="1" name="QuestionsAnswers[{{$object_each->id}}]" >1
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="2" name="QuestionsAnswers[{{$object_each->id}}]" >2
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="3" name="QuestionsAnswers[{{$object_each->id}}]" >3
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="4" name="QuestionsAnswers[{{$object_each->id}}]" >4
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="5" name="QuestionsAnswers[{{$object_each->id}}]" >5
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="6" name="QuestionsAnswers[{{$object_each->id}}]" >6
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="7" name="QuestionsAnswers[{{$object_each->id}}]" >7
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="8" name="QuestionsAnswers[{{$object_each->id}}]" >8
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="9" name="QuestionsAnswers[{{$object_each->id}}]" >9
                                                            </label>
                                                            <label class="radio-inline">
                                                                <input type="checkbox" value="10" name="QuestionsAnswers[{{$object_each->id}}]" >10
                                                            </label>
                                                            <label class="radio-inline-text">
                                                                 Fully agree
                                                            </label>
                                                        </div>
                                                @endforeach
                                                    <div class="im-done-button">
                                                        <button type="submit" class="btn btn-primary">I'm Done</button>
                                                    </div>
                                                </div>
                                                @endif
                                            </form>
                                            @endforeach
                                                <Br>
                                                @include('layouts.errors')

                                    </div>
                                    @else <h1>This is not your team survey</h1> @endif
                                     @else <h1>This survey ended</h1>  @endif
                    </div>
                    <div class="col-md-2">
                    </div>
                </div>
                <hr>
            </div>

</body>
</html>

0 个答案:

没有答案