Skip to content

Commit

Permalink
Can optionally show question URL's with or without pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
kreut committed Mar 16, 2023
1 parent 245cdab commit f4ff76e
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 15 deletions.
39 changes: 39 additions & 0 deletions app/Http/Controllers/AssignmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,45 @@ function gradersCanSeeStudentNames(Assignment $assignment, int $gradersCanSeeStu
return $response;
}

/**
* @param Assignment $assignment
* @return array
* @throws Exception
*/
public
function questionUrlView(Assignment $assignment): array
{

$response['type'] = 'error';
$authorized = Gate::inspect('questionUrlView', $assignment);

if (!$authorized->allowed()) {
$response['message'] = $authorized->message();
return $response;
}

try {
$question_url_view = $assignment->question_url_view === 'assignment' ? 'question' : 'assignment';
$assignment->update(['question_url_view' => $question_url_view]);
$response['type'] = 'info';
$response['question_url_view'] = $question_url_view;
$response['message'] = "The question URL view has been updated.";
} catch (Exception $e) {
$h = new Handler(app());
$h->report($e);
$response['message'] = "There was an error updating the question URL view for <strong>$assignment->name</strong>. Please try again or contact us for assistance.";
}
return $response;
}


/**
* @param Request $request
* @param Assignment $assignment
* @param int $showScores
* @return array
* @throws Exception
*/
public
function showScores(Request $request, Assignment $assignment, int $showScores)
{
Expand Down Expand Up @@ -1085,6 +1123,7 @@ function viewQuestionsInfo(Request $request,
'show_points_per_question' => $assignment->show_points_per_question,
'solutions_released' => $assignment->solutions_released,
'show_scores' => $assignment->show_scores,
'question_url_view' => $assignment->question_url_view,
'shown' => !(Auth::user()->role === 3 && !$is_fake_student) || Helper::isAnonymousUser() || $assignment->shown,
'scoring_type' => $assignment->scoring_type,
'students_can_view_assignment_statistics' => $assignment->students_can_view_assignment_statistics,
Expand Down
13 changes: 13 additions & 0 deletions app/Policies/AssignmentPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ class AssignmentPolicy
use HandlesAuthorization;
use CommonPolicies;

/**
* @param User $user
* @param Assignment $assignment
* @return Response
*/
public function questionUrlView(User $user, Assignment $assignment): Response
{
return $assignment->course->user_id === $user->id
? Response::allow()
: Response::deny('You are not allowed to update the question URL view for this assignment.');

}

/**
* @param User $user
* @param Assignment $assignment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateQuestionUrlViewToAssignments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('assignments', function (Blueprint $table) {
$table->string('question_url_view')
->after('solutions_availability')
->default('assignment');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('assignments', function (Blueprint $table) {
$table->dropColumn('question_url_view');
});
}
}
2 changes: 1 addition & 1 deletion resources/js/components/AssignmentProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ export default {
this.showHintPenalty = this.form.can_view_hint === 1
this.showMinimumNumberOfSuccessfulAssessments = this.form.learning_tree_success_criteria === 'assessment based'
this.showMinimumNumberOfSuccessfulBranches = this.form.learning_tree_success_level === 'branch'
if (this.isFormativeAssignment){
if (this.isFormativeAssignment) {
this.form.formative = '1'
}
})
Expand Down
54 changes: 54 additions & 0 deletions resources/js/components/QuestionUrlViewToggle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<div>
<toggle-button
tabindex="0"
:width="115"
:value="assignment.question_url_view==='question'"
:sync="true"
:font-size="14"
:color="toggleColors"
:aria-label="assignment.question_url_view==='question' ? `Just the question for ${assignment.name} are shown` : `The entire assignment for ${assignment.name} is shown`"
:labels="{checked: 'Question', unchecked: 'Assignment'}"
@change="submitQuestionUrlView()"
/>
</div>
</template>

<script>
import axios from 'axios'
import { ToggleButton } from 'vue-js-toggle-button'
export default {
components: { ToggleButton },
props: {
assignment:
{
type: Object,
default: function () {
}
}
},
data: () => ({
assessmentType: '',
toggleColors: window.config.toggleColors
}),
methods: {
async submitQuestionUrlView () {
try {
const { data } = await axios.patch(`/api/assignments/${this.assignment.id}/question-url-view`)
this.$noty[data.type](data.message)
if (data.type === 'info'){
this.assignment.question_url_view = data.question_url_view
}
} catch (error) {
this.$noty.error(error.message)
}
}
}
}
</script>

<style scoped>
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
color="#007BFF"
background="#FFFFFF"
/>
<PageTitle v-if="!isLoading" title="Control Panel"/>
<PageTitle v-if="!isLoading" title="Control Panel" />
<div v-if="!isLoading">
<b-form-group
id="scores"
Expand All @@ -19,7 +19,7 @@
label-for="scores"
>
<b-form-row class="mt-2">
<ShowScoresToggle :key="`show-scores-toggle-${assignment.id}`" :assignment="assignment"/>
<ShowScoresToggle :key="`show-scores-toggle-${assignment.id}`" :assignment="assignment" />
</b-form-row>
</b-form-group>
<b-form-group
Expand All @@ -30,7 +30,7 @@
label-for="solutions"
>
<b-form-row class="mt-2">
<ShowSolutionsToggle :key="`show-solutions-toggle-${assignment.id}`" :assignment="assignment"/>
<ShowSolutionsToggle :key="`show-solutions-toggle-${assignment.id}`" :assignment="assignment" />
</b-form-row>
</b-form-group>
<b-form-group
Expand All @@ -41,7 +41,9 @@
label-for="statistics"
>
<b-form-row class="mt-2">
<StudentsCanViewAssignmentStatisticsToggle :key="`students-can-view-assignment-statistics-toggle-${assignment.id}`" :assignment="assignment"/>
<StudentsCanViewAssignmentStatisticsToggle
:key="`students-can-view-assignment-statistics-toggle-${assignment.id}`" :assignment="assignment"
/>
</b-form-row>
</b-form-group>
<b-form-group
Expand All @@ -52,20 +54,21 @@
label-for="points_per_question"
>
<b-form-row class="mt-2">
<ShowPointsPerQuestionToggle :key="`show-points-per-question-toggle-${assignment.id}`" :assignment="assignment"/>
<ShowPointsPerQuestionToggle :key="`show-points-per-question-toggle-${assignment.id}`"
:assignment="assignment"
/>
</b-form-row>
</b-form-group>
<b-form-group
v-if="user.role === 2"
id="graders_can_see_student_names"
label-cols-sm="4"
label-cols-lg="3"
ab
>
<template slot="label">
<template v-slot:label>
Student Names

<QuestionCircleTooltip :id="'viewable-by-graders-tooltip'"/>
<QuestionCircleTooltip :id="'viewable-by-graders-tooltip'" />
<b-tooltip target="viewable-by-graders-tooltip"
delay="500"
triggers="hover focus"
Expand All @@ -75,7 +78,30 @@
</b-tooltip>
</template>
<b-form-row class="mt-2">
<GradersCanSeeStudentNamesToggle :key="`graders-can-see-student-names-toggle-${assignment.id}`" :assignment="assignment"/>
<GradersCanSeeStudentNamesToggle :key="`graders-can-see-student-names-toggle-${assignment.id}`"
:assignment="assignment"
/>
</b-form-row>
</b-form-group>
<b-form-group
id="question_url_view"
label-cols-sm="4"
label-cols-lg="3"
label-for="question_url_view"
>
<template v-slot:label>
Question URL View
<QuestionCircleTooltip id="question-url-view-tooltip" />
<b-tooltip target="question-url-view-tooltip"
delay="500"
triggers="hover focus"
>
You can provide your students with a URL taking them directly to any question in the assignment, found within a given question's properties. From this question you can either show the entire assignment
or just limit the view to that specific question.
</b-tooltip>
</template>
<b-form-row class="mt-2">
<QuestionUrlViewToggle :key="`question-url-view-toggle-${assignment.id}`" :assignment="assignment" />
</b-form-row>
</b-form-group>
</div>
Expand All @@ -93,6 +119,8 @@ import ShowSolutionsToggle from '~/components/ShowSolutionsToggle'
import StudentsCanViewAssignmentStatisticsToggle from '~/components/StudentsCanViewAssignmentStatisticsToggle'
import ShowPointsPerQuestionToggle from '~/components/ShowPointsPerQuestionToggle'
import GradersCanSeeStudentNamesToggle from '~/components/GradersCanSeeStudentNamesToggle'
import QuestionUrlViewToggle from '~/components/QuestionUrlViewToggle.vue'
export default {
middleware: 'auth',
components: {
Expand All @@ -101,7 +129,8 @@ export default {
ShowSolutionsToggle,
StudentsCanViewAssignmentStatisticsToggle,
ShowPointsPerQuestionToggle,
GradersCanSeeStudentNamesToggle
GradersCanSeeStudentNamesToggle,
QuestionUrlViewToggle
},
metaInfo () {
return { title: 'Assignment Control Panel' }
Expand Down
20 changes: 18 additions & 2 deletions resources/js/pages/instructors/assignments.index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
<th v-if="view === 'control panel'" scope="col">
Points Per Question
</th>
<th v-if="view === 'control panel' && user.role ===2" scope="col">
<th v-if="view === 'control panel' && user.role ===2" scope="col" style="width:170px">
Student Names
<QuestionCircleTooltip :id="'viewable-by-graders-tooltip'"/>
<b-tooltip target="viewable-by-graders-tooltip"
Expand All @@ -382,6 +382,17 @@
conscious or subconscious bias.
</b-tooltip>
</th>
<th v-if="view === 'control panel' && user.role ===2" scope="col">
Question URL View
<QuestionCircleTooltip id="question-url-view-tooltip"/>
<b-tooltip target="question-url-view-tooltip"
delay="500"
triggers="hover focus"
>
You can provide your students with a URL taking them directly to any question in the assignment, found within a given question's properties. From this question you can either show the entire assignment
or just limit the view to that specific question.
</b-tooltip>
</th>
<th v-if="view === 'main view' && [2,4].includes(user.role)" scope="col">
Shown
</th>
Expand Down Expand Up @@ -522,6 +533,9 @@
/>
</div>
</td>
<td v-if="view === 'control panel' && user.role === 2">
<QuestionUrlViewToggle :key="`question-url-view-toggle-${assignment.id}`" :assignment="assignment" />
</td>
<td v-if="view === 'main view' && [2,4].includes(user.role)">
<div v-if="isFormative (assignment)">
N/A
Expand Down Expand Up @@ -710,10 +724,12 @@ import StudentsCanViewAssignmentStatisticsToggle from '~/components/StudentsCanV
import ShowPointsPerQuestionToggle from '~/components/ShowPointsPerQuestionToggle'
import GradersCanSeeStudentNamesToggle from '~/components/GradersCanSeeStudentNamesToggle'
import { fixInvalid } from '~/helpers/accessibility/FixInvalid'
import QuestionUrlViewToggle from '~/components/QuestionUrlViewToggle.vue'
export default {
middleware: 'auth',
components: {
QuestionUrlViewToggle,
ToggleButton,
Loading,
AssignmentProperties,
Expand All @@ -725,7 +741,7 @@ export default {
ShowSolutionsToggle,
StudentsCanViewAssignmentStatisticsToggle,
ShowPointsPerQuestionToggle,
GradersCanSeeStudentNamesToggle
GradersCanSeeStudentNamesToggle,
},
data: () => ({
ownsAllQuestions: false,
Expand Down
7 changes: 5 additions & 2 deletions resources/js/pages/questions.view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@
<b-tooltip target="summative-qr-code-tooltip" delay="250"
triggers="hover focus"
>
If logged in, students can summatively attempt this question by using this QR code. You can copy the code by right-clicking it.
If logged in, students can summatively attempt this question by using this QR code. You can copy the
code by right-clicking it.
</b-tooltip>
<div id="qrCodeCanvas" ref="qrCodeCanvas" class="ml-2"/>
</div>
Expand Down Expand Up @@ -1707,7 +1708,7 @@
>
<b-pagination
v-if="(inIFrame && questionNumbersShownInIframe)
|| (!inIFrame && (assessmentType !== 'clicker' || (isInstructor() && !presentationMode) || pastDue))"
|| (!inIFrame && questionNumbersShownOutOfIframe && (assessmentType !== 'clicker' || (isInstructor() && !presentationMode) || pastDue))"
v-model="currentPage"
:total-rows="questions.length"
:per-page="perPage"
Expand Down Expand Up @@ -2806,6 +2807,7 @@ export default {
CloneQuestion
},
data: () => ({
questionNumbersShownOutOfIframe: true,
formativeQuestionURL: '',
technologySrcDoc: '',
confirmDeleteOpenEndedSubmissionsMessage: '',
Expand Down Expand Up @@ -5651,6 +5653,7 @@ export default {
this.canViewHint = assignment.can_view_hint
this.hintPenaltyIfShownHint = assignment.hint_penalty
this.questionNumbersShownInIframe = assignment.question_numbers_shown_in_iframe
this.questionNumbersShownOutOfIframe = this.user.role !== 3 || (assignment.question_url_view === 'assignment' || (assignment.question_url_view === 'question' && !this.$route.params.questionId))
if (this.user.role === 3) {
if (this.isLMS && !assignment.lti_launch_exists) {
this.launchThroughLMSMessage = true
Expand Down
2 changes: 2 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@
Route::post('/assignments/{assignment}/create-assignment-from-template', 'AssignmentController@createAssignmentFromTemplate');
Route::patch('/assignments/{assignment}/show-assignment-statistics/{showAssignmentStatistics}', 'AssignmentController@showAssignmentStatistics');
Route::patch('/assignments/{assignment}/show-scores/{showScores}', 'AssignmentController@showScores');
Route::patch('/assignments/{assignment}/question-url-view', 'AssignmentController@questionUrlView');

Route::patch('/assignments/{assignment}/graders-can-see-student-names/{gradersCanSeeStudentNames}', 'AssignmentController@gradersCanSeeStudentNames');
Route::patch('/assignments/{assignment}/show-points-per-question/{showPointsPerQuestion}', 'AssignmentController@showPointsPerQuestion');
Route::patch('/assignments/{assignment}/solutions-released/{solutionsReleased}', 'AssignmentController@solutionsReleased');
Expand Down
Loading

0 comments on commit f4ff76e

Please sign in to comment.