Skip to content

Commit

Permalink
IP-346: Refactor the project landing page to show the problems button…
Browse files Browse the repository at this point in the history
… directly after the user has answered to the questionnaire (don't wait until the questionnaire is finalized)
  • Loading branch information
PavlosIsaris committed Jan 2, 2025
1 parent b94a1a9 commit 7449470
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public function getCrowdSourcingProjectViewModelForLandingPage(
$shareUrlForFacebook = '';
$shareUrlForTwitter = '';
$countAll = 0;
$projectHasPublishedProblems = false;
if ($questionnaire) {
$countAll = $this->questionnaireRepository->countAllResponsesForQuestionnaire($questionnaire->id);
$questionnaireGoalVM = $this->questionnaireGoalManager->getQuestionnaireGoalViewModel($questionnaire, $countAll);
Expand All @@ -146,10 +145,8 @@ public function getCrowdSourcingProjectViewModelForLandingPage(
$shareButtonsModel = new QuestionnaireSocialShareButtons($questionnaire, $idOfUserThatCanShareTheQuestionnaire);
$shareUrlForFacebook = $shareButtonsModel->getSocialShareURL($project, 'facebook');
$shareUrlForTwitter = $shareButtonsModel->getSocialShareURL($project, 'twitter');
} else {
// if there is no questionnaire, we need to check if this project has published problems
$projectHasPublishedProblems = $this->crowdSourcingProjectProblemRepository->projectHasPublishedProblems($project->id);
}
$projectHasPublishedProblems = $this->crowdSourcingProjectProblemRepository->projectHasPublishedProblems($project->id);
if ($feedbackQuestionnaire) {
$userFeedbackQuestionnaireResponse =
$this->questionnaireRepository->getUserResponseForQuestionnaire($feedbackQuestionnaire->id, $userId);
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/sass/project/landing-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ h6 {
z-index: 1000;
background-color: black;
opacity: 0.2;
height: 650px;
height: 750px;
top: 0;
position: absolute;
width: 100%;
Expand Down
4 changes: 2 additions & 2 deletions resources/views/crowdsourcing-project/landing-page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
@section('content')
<div class="container-fluid h-100 w-100 px-0">
@include('partials.flash-messages-and-errors')
<section id="motto" style="height: 650px;">
<section id="motto" style="height: 750px;">
@include('crowdsourcing-project.partials.motto')
</section>
<section>
@include('crowdsourcing-project.partials.about')
</section>
<section>
@include('crowdsourcing-project.partials.questionnaire')
@include('crowdsourcing-project.partials.next-actions')
</section>
@if($viewModel->questionnaire)
<section id="collective-goal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@
@if($viewModel->shareUrlForFacebook || $viewModel->shareUrlForTwitter)
{{ __("questionnaire.invite_your_friends_to_answer")}}
@endif


</h2>
<div class="col-10 col-md-12 mx-auto d-flex flex-wrap justify-content-center social-share">
@include('crowdsourcing-project.partials.share-questionnaire-on-social', ["viewModel"=>$viewModel])
</div>

</div>
</div>


129 changes: 13 additions & 116 deletions resources/views/crowdsourcing-project/partials/motto.blade.php
Original file line number Diff line number Diff line change
@@ -1,131 +1,28 @@
<div id="project-motto-container" class="row h-100 w-100 align-items-center mx-0 bg-img"
style="background-image: url({{asset($viewModel->project->img_path)}}); position: relative;">
style="background-image: url({{ asset($viewModel->project->img_path) }}); position: relative;">
<div class="overlay-filter {{ $viewModel->thankYouMode ? 'overlay-thanks' : '' }}"></div>
<div class="col-lg-7 col-md-8 col-sm-11 mx-auto motto-content">
<div class="frosted"></div>
<div id="project-motto" class="h-100">
<div class="container">
<div class="row title-row mb-3 text-center">
<div class="col-12 px-5">
<h1 id="project-title"
class="text">{!! $viewModel->project->currentTranslation->name !!}</h1>
<h2 id="motto-title"
class="text">{!! $viewModel->project->currentTranslation->motto_title !!}</h2>
@if($viewModel->project->currentTranslation->motto_subtitle)
<h4 id="motto-subtitle"
class="text text-center pt-5">{!! $viewModel->project->currentTranslation->motto_subtitle !!}</h4>
<h1 id="project-title" class="text">
{!! $viewModel->project->currentTranslation->name !!}
</h1>
<h2 id="motto-title" class="text">
{!! $viewModel->project->currentTranslation->motto_title !!}
</h2>
@if ($viewModel->project->currentTranslation->motto_subtitle)
<h4 id="motto-subtitle" class="text text-center pt-5">
{!! $viewModel->project->currentTranslation->motto_subtitle !!}
</h4>
@endif
</div>
</div>
<div class="row pt-3 pb-5">
<div class="col-md-10 col-sm-11 mx-auto">
<div class="container-fluid">
<div class="row">
{{-- PROJECT HAVE AN ACTIVE QUESTIONNAIRE --}}
@if($viewModel->questionnaire)
{{-- USER RESPONDED TO THE QUESTIONNAIRE --}}
@if($viewModel->userResponse)
@if($viewModel->projectHasPublishedProblems && !$viewModel->thankYouMode)
<a href="{{ route('project.problems-page', ['project_slug' => $viewModel->project->slug]) }}"
class="btn btn-primary call-to-action mx-auto">
{{__("project-problems.project_landing_page_problems_action_button")}}
<i
class="fas fa-arrow-right"></i></a>
@else
<div class="col-12">
<h4 class="{{ $viewModel->thankYouMode ? 'mt-0' : 'mt-3' }} mb-4 text-center">
@if(!$viewModel->thankYouMode)
{{ __("questionnaire.already_answered") }}
@endif
{{ __("questionnaire.thank_you_for_your_response") }}
</h4>
@if($viewModel->thankYouMode && isset($badge))
<div class="container mt-5">
<div class="row mb-4">
<div class="col-md-8 col-sm-12 mx-auto text-center">
@include('gamification.badge-single', ['badge' => $badge, 'title' => "You are a level " . $badge->level . " " . $badge->badgeName . "!"])
</div>
</div>
@if(\Illuminate\Support\Facades\Auth::check())
<div class="row">
<div class="col-md-7 col-sm-12 mx-auto text-center">
<h3 class="dashboard-message w-100">
@if($viewModel->projectHasPublishedProblems)
{{ __('project-problems.project_landing_page_problems_action_button') }}
&
{{ __('project-problems.suggest_solution') }}
@else
{{ __('questionnaire.visit_dashboard_and_invite') }}
@endif
</h3>
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-9 mx-auto text-center">
@if($viewModel->projectHasPublishedProblems)
<a href="{{ route('project.problems-page', ['project_slug' => $viewModel->project->slug]) }}"
class="btn btn-primary call-to-action mx-auto">
{{__("project-problems.project_landing_page_problems_action_button")}}
<i
class="fas fa-arrow-right"></i></a>
@else
<a href="{{ route('my-dashboard', ['locale' => app()->getLocale()]) }}"
class="btn btn-primary btn-lg w-100 dashboard-btn">
{{ __("menu.my_dashboard") }}
</a>
@endif
</div>
</div>
@endif
</div>
@endif
<br>
</div>
@endif
{{-- IF HE HAS NOT RESPONDEDED TO THE FEEDBACK, INVITE HIM TO DO SO--}}
@if ($viewModel->displayFeedbackQuestionnaire())
<div class="col-md-9 col-sm-12 mx-auto">
<a href="{{ route('show-questionnaire-page', ['locale' => app()->getLocale(), 'project' => $viewModel->project->slug,'questionnaire' => $viewModel->feedbackQuestionnaire->id]) }}"
class="btn btn-primary w-100 respond-questionnaire call-to-action">
{{__("questionnaire.give_us_feedback")}}
</a>
</div>
@else
{{-- DISPLAY INVITE TO SHARE ON SOCIAL --}}
@if($viewModel->shareUrlForFacebook || $viewModel->shareUrlForTwitter)

<div class="col-12">
<h4 class="mb-3 text-center">
{{ __("questionnaire.invite_your_friends_to_answer") }}:
</h4>
</div>

<div class="col-10 col-md-12 mx-auto d-flex flex-wrap justify-content-center social-share">
@include('crowdsourcing-project.partials.share-questionnaire-on-social', ["viewModel"=>$viewModel])
</div>

@endif
@endif
@else
{{-- INVITE HIM TO RESPOND TO THE PROJECT QUESTIONNAIRE --}}
<div class="col-md-9 col-sm-12 mx-auto">
<a href="{{ route('show-questionnaire-page', ['locale' => app()->getLocale(), 'project' => $viewModel->project->slug,'questionnaire' => $viewModel->questionnaire->id]) }}"
class="btn btn-primary w-100 respond-questionnaire call-to-action
{{ !$viewModel->project->lp_show_speak_up_btn ? 'hidden' : '' }}">
{{__("questionnaire.answer_the_questionnaire")}}
</a>
</div>
@endif
@elseif($viewModel->projectHasPublishedProblems)
<a href="{{ route('project.problems-page', ['project_slug' => $viewModel->project->slug]) }}"
class="btn btn-primary call-to-action mx-auto">
{{__("project-problems.project_landing_page_problems_action_button")}} <i
class="fas fa-arrow-right"></i></a>
@else
@include('crowdsourcing-project.partials.external-url')
@endif
</div>
</div>
<div class="col-lg-6 col-md-8 col-sm-11 mx-auto">
@include('crowdsourcing-project.partials.questionnaire-problems-buttons')
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div id="questionnaire-wrapper" class="py-5">
<div class="container">
<div id="questionnaire"
class="align-items-center mx-0"
style="background-image: url('{{ asset($viewModel->project->lp_questionnaire_img_path) }}')">
@include('crowdsourcing-project.partials.questionnaire-problems-buttons')
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="text-center content-container">
{{-- Show Questionnaire Button if available and user has not answered --}}
@if ($viewModel->questionnaire && !$viewModel->userResponse)
<h3 class="project-section-title text-center mb-5">
{{ $viewModel->questionnaire->fieldsTranslation->title }}
</h3>
<a href="{{ route('show-questionnaire-page', ['locale' => app()->getLocale(), 'project' => $viewModel->project->slug, 'questionnaire' => $viewModel->questionnaire->id]) }}"
class="btn btn-primary w-100 respond-questionnaire call-to-action">
{{ __("questionnaire.start_answering") }}
</a>

{{-- Show Problems Button if user has answered questionnaire or no questionnaire exists --}}
@elseif (($viewModel->questionnaire && $viewModel->userResponse && $viewModel->projectHasPublishedProblems) ||
(!$viewModel->questionnaire && $viewModel->projectHasPublishedProblems))
<h3 class="project-section-title text-center mb-5">
@if ($viewModel->questionnaire)
{{ __("my-dashboard.see_the_problems_cta") }}
@endif
</h3>
<a href="{{ route('project.problems-page', ['project_slug' => $viewModel->project->slug]) }}"
class="btn btn-primary w-100 call-to-action">
{{ __("project-problems.project_landing_page_problems_action_button") }}
<i class="fas fa-arrow-right"></i>
</a>
@else
<div>
@if ($viewModel->project->status_id == App\BusinessLogicLayer\lkp\CrowdSourcingProjectStatusLkp::FINALIZED)
<h3 class="project-section-title">{{ __("questionnaire.project_finalized") }}</h3>
@else
<h3 class="project-section-title">{{ __("questionnaire.no_active_questionnaires") }}</h3>
<h3 class="project-section-title">{{ __("questionnaire.next_questionnaire") }}</h3>
@endif
</div>
@endif
</div>
Loading

0 comments on commit 7449470

Please sign in to comment.