Ejemplo n.º 1
0
 public function saveBiography($character)
 {
     $question_ids = Input::get('ids');
     $replies = Input::get('replies');
     if ($character) {
         foreach ($question_ids as $index => $q) {
             $response = CharacterQuestionnaire::firstOrNew(['character_id' => $character->id, 'questionnaire_id' => $q]);
             $response->response = $replies[$index];
             $response->save();
         }
         if (Input::hasFile('backstory')) {
             $file = Input::file('backstory');
             $fileName = preg_replace("([^\\w\\d\\-_~,;:\\[\\]\\(\\).])", '', $character->name . "Backstory." . $file->getClientOriginalExtension());
             $file->move(public_path() . '/content/backstories/', $fileName);
             $character->backstory_file = $fileName;
             $character->save();
         }
         if ($character->active || $character->in_review) {
             //Find the relevant forum post and bump it (or create it if it doesn't exist)
             $post = ForumPost::where('body', "[[questionnaire/{$character->id}]]")->first();
             if ($post) {
                 $topic = $post->topic;
                 $topic->postReply($character->owner->id, "Questionnaire responses updated. (Automatic system post)");
             } else {
                 //42 = Character Backgrounds
                 $topic = Forum::find(42)->post("Character Biography for " . $character->name, "[[questionnaire/{$character->id}]]");
                 $topic->markAsRead(Auth::user());
             }
             return Redirect::to("/forums/topic/" . $topic->id);
         } else {
             return Redirect::to("/dashboard/characters");
         }
     } else {
         return Response::json(["success" => false, "message" => "Character could not be found."]);
     }
 }
		<tbody>
			@foreach(Character::activeCharacters()->orderBy('name')->get() as $c)
			<?php 
//Find the relevant thread
$topic = ForumPost::where('body', "[[questionnaire/{$c->id}]]")->first();
?>
			<tr>
				<td>
					@if($topic) 
						<a href="/forums/topic/{{$topic->topic->id}}">{{$c->name}}</a> 
					@else 
						{{$c->name}} 
					@endif
				</td>
				<?php 
$biographies = CharacterQuestionnaire::where('character_id', $c->id)->where('response', '!=', '')->get();
$experience = CharacterBiographyExperience::where('character_id', $c->id)->first();
?>
				<td>
					{{$biographies->count()}}
				</td>
				<td>
					@if($c->backstory_file)
						<a href="/content/backstories/{{$c->backstory_file}}">
							<i class="icon-book"></i>
						</a>
					@endif
				</td>
				<td>
					@if($experience && $experience->questionnaire_xp)
						<i class='icon-check'></i>
Ejemplo n.º 3
0
@stop
@section('dashboard-content')
<div class="row left">
	<h2 class="character-title">Character Biography</h2>	
	<p>
		Please answer the following questions with as much information as you're comfortable giving. 
		This questionnaire is worth an experience point when all ten questions are filled out. 
		You can come back and edit your entries, but you only receive experience for the first time.
	</p>
	<form action="/dashboard/character/{{$character->id}}/biography/submit" method="post" enctype="multipart/form-data">
		@foreach(RulebookQuestionnaire::all() as $index => $q) 
			<div class="panel">
				<b>{{$index + 1}}. {{$q->question}}</b>
				<input type="hidden" name="ids[]" value="{{$q->id}}" />
				<?php 
$response = CharacterQuestionnaire::where(['character_id' => $character->id, 'questionnaire_id' => $q->id])->first();
?>
				<textarea name="replies[]" class="questionnaire-reply">
					{{$response ? $response->response : ""}}
				</textarea>
			</div>
		@endforeach
		<div class="panel">
			<b>If you have a backstory for your character, upload it here.</b>
			{{ Form::file('backstory'); }}
		</div>
		<input type="submit" class="button small success" value="Submit" />
	</form>
</div>

@stop