diff --git a/app/Console/Commands/backupS3Files.php b/app/Console/Commands/backupS3Files.php
deleted file mode 100644
index 9e0e895db..000000000
--- a/app/Console/Commands/backupS3Files.php
+++ /dev/null
@@ -1,119 +0,0 @@
- config('myconfig.telegram_channel_id'),
- 'parse_mode' => 'HTML',
- 'text' => $message
- ]);
-
- }
-
- /**
- * Execute the console command.
- *
- * @return int
- * @throws \Throwable
- */
- public function handle()
- {
-
- try {
- $command = "/usr/local/bin/aws s3 ls s3://libretexts/assignments/ --profile default --output json";
- exec($command, $output, $return_var);
- if ($return_var !== 0) {
- $this->sendTelegramMessage("Unable to get the assignments for the s3 backup with return var $return_var");
- exit;
- }
- $s3_assignments = [];
- foreach ($output as $value) {
- $value = str_replace('PRE', '', $value);
- $value = str_replace(' ', '', $value);
- $folder = str_replace('/', '', $value);
- $s3_assignments[] = $folder;
- }
- $local_assignments = [];
- $iterator = new DirectoryIterator('/var/www/dev.adapt/storage/s3_backups/assignments');
- foreach ($iterator as $fileinfo) {
- if (!$fileinfo->isDot()) {
- $local_assignments[$fileinfo->getBasename()] = $fileinfo->getPathname();
- }
- }
- echo "Removing local assignments\r\n";
- foreach ($local_assignments as $assignment_id => $local_assignment) {
- if (!in_array($assignment_id, $s3_assignments)) {
-
- $command = "rm -rf $local_assignment";
- exec($command, $output, $return_var);
- echo "Removed Local $local_assignment\r\n";
- if ($return_var !== 0) {
- $this->sendTelegramMessage("Unable to remove folder from Local: Assignment $assignment_id");
- exit;
- }
- $command = "/usr/local/bin/aws s3 rm s3://adapt/assignments/$assignment_id --recursive --endpoint=https://sfo3.digitaloceanspaces.com --profile digital_ocean";
- exec($command, $output, $return_var);
- if ($return_var !== 0) {
- $this->sendTelegramMessage("Unable to remove folder from Digital Ocean: Assignment $assignment_id");
- exit;
- }
- echo "Removed Digital Ocean $local_assignment\r\n";
- }
- }
- echo "Syncing from S3\r\n";
- $command = "/usr/local/bin/aws s3 sync s3://libretexts /var/www/dev.adapt/storage/s3_backups --profile default";
- exec($command, $output, $return_var);
- if ($return_var !== 0) {
- $this->sendTelegramMessage("Unable to get the folders for the s3 backup with return var $return_var");
- exit;
- }
- echo "Backing up to Digital Ocean Spaces\r\n";
- $command = "/usr/local/bin/aws s3 sync /var/www/dev.adapt/storage/s3_backups s3://adapt --endpoint=https://sfo3.digitaloceanspaces.com --profile digital_ocean";
- exec($command, $output, $return_var);
- echo "Return var: $return_var\r\n";
- if ($return_var !== 0) {
- $this->sendTelegramMessage("Unable to sync back to Digital Ocean Spaces with return var $return_var");
- exit;
- }
-
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- }
- }
-}
diff --git a/app/Console/Commands/emailInstructorsWithConcludedCourses.php b/app/Console/Commands/emailInstructorsWithConcludedCourses.php
deleted file mode 100644
index f5956f5b5..000000000
--- a/app/Console/Commands/emailInstructorsWithConcludedCourses.php
+++ /dev/null
@@ -1,83 +0,0 @@
-concludedCourses('equals', $num_day);
- if ($concluded_courses->isNotEmpty()) {
- $beauty_mail = app()->make(Beautymail::class);
- foreach ($concluded_courses as $concluded_course) {
- $concluded_course->num_days = $num_day;
- $concluded_course->reset_course_link = request()->getSchemeAndHttpHost() . "/instructors/courses/$concluded_course->id/properties/reset";
- $beauty_mail->send('emails.reset_course', (array)$concluded_course, function ($message)
- use ($concluded_course) {
- $message
- ->from('adapt@noreply.libretexts.org', 'ADAPT')
- ->to($concluded_course->email)
- ->subject('Grading');
- });
- if ($num_day === 100) {
- $concluded_course->courses_to_reset_link = request()->getSchemeAndHttpHost() . "/control-panel/courses-to-reset";
- $beauty_mail->send('emails.100_day_reset_course', (array)$concluded_course, function ($message)
- use ($concluded_course) {
- $message
- ->from('adapt@noreply.libretexts.org', 'ADAPT')
- ->to('delmar@libretexts.org')
- ->subject("$concluded_course->name should be reset");
- });
- }
- }
- }
- }
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- return 1;
- }
- return 0;
- }
-}
diff --git a/app/Course.php b/app/Course.php
deleted file mode 100644
index 4354ee036..000000000
--- a/app/Course.php
+++ /dev/null
@@ -1,535 +0,0 @@
-hasManyThrough('App\Score', 'App\Assignment');
- }
-
- /**
- * @throws Exception
- */
- public function concludedCourses(string $operator_text, int $num_days): Collection
- {
-
- $concluded_courses = DB::table('courses')
- ->join('enrollments', 'courses.id', '=', 'enrollments.course_id')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->select('courses.id',
- 'courses.name',
- 'courses.user_id',
- 'courses.end_date')
- ->where('users.fake_student', 0);
- switch ($operator_text) {
- case('more-than'):
- $concluded_courses = $concluded_courses->where('end_date', '<', Carbon::now()->subDays($num_days));
- break;
- case('equals'):
- $concluded_courses = $concluded_courses->where(DB::raw('DATE(`end_date`)'), '=', Carbon::now()->subDays($num_days)->toDateString());
- break;
- default:
- throw new Exception ("$operator_text is not a valid operator.");
- }
- $concluded_courses = $concluded_courses
- ->groupBy('courses.id')
- ->orderBy('end_date', 'desc')
- ->get();
- $course_ids = [];
- foreach ($concluded_courses as $course_info) {
- $course_ids[] = $course_info->id;
- }
- $course_infos = DB::table('courses')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->select('courses.id',
- 'users.email',
- 'first_name',
- DB::raw('CONCAT(first_name, " " , last_name) AS instructor'))
- ->whereIn('courses.id', $course_ids)
- ->get();
- $courses = [];
- foreach ($course_infos as $course_info) {
- $courses[$course_info->id] = $course_info;
- }
- foreach ($concluded_courses as $key => $concluded_course) {
- if ($courses[$concluded_course->id]->email === 'adapt@libretexts.org') {
- unset($concluded_courses[$key]);
- } else {
- $concluded_courses[$key]->email = $courses[$concluded_course->id]->email;
- $concluded_courses[$key]->first_name = $courses[$concluded_course->id]->first_name;
- $concluded_courses[$key]->instructor = $courses[$concluded_course->id]->instructor;
- }
- }
- return $concluded_courses->values();
- }
-
- /**
- * @return Collection
- */
- public function betaCoursesInfo()
- {
- return DB::table('beta_courses')
- ->join('courses', 'beta_courses.id', '=', 'courses.id')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->where('alpha_course_id', $this->id)
- ->select('courses.name',
- DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_name"),
- 'users.email'
- )
- ->get();
-
- }
-
- /**
- * @return bool
- */
- public function isBetaCourse()
- {
- return DB::table('beta_courses')->where('id', $this->id)->first() !== null;
-
- }
-
-
- public function betaAssignmentIds()
- {
- $beta_assignment_ids = [];
- $beta_assignments = DB::table('assignments')
- ->join('beta_assignments', 'assignments.id', '=', 'beta_assignments.id')
- ->where('assignments.course_id', $this->id)
- ->get();
-
- if ($beta_assignments) {
- foreach ($beta_assignments as $beta_assignment) {
- $beta_assignment_ids[] = $beta_assignment->id;
- }
- }
- return $beta_assignment_ids;
- }
-
- public function school()
- {
- return $this->belongsTo('App\School');
- }
-
- public function extraCredits()
- {
- return $this->hasMany('App\ExtraCredit');
- }
-
- public function headGrader()
- {
- return $this->hasOne('App\HeadGrader');
- }
-
- public function sections()
- {
- return $this->hasMany('App\Section');
- }
-
- public function graderNotifications()
- {
- return $this->hasOne('App\GraderNotification');
- }
-
- /**
- * @return Collection
- */
- public function assignmentGroups(): Collection
- {
- $default_assignment_groups = AssignmentGroup::where('user_id', 0)->select()->get();
- $course_assignment_groups = AssignmentGroup::where('user_id', Auth::user()->id)
- ->where('course_id', $this->id)
- ->select()
- ->get();
- $assignmentGroup = new AssignmentGroup();
- return $assignmentGroup->combine($default_assignment_groups, $course_assignment_groups);
-
- }
-
- public function assignmentGroupWeights()
- {
-
- $assignment_group_ids = DB::table('assignments')
- ->select('assignment_group_id')
- ->where('course_id', $this->id)
- ->groupBy('assignment_group_id')
- ->select('assignment_group_id')
- ->pluck('assignment_group_id')
- ->toArray();
-
- return DB::table('assignment_group_weights')
- ->join('assignment_groups', 'assignment_group_weights.assignment_group_id', '=', 'assignment_groups.id')
- ->whereIn('assignment_group_id', $assignment_group_ids)
- ->where('assignment_group_weights.course_id', $this->id)
- ->groupBy('assignment_group_id', 'assignment_group_weights.assignment_group_weight')
- ->select('assignment_group_id AS id', 'assignment_groups.assignment_group', 'assignment_group_weights.assignment_group_weight')
- ->get();
-
- }
-
- public function enrolledUsers()
- {
-
- return $this->hasManyThrough('App\User',
- 'App\Enrollment',
- 'course_id', //foreign key on enrollments table
- 'id', //foreign key on users table
- 'id', //local key in courses table
- 'user_id')
- ->where('fake_student', 0)
- ->orderBy('enrollments.id'); //local key in enrollments table
- }
-
- public function orderCourses(array $ordered_courses)
- {
- foreach ($ordered_courses as $key => $course_id) {
- DB::table('courses')
- ->where('id', $course_id)//validation step!
- ->update(['order' => $key + 1]);
- }
- }
-
- /**
- * @return array
- */
- public function sectionEnrollmentsByUser()
- {
- $enrolled_user_ids = $this->enrolledUsers->pluck('id')->toArray();
- $enrollments = DB::table('enrollments')
- ->join('sections', 'enrollments.section_id', '=', 'sections.id')
- ->where('enrollments.course_id', $this->id)
- ->whereIn('enrollments.user_id', $enrolled_user_ids)
- ->select('user_id', 'sections.name', 'sections.crn')
- ->get();
- $enrolled_users_by_section = [];
- foreach ($enrollments as $enrollment) {
- $enrolled_users_by_section[$enrollment->user_id] = [
- 'crn' => $enrollment->crn,
- 'course_section' => "$this->name - $enrollment->name"
- ];
- }
- return $enrolled_users_by_section;
- }
-
- public function enrolledUsersWithFakeStudent()
- {
-
- return $this->hasManyThrough('App\User',
- 'App\Enrollment',
- 'course_id', //foreign key on enrollments table
- 'id', //foreign key on users table
- 'id', //local key in courses table
- 'user_id')
- ->orderBy('enrollments.id'); //local key in enrollments table
- }
-
- public function extensions()
- {
- return $this->hasManyThrough('App\Extension',
- 'App\Assignment',
- 'course_id', //foreign key on assignments table
- 'assignment_id', //foreign key on extensions table
- 'id', //local key in courses table
- 'id'); //local key in assignments table
- }
-
- public function assignments()
- {
- return Auth::user() && Auth::user()->role === 3
- ? $this->hasMany('App\Assignment')
- : $this->hasMany('App\Assignment')->orderBy('order');
- }
-
-
- public function enrollments()
- {
- return $this->hasMany('App\Enrollment');
- }
-
- public function fakeStudent()
- {
- $fake_student_user_id = DB::table('enrollments')->join('courses', 'enrollments.course_id', '=', 'courses.id')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->where('course_id', $this->id)
- ->where('fake_student', 1)
- ->select('users.id')
- ->pluck('id')
- ->first();
- return User::find($fake_student_user_id);
- }
-
- public function fakeStudentIds()
- {
- return DB::table('enrollments')->join('courses', 'enrollments.course_id', '=', 'courses.id')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->where('course_id', $this->id)
- ->where('fake_student', 1)
- ->select('users.id')
- ->get()
- ->pluck('id')
- ->toArray();
- }
-
-
- public function finalGrades()
- {
- return $this->hasOne('App\FinalGrade');
- }
-
- public function graderSections($user = null)
- {
- $user = ($user === null) ? Auth::user() : $user;
- return DB::table('graders')
- ->join('sections', 'graders.section_id', '=', 'sections.id')
- ->where('sections.course_id', $this->id)
- ->where('graders.user_id', $user->id)
- ->select('sections.*')
- ->orderBy('sections.name')
- ->get();
-
-
- }
-
- /**
- * @param int $user_id
- * @return array
- */
- public function accessbileAssignmentsByGrader(int $user_id)
- {
-
-
- $cannot_access_assignments = DB::table('assignment_grader_access')
- ->whereIn('assignment_id', $this->assignments->pluck('id')->toArray())
- ->where('user_id', $user_id)
- ->where('access_level', 0)
- ->select('assignment_id')
- ->get();
- $cannot_access_assignment_ids = [];
- foreach ($cannot_access_assignments as $cannot_access_assignment) {
- $cannot_access_assignment_ids[] = $cannot_access_assignment->assignment_id;
- }
- $accessible_assignment_ids = [];
-
- foreach ($this->assignments as $assignment) {
-
- $accessible_assignment_ids[$assignment->id] = !in_array($assignment->id, $cannot_access_assignment_ids);
- }
- return $accessible_assignment_ids;
-
- }
-
- public function contactGraderOverride()
- {
- $contact_grader_override = DB::table('contact_grader_overrides')
- ->where('course_id', $this->id)
- ->first();
- return $contact_grader_override ? $contact_grader_override->user_id : null;
- }
-
- public function graders()
- {
-
- return DB::table('graders')
- ->join('sections', 'graders.section_id', '=', 'sections.id')
- ->join('users', 'graders.user_id', '=', 'users.id')
- ->where('sections.course_id', $this->id)
- ->select('users.id')
- ->groupBy('id')
- ->get();
-
- }
-
- public function graderInfo()
- {
-
- $grader_info = DB::table('graders')
- ->join('sections', 'graders.section_id', '=', 'sections.id')
- ->join('users', 'graders.user_id', '=', 'users.id')
- ->where('sections.course_id', $this->id)
- ->select('users.id AS user_id',
- DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_name"),
- 'email',
- 'sections.name AS section_name',
- 'sections.id as section_id')
- ->get();
- $graders = [];
- foreach ($grader_info as $grader) {
- if (!isset($graders[$grader->user_id])) {
- $graders[$grader->user_id]['user_id'] = $grader->user_id;
- $graders[$grader->user_id]['sections'] = [];
- $graders[$grader->user_id]['name'] = $grader->user_name;
- $graders[$grader->user_id]['email'] = $grader->email;
- }
- $graders[$grader->user_id]['sections'] [$grader->section_id] = $grader->section_name;
- }
- usort($graders, function ($a, $b) {
- return $a['name'] <=> $b['name'];
- });
-
- return array_values($graders);
- }
-
-
- /**
- * @param int $course_id
- * @param int $section_id
- * @param Enrollment $enrollment
- */
- public function enrollFakeStudent(int $course_id, int $section_id, Enrollment $enrollment)
- {
- $fake_student = new User();
- $fake_student->last_name = 'Student';
- $fake_student->first_name = 'Fake';
- $fake_student->time_zone = auth()->user()->time_zone;
- $fake_student->fake_student = 1;
- $fake_student->role = 3;
- $fake_student->save();
-
- //enroll the fake student
- $enrollment->user_id = $fake_student->id;
- $enrollment->section_id = $section_id;
- $enrollment->course_id = $course_id;
- $enrollment->save();
- return $enrollment;
-
-
- }
-
- public function isGrader()
- {
- $graders = DB::table('graders')
- ->join('sections', 'graders.section_id', '=', 'sections.id')
- ->where('sections.course_id', $this->id)
- ->select('user_id')
- ->get()
- ->pluck('user_id')
- ->toArray();
- return (in_array(Auth::user()->id, $graders));
- }
-
- public function assignTosByAssignmentAndUser()
- {
- $assigned_assignments = DB::table('assignments')
- ->join('assign_to_timings', 'assignments.id', '=', 'assign_to_timings.assignment_id')
- ->join('assign_to_users', 'assign_to_timings.id', '=', 'assign_to_users.assign_to_timing_id')
- ->where('assignments.course_id', $this->id)
- ->select('assignments.id AS assignment_id', 'assign_to_users.user_id AS user_id')
- ->get();
- $assigned_assignments_by_assignment_and_user_id = [];
- foreach ($assigned_assignments as $assignment) {
- $assigned_assignments_by_assignment_and_user_id[$assignment->assignment_id][] = $assignment->user_id;
- }
- return $assigned_assignments_by_assignment_and_user_id;
- }
-
- public function assignedToAssignmentsByUser()
- {
- $assigned_assignments = DB::table('assignments')
- ->join('assign_to_timings', 'assignments.id', '=', 'assign_to_timings.assignment_id')
- ->join('assign_to_users', 'assign_to_timings.id', '=', 'assign_to_users.assign_to_timing_id')
- ->where('assignments.course_id', $this->id)
- ->where('assign_to_users.user_id', auth()->user()->id)
- ->get();
- $assigned_assignments_by_id = [];
- foreach ($assigned_assignments as $assignment) {
- $assigned_assignments_by_id[$assignment->assignment_id] = $assignment;
- }
-
- return $assigned_assignments_by_id;
- }
-
- /**
- * @return string
- */
- public function bulkUploadAllowed(): string
- {
- $beta_courses = DB::table('courses')
- ->join('beta_courses', 'courses.id', '=', 'beta_courses.alpha_course_id')
- ->where('courses.id', $this->id)
- ->select('courses.name as name')
- ->get();
- if ($beta_courses->isNotEmpty()) {
- return "Bulk upload is not possible for Alpha courses which already have Beta courses. You can always make a copy of the course and upload these questions to the copied course.";
- }
-
- $course_enrollments = DB::table('courses')
- ->join('enrollments', 'courses.id', '=', 'enrollments.course_id')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->where('courses.id', $this->id)
- ->where('fake_student', 0)
- ->where('courses.user_id', $this->user_id)
- ->select('courses.name as name')
- ->get();
- if ($course_enrollments->isNotEmpty()) {
- return "Bulk upload is only possible for courses without any enrollments. Please make a copy of the course and upload these questions to the copied course.";
- }
- return '';
- }
-
- /**
- * @return Collection
- */
- function publicCourses(): Collection
- {
- $commons_user = DB::table('users')->where('email', 'commons@libretexts.org')->first();
- $commons_courses = DB::table('courses')
- ->where('user_id', $commons_user->id)
- ->where('public', 1)
- ->get('courses.id AS course_id')
- ->pluck('course_id')
- ->toArray();
-
- $public_courses_with_at_least_one_assignment = DB::table('courses')
- ->join('assignments', 'courses.id', '=', 'assignments.course_id')
- ->where('public', 1)
- ->where('courses.user_id', '<>', $commons_user->id)
- ->select('courses.id AS course_id')
- ->groupBy('course_id')
- ->get()
- ->pluck('course_id')
- ->toArray();
- $public_courses_with_at_least_one_question = DB::table('assignment_question')
- ->join('assignments', 'assignment_question.assignment_id', '=', 'assignments.id')
- ->whereIn('assignments.course_id', $public_courses_with_at_least_one_assignment)
- ->select('course_id', DB::raw("COUNT(question_id)"))
- ->groupBy('course_id')
- ->havingRaw("COUNT(question_id) > 0")
- ->get()
- ->pluck('course_id')
- ->toArray();
-
- return DB::table('courses')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->join('schools', 'courses.school_id', '=', 'schools.id')
- ->whereIn('courses.id', $public_courses_with_at_least_one_question)
- ->orWhereIn('courses.id', $commons_courses)
- ->select('courses.id',
- 'courses.name AS name',
- 'schools.name AS school',
- 'term',
- 'alpha',
- DB::raw('CONCAT(first_name, " " , last_name) AS instructor'))
- ->orderBy('name')
- ->get();
- }
-}
diff --git a/app/Http/Controllers/CourseController.php b/app/Http/Controllers/CourseController.php
deleted file mode 100644
index 56c3544ec..000000000
--- a/app/Http/Controllers/CourseController.php
+++ /dev/null
@@ -1,1730 +0,0 @@
-allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $beta_courses = DB::table('beta_courses')->get('id')->pluck('id')->toArray();
- $courses_and_assignments = DB::table('courses')->join('assignments', 'courses.id', '=', 'assignments.course_id')
- ->select('courses.name AS course_name', 'courses.id AS course_id', 'assignments.name AS assignment_name', 'assignments.id AS assignment_id')
- ->where('courses.user_id', $request->user()->id)
- ->whereNotIn('courses.id', $beta_courses)
- ->orderBy('course_name')
- ->orderBy('assignments.order')
- ->get();
- $course_ids = [];
- $courses = [];
- $assignments = [];
- foreach ($courses_and_assignments as $value) {
- if (!in_array($value->course_id, $course_ids)) {
- $courses[] = ['course_id' => $value->course_id, 'course_name' => $value->course_name];
- $assignments[$value->course_id] = [];
- $assignments[$value->course_id]['course_id'] = $value->course_id;
- $assignments[$value->course_id]['assignments'] = [];
- $course_ids[] = $value->course_id;
- }
- $assignments[$value->course_id]['assignments'][] = ['assignment_id' => $value->assignment_id, 'assignment_name' => $value->assignment_name];
- }
- $response['type'] = 'success';
- $response['courses'] = $courses;
- $response['assignments'] = array_values($assignments);
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error getting your courses and assignments.";
- }
- return $response;
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public function getCommonsCoursesAndAssignments(Course $course): array
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('getCommonsCoursesAndAssignments', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $commons_user = User::where('email', 'commons@libretexts.org')->first();
- $commons_courses_and_assignments = DB::table('assignments')
- ->join('courses', 'assignments.course_id', '=', 'courses.id')
- ->select('assignments.id AS assignment_id',
- 'courses.id AS course_id',
- 'assignments.name AS assignment_name',
- 'courses.name AS course_name')
- ->where('courses.user_id', $commons_user->id)
- ->orderBy('course_name')
- ->orderBy('assignment_name')
- ->get();
- $response['commons_courses_and_assignments'] = $commons_courses_and_assignments;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error getting the Commons courses and assignments.";
- }
- return $response;
-
-
- }
-
-
- /**
- * @param ResetCourse $request
- * @param Course $course
- * @param AssignToTiming $assignToTiming
- * @return array
- * @throws Exception
- */
- public
- function reset(ResetCourse $request,
- Course $course,
- AssignToTiming $assignToTiming): array
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('reset', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- $request->validated();
-
- try {
- DB::beginTransaction();
- $fake_student = DB::table('enrollments')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->where('course_id', $course->id)
- ->where('fake_student', 1)
- ->first();
-
- $assignments = $course->assignments;
- $assignment_ids = [];
- foreach ($assignments as $assignment) {
- $assignment_ids[] = $assignment->id;
- $default_timing = $assignToTiming->where('assignment_id', $assignment->id)->first();
- $assignToTiming->deleteTimingsGroupsUsers($assignment);
- $assign_to_timing_id = $assignment->saveAssignmentTimingAndGroup($assignment, $default_timing);
- $assignToUser = new AssignToUser();
- $assignToUser->assign_to_timing_id = $assign_to_timing_id;
- $assignToUser->user_id = $fake_student->user_id;
- $assignToUser->save();
- }
-
- DB::table('submissions')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('submission_files')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('scores')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('cutups')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('seeds')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('compiled_pdf_overrides')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('question_level_overrides')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('assignment_level_overrides')->whereIn('assignment_id', $assignment_ids)->delete();
- //reset all of the LMS stuff
- DB::table('lti_grade_passbacks')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('lti_launches')->whereIn('assignment_id', $assignment_ids)->delete();
- DB::table('assignments')->whereIn('id', $assignment_ids)
- ->update(['lms_resource_link_id' => null]);
-
-
- $course->extensions()->delete();
- $course->extraCredits()->delete();
- DB::table('enrollments')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->where('course_id', $course->id)
- ->where('fake_student', 0)
- ->delete();
- foreach ($assignments as $assignment) {
- DeleteAssignmentDirectoryFromS3::dispatch($assignment->id);
- }
- DB::commit();
-
- $response['type'] = 'success';
- $response['message'] = "All students from $course->name have been unenrolled and their data removed.";
- } catch (Exception $e) {
- DB::rollBack();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error removing all students from $course->name. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- public
- function order(Request $request, Course $course)
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('order', [$course, $request->ordered_courses]);
-
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
-
-
- try {
- DB::beginTransaction();
- $course->orderCourses($request->ordered_courses);
- DB::commit();
- $response['message'] = 'Your courses have been re-ordered.';
- $response['type'] = 'success';
-
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error re-ordering your courses. Please try again or contact us for assistance.";
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function getAllCourses(Course $course): array
- {
-
- $response['type'] = 'error';
- $authorized = Gate::inspect('getAllCourses', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
-
- $response['courses'] = DB::table('courses')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->select('courses.id AS value', DB::raw('CONCAT(courses.name, " --- " ,first_name, " " , last_name) AS label'))
- ->orderBy('label')
- ->get();
-
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = 'We could not get all courses.';
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function open(Course $course): array
- {
-
- $response['type'] = 'error';
- try {
-
- $response['open_courses'] = $course->where('anonymous_users', 1)->get();
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = 'We could not determine whether you can log into the this course as an anonymous user.';
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function canLogIntoCourseAsAnonymousUser(Course $course): array
- {
-
-
- try {
- $response['can_log_into_course_as_anonymous_user'] = (boolean)$course->anonymous_users;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $response['type'] = 'error';
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = 'We could not determine whether you can log into the this course as an anonymous user.';
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function hasH5PQuestions(Course $course)
- {
-
- $response['type'] = 'error';
- try {
- $h5p_questions_exist = DB::table('assignment_question')
- ->join('assignments', 'assignment_question.assignment_id', '=', 'assignments.id')
- ->join('questions', 'assignment_question.question_id', '=', 'questions.id')
- ->where('assignments.course_id', $course->id)
- ->where('questions.technology', 'h5p')
- ->get()
- ->isNotEmpty();
- $response['h5p_questions_exist'] = $h5p_questions_exist;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = 'We could not determine whether this course has H5P questions.';
- }
- return $response;
-
- }
-
- /**
- * @param Request $request
- * @param Assignment $assignment
- * @return array
- * @throws Exception
- */
- public
- function canLogInAsAnonymousUser(Request $request, Assignment $assignment): array
- {
- try {
- $response['type'] = 'error';
- $landing_page = $request->session()->get('landing_page');
- if ($landing_page) {
- $landing_page_array = explode('/', $landing_page);
- /* 0 => ""
- 1 => "assignments"
- 2 => "298"
- 3 => "questions"
- 4 => "view"
- 5 => "98505"
- */
- $anonymous_users = false;
- if (count($landing_page_array) === 6
- && $landing_page_array[1] === 'assignments'
- && is_numeric($landing_page_array[2])
- && $landing_page_array[3] === 'questions'
- && $landing_page_array[4] === 'view'
- && is_numeric($landing_page_array[5])) {
- $course = DB::table('assignments')
- ->join('courses', 'assignments.course_id', '=', 'courses.id')
- ->where('assignments.id', $landing_page_array[2])
- ->first();
- $anonymous_users = (boolean)$course->anonymous_users;
- }
- $response['type'] = 'success';
- $response['anonymous_users'] = $anonymous_users;
- }
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = 'We could not determine whether this course allowed anonymous users.';
- }
- return $response;
-
- }
-
- /**
- * @return array
- * @throws Exception
- */
- public
- function getAnonymousUserCourses(): array
- {
- try {
- $response['enrollments'] = DB::table('courses')
- ->where('courses.anonymous_users', 1)
- ->where('courses.shown', 1)
- ->select('id',
- 'courses.name AS course_section_name',
- 'public_description')
- ->get();
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error getting the courses with anonymous users. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- public
- function updateIFrameProperties(Request $request, Course $course)
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('updateIFrameProperties', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
-
- try {
- $item = $request->item;
- if (!in_array($item, ['attribution', 'assignment', 'submission', 'question_numbers'])) {
- $response['message'] = "$item is not a valid iframe property.";
- return $response;
- }
- $action = $request->action;
- if (!in_array($action, ['show', 'hide'])) {
- $response['message'] = "$action isn't a valid action.";
- return $response;
- }
- $value = ($action === 'show') ? 1 : 0;
- $assignments = DB::table('assignments')->where('course_id', $course->id)->get('id');
- $message = "This course has no assignments.";
- $action_message = ($action === 'show') ? 'shown' : 'hidden';
- $type = "info";
- if ($item === 'question_numbers') {
- DB::table('courses')
- ->where('id', $course->id)
- ->update(['question_numbers_shown_in_iframe' => !$course->question_numbers_shown_in_iframe]);
- $type = ($action === 'show') ? 'success' : 'info';
- $message = "The question numbers will now be $action_message when embedded in an iframe.";
- } else {
- if ($assignments) {
- $assignment_ids = $assignments->pluck('id');
- DB::table('assignment_question')
- ->whereIn('assignment_id', $assignment_ids)
- ->update(["{$item}_information_shown_in_iframe" => $value]);
- $type = ($action === 'show') ? 'success' : 'info';
- $message = "The $item information will now be $action_message when embedded in an iframe.";
- }
- }
- $response['message'] = $message;
- $response['type'] = $type;
- return $response;
-
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to update the iframe properties for your course. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- /**
- * @return array
- * @throws Exception
- */
- public
- function getOpenCourses(): array
- {
- $response['type'] = 'error';
- try {
- $commons_user = User::where('email', 'commons@libretexts.org')->first();
- $open_courses = DB::table('courses')
- ->where('courses.user_id', $commons_user->id)
- ->where('shown', 1)
- ->where('anonymous_users', 1)
- ->select('id',
- 'courses.name AS name',
- 'courses.public_description AS description',
- DB::raw('CONCAT("' . config('app.url') . '/courses/",id,"/anonymous") AS url'))
- ->get();
- $response['open_courses'] = $open_courses;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to see get the courses from the Commons. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @return array
- * @throws Exception
- */
- public
- function getCommonsCourses(): array
- {
- $response['type'] = 'error';
- try {
- $commons_user = User::where('email', 'commons@libretexts.org')->first();
- $commons_courses = DB::table('courses')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->join('schools', 'courses.school_id', '=', 'schools.id')
- ->where('courses.user_id', $commons_user->id)
- ->where('shown', 1)
- ->select('courses.id',
- 'courses.name AS name',
- 'courses.public_description AS description',
- 'schools.name AS school',
- DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS instructor"),
- 'alpha',
- 'anonymous_users')
- ->get();
- $response['commons_courses'] = $commons_courses;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to see get the courses from the Commons. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- public
- function updateBetaApprovalNotifications(Course $course)
- {
-
- $response['type'] = 'error';
- $authorized = Gate::inspect('updateBetaApprovalNotifications', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
-
- try {
- $course->beta_approval_notifications = !$course->beta_approval_notifications;
- $course->save();
- $message_text = $course->beta_approval_notifications ? "now" : "no longer";
- $response['type'] = 'info';
- $response['message'] = "You will $message_text receive daily email notifications of pending approvals.";
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to see whether this course is an Alpha course. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- public
- function getBetaApprovalNotifications(Course $course)
- {
-
- $response['type'] = 'error';
- try {
- $response['beta_approval_notifications'] = $course->beta_approval_notifications;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to see whether this course is an Alpha course. Please try again or contact us for assistance.";
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function getWarnings(Course $course): array
- {
- try {
- $response['alpha'] = $course->alpha;
- $response['formative'] = $course->formative;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to get the course warnings. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- public
- function isAlpha(Course $course)
- {
- try {
- $response['alpha'] = $course->alpha;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to see whether this course is an Alpha course. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- public
- function getLastSchool(Request $request, School $school)
- {
- $response['type'] = 'error';
- try {
- $school_name = '';
- $school_id = 1;
- if ($request->user()->role === 2) {
- $school = DB::table('courses')
- ->join('schools', 'courses.school_id', '=', 'schools.id')
- ->where('user_id', $request->user()->id)
- ->orderBy('courses.created_at', 'desc')
- ->first();
- if ($school && ($school->school_id !== 1)) {
- $school_name = $school->name;
- $school_id = $school->school_id;
- }
- }
- $response['last_school_name'] = $school_name;
- $response['last_school_id'] = $school_id;
- $response['type'] = 'success';
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to get your last school. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @param Course $course
- * @param User|null $instructor
- * @return array
- * @throws Exception
- */
- public
- function getPublicCourses(Course $course, User $instructor = null): array
- {
-
- $response['type'] = 'error';
- try {
- $public_courses = [];
- switch ($instructor) {
- case(true):
- $public_courses = $course->where('public', 1)
- ->where('user_id', $instructor->id)
- ->select('id', 'name')
- ->orderBy('name')
- ->get();
- break;
- case(false):
- $public_courses = $course->publicCourses();
- break;
-
- }
- $response['public_courses'] = $public_courses;
- $response['type'] = 'success';
-
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to get the public courses. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @param Request $request
- * @return array
- * @throws Exception
- */
- public
- function getCoursesAndNonBetaAssignments(Request $request)
- {
-
- $response['type'] = 'error';
- $courses = [];
- $assignments = [];
- try {
- $results = DB::table('courses')
- ->join('assignments', 'courses.id', '=', 'assignments.course_id')
- ->leftJoin('beta_assignments', 'assignments.id', '=', 'beta_assignments.id')
- ->where('courses.user_id', $request->user()->id)
- ->select(DB::raw('courses.id AS course_id'),
- DB::raw('courses.name AS course_name'),
- 'courses.start_date',
- 'courses.end_date',
- 'beta_assignments.id AS beta_assignment_id',
- DB::raw('assignments.id AS assignment_id'),
- DB::raw('assignments.name AS assignment_name'))
- ->orderBy('courses.start_date', 'desc')
- ->get();
- $course_ids = [];
- foreach ($results as $value) {
- $course_id = $value->course_id;
- if (!in_array($course_id, $course_ids)) {
- $courses[] = ['value' => $course_id,
- 'text' => $value->course_name,
- 'start_date' => $value->start_date,
- 'end_date' => $value->end_date];
- $course_ids[] = $course_id;
- }
- if (!$value->beta_assignment_id) {
- $assignments[$course_id][] = ['value' => $value->assignment_id,
- 'text' => $value->assignment_name];
- }
- }
-
- $response['type'] = 'success';
- $response['courses'] = $courses;
- $response['assignments'] = $assignments;
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to get your courses and assignments. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- /**
- * @param Enrollment $enrollment
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function getEnrolledInCoursesAndAssignments(Enrollment $enrollment, Course $course): array
- {
-
- $response['type'] = 'error';
- $authorized = Gate::inspect('view', $enrollment);
-
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- $enrollments = $enrollment->index();
- $enrolled_in_courses_and_assignments = [];
- foreach ($enrollments as $key => $enrollment) {
- $enrolled_in_courses_and_assignments[$key] = [];
- $enrolled_in_courses_and_assignments[$key]['course'] = $enrollment;
- $course = Course::find($enrollment->id);
- $enrolled_in_courses_and_assignments[$key]['assignments'] = $course->assignedToAssignmentsByUser();
- }
-
- try {
- $response['enrolled_in_courses_and_assignments'] = $enrolled_in_courses_and_assignments;
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error getting your enrolled courses and assignments. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- public
- function getCoursesAndAssignments(Request $request)
- {
-
- $response['type'] = 'error';
- $courses = [];
- $assignments = [];
- try {
- $results = DB::table('courses')
- ->join('assignments', 'courses.id', '=', 'assignments.course_id')
- ->where('courses.user_id', $request->user()->id)
- ->select(DB::raw('courses.id AS course_id'),
- DB::raw('courses.name AS course_name'),
- 'courses.lms',
- 'assignments.lms_resource_link_id',
- 'assignments.assessment_type',
- DB::raw('assignments.id AS assignment_id'),
- DB::raw('assignments.name AS assignment_name'))
- ->orderBy('courses.start_date', 'desc')
- ->get();
- $course_ids = [];
- foreach ($results as $value) {
- $course_id = $value->course_id;
- if (!in_array($course_id, $course_ids)) {
- $courses[] = ['value' => $course_id,
- 'text' => $value->course_name,
- 'lms' => $value->lms];
- $course_ids[] = $course_id;
- }
- $assignments[$course_id][] = ['value' => $value->assignment_id,
- 'text' => $value->assignment_name,
- 'lms_resource_link_id' => $value->lms_resource_link_id,
- 'assessment_type' => $value->assessment_type];
- }
-
- $response['type'] = 'success';
- $response['courses'] = $courses;
- $response['assignments'] = $assignments;
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "We were not able to get your courses and assignments. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- /**
- * @param Request $request
- * @param Course $course
- * @param AssignmentGroup $assignmentGroup
- * @param AssignmentGroupWeight $assignmentGroupWeight
- * @param AssignmentSyncQuestion $assignmentSyncQuestion
- * @param Enrollment $enrollment
- * @param FinalGrade $finalGrade
- * @param Section $section
- * @param School $school
- * @param BetaCourse $betaCourse
- * @return array
- * @throws Exception '
- */
- public
- function import(Request $request,
- Course $course,
- AssignmentGroup $assignmentGroup,
- AssignmentGroupWeight $assignmentGroupWeight,
- AssignmentSyncQuestion $assignmentSyncQuestion,
- Enrollment $enrollment,
- FinalGrade $finalGrade,
- Section $section,
- School $school,
- BetaCourse $betaCourse): array
- {
-
- $response['type'] = 'error';
-
- $authorized = Gate::inspect('import', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
-
- if (!in_array($request->action, ['import', 'clone'])) {
- $response['message'] = "$request->action should either be to import or clone.";
- return $response;
- }
- $import_as_beta = (int)$request->import_as_beta;
-
- if ($import_as_beta && !$course->alpha) {
- $response['message'] = "You cannot $request->action this course as a Beta course since the original course is not an Alpha course.";
- return $response;
- }
- $school = $this->getLastSchool($request, $school);
- try {
- DB::beginTransaction();
- $imported_course = $course->replicate();
- $action = $request->action === 'import' ? "Import" : "Copy";
- $imported_course->name = "$imported_course->name " . $action;
- $imported_course->start_date = Carbon::now()->startOfDay();
- $imported_course->end_date = Carbon::now()->startOfDay()->addMonths(3);
- $imported_course->shown = 0;
- $imported_course->public = 0;
- $imported_course->alpha = 0;
- $imported_course->lms = 0;
- $imported_course->anonymous_users = 0;
- $imported_course->school_id = $school['last_school_id'];
- $imported_course->show_z_scores = 0;
- $imported_course->students_can_view_weighted_average = 0;
- $imported_course->user_id = $request->user()->id;
- $imported_course->order = 0;
- $imported_course->save();
- if ($import_as_beta) {
- $betaCourse->id = $imported_course->id;
- $betaCourse->alpha_course_id = $course->id;
- $betaCourse->save();
- }
- foreach ($course->assignments as $assignment) {
- $imported_assignment = $this->cloneAssignment($assignmentGroup, $imported_course, $assignment, $assignmentGroupWeight, $course);
- if ($import_as_beta) {
- BetaAssignment::create([
- 'id' => $imported_assignment->id,
- 'alpha_assignment_id' => $assignment->id
- ]);
- }
- $default_timing = DB::table('assign_to_timings')
- ->join('assign_to_groups', 'assign_to_timings.id', '=', 'assign_to_groups.assign_to_timing_id')
- ->where('assignment_id', $assignment->id)
- ->first();
-
- $assignment->saveAssignmentTimingAndGroup($imported_assignment, $default_timing);
- $assignmentSyncQuestion->importAssignmentQuestionsAndLearningTrees($assignment->id, $imported_assignment->id);
- }
-
- $this->prepareNewCourse($section, $imported_course, $course, $enrollment, $finalGrade);
- $fake_user = DB::table('enrollments')
- ->join('users', 'enrollments.user_id', '=', 'users.id')
- ->where('course_id', $imported_course->id)
- ->where('fake_student', 1)
- ->first();
-
- $assign_to_timings = DB::table('assign_to_timings')
- ->whereIn('assignment_id', $imported_course->assignments->pluck('id')->toArray())
- ->get();
- foreach ($assign_to_timings as $assign_to_timing) {
- $assignToUser = new AssignToUser();
- $assignToUser->assign_to_timing_id = $assign_to_timing->id;
- $assignToUser->user_id = $fake_user->id;
- $assignToUser->save();
- }
- DB::commit();
- $response['type'] = 'success';
- $response['message'] = "$imported_course->name has been created. Don't forget to change the dates associated with this course and all of its assignments.";
-
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error creating the $request->action. Please try again or contact us for assistance.";
- }
- return $response;
-
-
- }
-
- public
- function reOrderAllCourses()
- {
- $courses = $this->getCourses(Auth::user());
- $all_course_ids = [];
- if ($courses) {
- foreach ($courses as $value) {
- $all_course_ids[] = $value->id;
- }
- $course = new Course();
- $course->orderCourses($all_course_ids);
- }
- }
-
- /**
- * @param Request $request
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function getImportable(Request $request, Course $course)
- {
- $response['type'] = 'error';
-
- $authorized = Gate::inspect('getImportable', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $instructor_courses = DB::table('courses')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->where('user_id', $request->user()->id)
- ->select('name',
- DB::raw('CONCAT(first_name, " " , last_name) AS instructor'),
- 'courses.id',
- 'term')
- ->get();
- $public_courses = $course->publicCourses();
-
- $importable_courses = [];
- foreach ($instructor_courses as $course) {
- $importable_courses[] = $course;
- }
- foreach ($public_courses as $course) {
- $importable_courses[] = $course;
- }
- $formatted_importable_courses = [];
- $formatted_course_ids = [];
- $formatted_course_names = [];
- foreach ($importable_courses as $course) {
- if (!in_array($course->id, $formatted_course_ids)) {
- $formatted_course = "$course->name --- $course->instructor";
- if (in_array($formatted_course, $formatted_course_names)) {
- $formatted_course = "$course->name ($course->term) --- $course->instructor";
- }
- $formatted_importable_courses[] = [
- 'course_id' => $course->id,
- 'formatted_course' => $formatted_course
- ];
- $formatted_course_ids[] = $course->id;
- $formatted_course_names[] = $formatted_course;
- }
-
- }
-
- usort($formatted_importable_courses, function ($item1, $item2) {
- return $item1['formatted_course'] <=> $item2['formatted_course'];
- });
-
- $response['type'] = 'success';
- $response['importable_courses'] = $formatted_importable_courses;
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error retrieving the importable courses. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- /**
- * @param Request $request
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function index(Request $request, Course $course)
- {
-
- $response['type'] = 'error';
-
-
- if ($request->session()->get('completed_sso_registration')) {
- \Log::info('Just finished registration.');
- }
- $authorized = Gate::inspect('viewAny', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $response['courses'] = $this->getCourses(auth()->user());
- $response['show_beta_course_dates_warning'] = !$request->hasCookie('show_beta_course_dates_warning');
-
- $response['type'] = 'success';
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error retrieving your courses. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- /**
- * @param Request $request
- * @param Course $course
- * @param AssignmentGroupWeight $assignmentGroupWeight
- * @return array
- * @throws Exception
- */
- public
- function updateShowZScores(Request $request, Course $course, AssignmentGroupWeight $assignmentGroupWeight): array
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('updateShowZScores', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- $response = $assignmentGroupWeight->validateCourseWeights($course);
- if ($response['type'] === 'error') {
- return $response;
- }
- try {
-
- $course->show_z_scores = !$request->show_z_scores;
- $course->save();
-
- $verb = $course->show_z_scores ? "can" : "cannot";
- $response['type'] = $course->show_z_scores ? 'success' : 'info';
- $response['message'] = "Students $verb view their z-scores.";
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error updating the ability for students to view their z-scores. Please try again or contact us for assistance.";
- }
- return $response;
-
-
- }
-
- /**
- * @param Request $request
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function updateShowProgressReport(Request $request, Course $course): array
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('updateShowProgressReport', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
-
- try {
-
- $course->show_progress_report = !$request->show_progress_report;
- $course->save();
-
- $verb = $course->show_progress_report ? "can" : "cannot";
- $response['type'] = $course->show_progress_report ? 'success' : 'info';
- $response['message'] = "Students $verb view their progress reports.";
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error updating the ability for students to view their progress_reports. Please try again or contact us for assistance.";
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function showOpen(Course $course)
- {
-
- $response['type'] = 'error';
- $authorized = Gate::inspect('viewOpen', $course);
- if (!$authorized->allowed()) {
-
- $response['message'] = $authorized->message();
- return $response;
- }
-
- try {
- $response['open_course'] = [
- 'id' => $course->id,
- 'name' => $course->name,
- 'alpha' => $course->alpha];
- $response['type'] = 'success';
-
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error retrieving this open course. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- public
- function updateStudentsCanViewWeightedAverage(Request $request, Course $course, AssignmentGroupWeight $assignmentGroupWeight)
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('updateStudentsCanViewWeightedAverage', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $response = $assignmentGroupWeight->validateCourseWeights($course);
- if ($response['type'] === 'error') {
- return $response;
- }
- $course->students_can_view_weighted_average = !$request->students_can_view_weighted_average;
- $course->save();
-
- $verb = $course->students_can_view_weighted_average ? "can" : "cannot";
- $response['type'] = $course->students_can_view_weighted_average ? 'success' : 'info';
- $response['message'] = "Students $verb view their weighted averages.";
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error updating the ability for students to view their weighted averages. Please try again or contact us for assistance.";
- }
- return $response;
-
-
- }
-
- /**
- * @param Course $course
- * @return array
- * @throws Exception
- */
- public
- function show(Course $course): array
- {
-
- $response['type'] = 'error';
- $authorized = Gate::inspect('view', $course);
- if (!$authorized->allowed()) {
-
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $question_exists_not_owned_by_the_instructor = DB::table('assignment_question')
- ->join('questions', 'assignment_question.question_id', '=', 'questions.id')
- ->whereIn('assignment_id', $course->assignments()->pluck('id')->toArray())
- ->where('question_editor_user_id', '<>', $course->user_id)
- ->first();
- $response['course'] = [
- 'school' => $course->school->name,
- 'name' => $course->name,
- 'public_description' => $course->public_description,
- 'private_description' => $course->private_description,
- 'textbook_url' => $course->textbook_url,
- 'term' => $course->term,
- 'students_can_view_weighted_average' => $course->students_can_view_weighted_average,
- 'letter_grades_released' => $course->finalGrades->letter_grades_released,
- 'sections' => $course->sections,
- 'show_z_scores' => $course->show_z_scores,
- 'graders' => $course->graderInfo(),
- 'start_date' => $course->start_date,
- 'end_date' => $course->end_date,
- 'public' => $course->public,
- 'lms' => $course->lms,
- 'question_numbers_shown_in_iframe' => (bool)$course->question_numbers_shown_in_iframe,
- 'show_progress_report' => $course->show_progress_report,
- 'owns_all_questions' => !$question_exists_not_owned_by_the_instructor,
- 'alpha' => $course->alpha,
- 'anonymous_users' => $course->anonymous_users,
- 'formative' => $course->formative,
- 'contact_grader_override' => $course->contactGraderOverride(),
- 'is_beta_course' => $course->isBetaCourse(),
- 'beta_courses_info' => $course->betaCoursesInfo()];
- $response['type'] = 'success';
-
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error retrieving your course. Please try again or contact us for assistance.";
- }
- return $response;
-
- }
-
- /**
- * @param Course $course
- * @param int $shown
- * @return array
- * @throws Exception
- */
- public
- function showCourse(Course $course, int $shown): array
- {
-
- $response['type'] = 'error';
- $authorized = Gate::inspect('showCourse', $course);
-
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
-
- try {
- DB::beginTransaction();
- $course->shown = !$shown;
- $course->save();
-
- $response['type'] = !$shown ? 'success' : 'info';
- $shown_message = !$shown ? 'can' : 'cannot';
- $is_commons_user = Auth::user()->email === 'commons@libretexts.org';
- $access_code_message = !$shown || $is_commons_user ? '' : ' In addition, all course access codes have been revoked.';
- $people = $is_commons_user ? "Visitors to the Commons " : "Your students";
- $response['message'] = "$people {$shown_message} view this course.{$access_code_message}";
- DB::commit();
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error showing {$course->name}. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @param $user
- * @return array|\Illuminate\Support\Collection
- */
- public
- function getCourses($user)
- {
-
- switch ($user->role) {
- case(6):
- return DB::table('tester_courses')
- ->join('courses', 'tester_courses.course_id', '=', 'courses.id')
- ->join('users', 'courses.user_id', '=', 'users.id')
- ->where('tester_courses.user_id', $user->id)
- ->select('courses.id',
- 'term',
- 'start_date',
- 'end_date',
- 'courses.name',
- DB::raw('CONCAT(first_name, " ", last_name) AS instructor'))
- ->get();
- case(5):
- case(2):
- return DB::table('courses')
- ->select('courses.*', DB::raw("beta_courses.id IS NOT NULL AS is_beta_course"))
- ->leftJoin('beta_courses', 'courses.id', '=', 'beta_courses.id')
- ->where('user_id', $user->id)
- ->orderBy('order')
- ->get();
- case(4):
- $sections = DB::table('graders')
- ->join('sections', 'section_id', '=', 'sections.id')
- ->where('user_id', $user->id)
- ->get()
- ->pluck('section_id');
-
- $course_section_info = DB::table('courses')
- ->join('sections', 'courses.id', '=', 'sections.course_id')
- ->select('courses.id AS id',
- DB::raw('courses.id AS course_id'),
- 'start_date',
- 'end_date',
- DB::raw('courses.name AS course_name'),
- DB::raw('sections.name AS section_name')
- )
- ->whereIn('sections.id', $sections)->orderBy('start_date', 'desc')
- ->get();
-
- $course_sections = [];
- foreach ($course_section_info as $course_section) {
- if (!isset($course_sections[$course_section->course_id])) {
- $course_sections[$course_section->course_id]['id'] = $course_section->course_id;
- $course_sections[$course_section->course_id]['name'] = $course_section->course_name;
- $course_sections[$course_section->course_id]['start_date'] = $course_section->start_date;
- $course_sections[$course_section->course_id]['end_date'] = $course_section->end_date;
- $course_sections[$course_section->course_id]['sections'] = [];
- }
- $course_sections[$course_section->course_id]['sections'][] = $course_section->section_name;
- }
-
- foreach ($course_sections as $key => $course_section) {
- $course_sections[$key]['sections'] = implode(', ', $course_section['sections']);
- }
- $course_sections = array_values($course_sections);
- return collect($course_sections);
-
- }
- }
-
- /**
- * @param StoreCourse $request
- * @param Course $course
- * @param Enrollment $enrollment
- * @param FinalGrade $finalGrade
- * @param Section $section
- * @param School $school
- * @return array
- * @throws Exception
- */
-
- public
- function store(StoreCourse $request,
- Course $course,
- Enrollment $enrollment,
- FinalGrade $finalGrade,
- Section $section,
- School $school): array
- {
- //todo: check the validation rules
- $response['type'] = 'error';
- $authorized = Gate::inspect('create', $course);
-
- if (!$authorized->allowed()) {
-
- $response['message'] = $authorized->message();
- return $response;
- }
- $is_instructor = $request->user()->role === 2;
- try {
- $data = $request->validated();
- DB::beginTransaction();
- if (!$is_instructor) {
- $data['start_date'] = date("Y-m-d");
- $datetime = new DateTime('+3 months');
- $data['end_date'] = $datetime->format("Y-m-d");
- $data['crn'] = 'N/A';
- $data['section'] = 'N/A';
- $data['term'] = 'N/A';
- $data['alpha'] = 0;
- $data['anonymous_users'] = 0;
- }
- $data['user_id'] =$request->user()->id;
- $data['school_id'] = $is_instructor ? $this->getSchoolIdFromRequest($request, $school) : 1;
- $formative = isset($data['formative']) && $data['formative'];
- if ($formative) {
- $data['start_date'] = $data['end_date'] = date('Y-m-d', time());
- $data['lms'] = 0;
- $data['alpha'] = 0;
- }
-
- $data['start_date'] = $this->convertLocalMysqlFormattedDateToUTC($data['start_date'] . '00:00:00', auth()->user()->time_zone);
- $data['end_date'] = $this->convertLocalMysqlFormattedDateToUTC($data['end_date'] . '00:00:00', auth()->user()->time_zone);
-
- $data['shown'] = 0;
- $data['public_description'] = $request->public_description;
- $data['private_description'] = $request->private_description;
- $data['order'] = 0;
- //create the main section
- $section->name = $formative ? 'Default' : $data['section'];
- $section->crn = $formative ? '' : $data['crn'];
- unset($data['section']);
- unset($data['crn']);
- unset($data['school']);
- //create the course
-
-
- $new_course = $course->create($data);
-
- $section->course_id = $new_course->id;
- $section->save();
- $course->enrollFakeStudent($new_course->id, $section->id, $enrollment);
- $finalGrade->setDefaultLetterGrades($new_course->id);
-
- $this->reOrderAllCourses();
-
- DB::commit();
- $response['type'] = 'success';
- $response['message'] = "The course $request->name has been created.";
- } catch (Exception $e) {
- DB::rollback();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error creating $request->name. Please try again or contact us for assistance.";
- }
-
- return $response;
- }
-
- public
- function getSchoolIdFromRequest(Request $request, School $school)
- {
-
- return $request->school
- ? $school->where('name', $request->school)->first()->id
- : $school->first()->id;
- }
-
- /**
- *
- * Update the specified resource in storage.
- *
- *
- * @param StoreCourse $request
- * @param Course $course
- * @param School $school
- * @param BetaCourse $betaCourse
- * @return array
- * @throws Exception
- */
- public
- function update(StoreCourse $request,
- Course $course,
- School $school,
- BetaCourse $betaCourse): array
- {
- $response['type'] = 'error';
-
- $authorized = Gate::inspect('update', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- $is_beta_course = $betaCourse->where('id', $course->id)->first();
- if ($message = $this->failsTetherCourseValidation($request, $course, $is_beta_course)) {
- $response['message'] = $message;
- return $response;
- }
- try {
- $data = $request->validated();
- DB::beginTransaction();
-
- $data['public_description'] = $request->public_description;
- $data['private_description'] = $request->private_description;
- if ($request->user()->role === 2) {
- $data['school_id'] = $this->getSchoolIdFromRequest($request, $school);
- if (!$request->formative) {
- $data['start_date'] = $this->convertLocalMysqlFormattedDateToUTC($data['start_date'], auth()->user()->time_zone);
- $data['end_date'] = $this->convertLocalMysqlFormattedDateToUTC($data['end_date'], auth()->user()->time_zone);
- }
- $data['textbook_url'] = $request->textbook_url;
- if ($is_beta_course && $request->untether_beta_course) {
- $betaCourse->untether($course);
- }
- unset($data['school']);
- }
- $course->update($data);
- DB::commit();
- $response['type'] = 'success';
- $response['message'] = "The course $course->name has been updated.";
- $response['is_beta_course'] = $betaCourse->where('id', $course->id)->first();
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error updating $course->name. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @param $request
- * @param $course
- * @param $is_beta_course
- * @return string
- */
- public
- function failsTetherCourseValidation($request, $course, $is_beta_course): string
- {
- $message = '';
- $at_least_one_beta_course_exists = BetaCourse::where('alpha_course_id', $course->id)->first();
- if ($course->alpha && (int)$request->alpha === 0 && $at_least_one_beta_course_exists) {
- $message = "You are trying to change an Alpha course into a non-Alpha course but Beta courses are currently tethered to this course.";
- }
- if ((int)$request->alpha === 1 && $is_beta_course) {
- $message = "You can't change a Beta course into an Alpha course.";
- }
- return $message;
- }
-
- /**
- *
- * Delete a course
- *
- * @param DestroyCourse $request
- * @param Course $course
- * @param AssignToTiming $assignToTiming
- * @param BetaAssignment $betaAssignment
- * @param BetaCourse $betaCourse
- * @param BetaCourseApproval $betaCourseApproval
- * @return array
- * @throws Exception
- */
-
- public
- function destroy(DestroyCourse $request,
- Course $course,
- AssignToTiming $assignToTiming,
- BetaAssignment $betaAssignment,
- BetaCourse $betaCourse,
- BetaCourseApproval $betaCourseApproval): array
-
- {
-
-
- $response['type'] = 'error';
-
- $authorized = Gate::inspect('delete', $course);
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- $request->validated();
- if (BetaCourse::where('alpha_course_id', $course->id)->first()) {
- $response['message'] = "You cannot delete an Alpha course with tethered Beta courses.";
- return $response;
- }
-
- try {
- DB::beginTransaction();
- foreach ($course->assignments as $assignment) {
- $assignment_question_ids = DB::table('assignment_question')
- ->where('assignment_id', $assignment->id)
- ->get()
- ->pluck('id');
-
- DB::table('assignment_question_learning_tree')
- ->whereIn('assignment_question_id', $assignment_question_ids)
- ->delete();
- $assignToTiming->deleteTimingsGroupsUsers($assignment);
- $assignment->questions()->detach();
- $assignment->submissions()->delete();
- $assignment->fileSubmissions()->delete();
- $assignment->scores()->delete();
- $assignment->canGiveUps()->delete();
- $assignment->cutups()->delete();
- $assignment->seeds()->delete();
- DB::table('randomized_assignment_questions')
- ->where('assignment_id', $assignment->id)
- ->delete();
- $assignment->graders()->detach();
- $betaAssignment->where('id', $assignment->id)->delete();
-
- DB::table('question_level_overrides')->where('assignment_id', $assignment->id)->delete();
- DB::table('compiled_pdf_overrides')->where('assignment_id', $assignment->id)->delete();
- DB::table('assignment_level_overrides')->where('assignment_id', $assignment->id)->delete();
-
- DB::table('learning_tree_time_lefts')->where('assignment_id', $assignment->id)->delete();
- DB::table('learning_tree_successful_branches')->where('assignment_id', $assignment->id)->delete();
- DB::table('remediation_submissions')->where('assignment_id', $assignment->id)->delete();
- DB::table('assignment_question_time_on_tasks')->where('assignment_id', $assignment->id)->delete();
- DB::table('review_histories')->where('assignment_id', $assignment->id)->delete();
- DB::table('shown_hints')->where('assignment_id', $assignment->id)->delete();
- DB::table('submission_confirmations')->where('assignment_id', $assignment->id)->delete();
- $betaCourseApproval->where('beta_assignment_id', $assignment->id)->delete();
- DeleteAssignmentDirectoryFromS3::dispatch($assignment->id);
- }
- DB::table('grader_notifications')
- ->where('course_id', $course->id)
- ->delete();
- $course->extensions()->delete();
- $course->assignments()->delete();
-
-
- AssignmentGroupWeight::where('course_id', $course->id)->delete();
- AssignmentGroup::where('course_id', $course->id)->where('user_id', Auth::user()->id)->delete();//get rid of the custom assignment groups
- $course->enrollments()->delete();
- foreach ($course->sections as $section) {
- $section->graders()->delete();
- $section->delete();
- }
-
- $course->finalGrades()->delete();
- $betaCourse->where('id', $course->id)->delete();
- DB::table('analytics_dashboards')->where('course_id', $course->id)->delete();
- DB::table('contact_grader_overrides')->where('course_id', $course->id)->delete();
- $course->delete();
- DB::commit();
- $response['type'] = 'info';
- $response['message'] = "The course $course->name has been deleted.";
- } catch (Exception $e) {
- DB::rollBack();
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error removing $course->name. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @param Course $course
- * @param string $operator_text
- * @param int $num_days
- * @return array
- * @throws Exception
- */
- public
- function getCoursesToReset(Course $course, string $operator_text, int $num_days): array
- {
- $response['type'] = 'error';
- $authorized = Gate::inspect('getConcludedCourses', $course);
-
- if (!$authorized->allowed()) {
- $response['message'] = $authorized->message();
- return $response;
- }
- try {
- $response['type'] = 'success';
- $response['courses_to_reset'] = $course->concludedCourses($operator_text, $num_days);
-
- } catch (Exception $e) {
- $h = new Handler(app());
- $h->report($e);
- $response['message'] = "There was an error getting the hundred day courses. Please try again or contact us for assistance.";
- }
- return $response;
- }
-
- /**
- * @param Section $section
- * @param Course $new_course
- * @param Course $course
- * @param Enrollment $enrollment
- * @param FinalGrade $finalGrade
- * @return void
- */
- public
- function prepareNewCourse(Section $section,
- Course $new_course,
- Course $course,
- Enrollment $enrollment,
- FinalGrade $finalGrade)
- {
- $section->name = 'Main';
- $section->course_id = $new_course->id;
- $section->crn = "To be determined";
- $section->save();
- $course->enrollFakeStudent($new_course->id, $section->id, $enrollment);
- $finalGrade->setDefaultLetterGrades($new_course->id);
- $this->reorderAllCourses();
-
- }
-
- /**
- * @param AssignmentGroup $assignmentGroup
- * @param Course $cloned_course
- * @param $assignment
- * @param AssignmentGroupWeight $assignmentGroupWeight
- * @param Course $course
- * @return mixed
- */
- public
- function cloneAssignment(AssignmentGroup $assignmentGroup, Course $cloned_course, $assignment, AssignmentGroupWeight $assignmentGroupWeight, Course $course)
- {
- $cloned_assignment_group_id = $assignmentGroup->importAssignmentGroupToCourse($cloned_course, $assignment);
- $assignmentGroupWeight->importAssignmentGroupWeightToCourse($course, $cloned_course, $cloned_assignment_group_id, false);
- $cloned_assignment = $assignment->replicate();
- $cloned_assignment->course_id = $cloned_course->id;
- $cloned_assignment->shown = 0;
- if ($cloned_assignment->assessment_type !== 'real time') {
- $cloned_assignment->solutions_released = 0;
- }
- if ($cloned_assignment->assessment_type === 'delayed') {
- $cloned_assignment->show_scores = 0;
- }
- $cloned_assignment->students_can_view_assignment_statistics = 0;
- $cloned_assignment->assignment_group_id = $cloned_assignment_group_id;
- $cloned_assignment->lms_resource_link_id = null;
- $cloned_assignment->save();
- return $cloned_assignment;
- }
-
-}
diff --git a/app/Policies/CoursePolicy.php b/app/Policies/CoursePolicy.php
deleted file mode 100644
index cefc69544..000000000
--- a/app/Policies/CoursePolicy.php
+++ /dev/null
@@ -1,489 +0,0 @@
-role, [2, 5])
- ? Response::allow()
- : Response::deny('You are not allowed to get the courses and assignments.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function storeTester(User $user, Course $course): Response
- {
- return $user->id === $course->user_id
- ? Response::allow()
- : Response::deny('You are not allowed to add testers to this course.');
-
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function getTesters(User $user, Course $course): Response
- {
- return $user->id === $course->user_id
- ? Response::allow()
- : Response::deny('You are not allowed to get the testers for this course.');
-
- }
-
- public function getCommonsCoursesAndAssignments(User $user): Response
- {
- return $user->role === 5
- ? Response::allow()
- : Response::deny('You are not allowed to get the Commons courses and assignments.');
-
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function reset(User $user, Course $course): Response
- {
- return (int)$course->user_id === $user->id || Helper::isAdmin()
- ? Response::allow()
- : Response::deny('You are not allowed to reset that course.');
- }
-
- public function getConcludedCourses(User $user, Course $course): Response
- {
- return Helper::isAdmin()
- ? Response::allow()
- : Response::deny('You are not allowed to get the the courses to unenroll.');
-
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function getAssignmentsForAnonymousUser(User $user, Course $course): Response
- {
- switch ($user->role) {
- case(2):
- $has_access = ($course->public || Helper::isCommonsCourse($course)) && Helper::hasAnonymousUserSession();
- break;
- case(3):
- $has_access = $course->anonymous_users && Helper::isAnonymousUser();
- break;
- default:
- $has_access = false;
- }
- return $has_access
- ? Response::allow()
- : Response::deny('You are not allowed to view these assignments.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function updateIFrameProperties(User $user, Course $course): Response
- {
- return ((int)$course->user_id === (int)$user->id)
- ? Response::allow()
- : Response::deny('You are not allowed to update what is shown in the iframe.');
- }
-
- /**
- * @param User $user
- * @param $courses
- * @param $ordered_courses
- * @return Response
- */
- public function order(User $user, $courses, $ordered_courses): Response
- {
- $owner_courses = DB::table('courses')
- ->where('user_id', $user->id)
- ->select('id')
- ->pluck('id')
- ->toArray();
- $has_access = true;
- foreach ($ordered_courses as $ordered_course) {
- if (!in_array($ordered_course, $owner_courses)) {
- $has_access = false;
- }
- }
- return $has_access
- ? Response::allow()
- : Response::deny('You are not allowed to re-order a course that is not yours.');
- }
-
- public function getAssignmentNamesForPublicCourse(User $user, Course $course): Response
- {
- return $user->role === 2 && $course->public
- ? Response::allow()
- : Response::deny('You are not allowed to access the assignments in that course.');
-
-
- }
-
- public function updateBetaApprovalNotifications(User $user, Course $course): Response
- {
- return ((int)$course->user_id === (int)$user->id)
- ? Response::allow()
- : Response::deny('You are not allowed to update the Beta course notifications for this course.');
-
- }
-
- public function courseAccessForGraders(User $user, Course $course): Response
- {
- return ((int)$course->user_id === (int)$user->id)
- ? Response::allow()
- : Response::deny('You are not allowed to grant access to all assignments for all graders for this course.');
- }
-
- public function getAssignmentOptions(User $user, Course $course): Response
- {
-
- return ((int)$course->user_id === (int)$user->id)
- ? Response::allow()
- : Response::deny('You are not allowed to download the assignment options.');
- }
-
- public function copy(User $user, Course $course): Response
- {
- return (int)$course->user_id === (int)$user->id
- ? Response::allow()
- : Response::deny('You are not allowed to copy a course you do not own.');
-
- }
-
-
- public function import(User $user, Course $course): Response
- {
-
- $owner_of_course = (int)$course->user_id === (int)$user->id;
- $is_public = (int)$course->public === 1;
- $has_role_that_can_import = in_array($user->role, [2, 5]);
- $is_non_instructor_question_editor = (int)$user->role === 5;
- return ( $has_role_that_can_import && ($owner_of_course || $is_public)) || ($owner_of_course && $is_non_instructor_question_editor)
- ? Response::allow()
- : Response::deny('You are not allowed to import that course.');
-
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function getImportable(User $user, Course $course): Response
- {
-
- return in_array($user->role, [2, 5])
- ? Response::allow()
- : Response::deny('You are not allowed to retrieve the importable courses.');
-
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @param int $student_user_id
- * @return Response
- */
- public
- function loginAsStudentInCourse(User $user, Course $course, int $student_user_id): Response
- {
- $student_enrolled_in_course = $course->enrollments->contains('user_id', $student_user_id);
- switch ($user->role) {
- case(2):
- $has_access = ($course->user_id === (int)$user->id);
- break;
- case(4):
- $has_access = $course->isGrader();
- break;
- case(6):
- $has_course_access = DB::table('tester_courses')
- ->where('user_id', $user->id)
- ->where('course_id', $course->id)
- ->first();
- $has_student_access = DB::table('tester_students')
- ->where('tester_user_id', $user->id)
- ->where('student_user_id', $student_user_id)
- ->first();
- $has_access = $has_course_access && $has_student_access;
- break;
- default:
- $has_access = false;
- }
-
- //check if the student is in their course.
- return ($student_enrolled_in_course && $has_access)
- ? Response::allow()
- : Response::deny('You are not allowed to log in as this student.');
- }
-
- /**
- * Determine whether the user can view any courses.
- *
- * @param User $user
- * @return mixed
- */
- public function viewAny(User $user)
- {
- return ($user->role !== 3)
- ? Response::allow()
- : Response::deny('You are not allowed to view courses.');
- }
-
- /**
- * Determine whether the user can view any courses.
- *
- * @param User $user
- * @return mixed
- */
- public function viewCourseScores(User $user, Course $course)
- {
-
- return ($course->isGrader() || $this->ownsCourseByUser($course, $user))
- ? Response::allow()
- : Response::deny('You are not allowed to view these scores.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function viewCourseScoresByUser(User $user, Course $course): Response
- {
- return $course->enrollments->contains('user_id', $user->id)
- ? Response::allow()
- : Response::deny('You are not allowed to view these scores.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function updateStudentsCanViewWeightedAverage(User $user, Course $course): Response
- {
- return ($this->ownsCourseByUser($course, $user))
- ? Response::allow()
- : Response::deny('You are not allowed to update being able to view the weighted average.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function updateShowZScores(User $user, Course $course): Response
- {
- return ($this->ownsCourseByUser($course, $user))
- ? Response::allow()
- : Response::deny('You are not allowed to update being able to view the z-scores.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function updateShowProgressReport(User $user, Course $course): Response
- {
- return ($this->ownsCourseByUser($course, $user))
- ? Response::allow()
- : Response::deny('You are not allowed to update being able to view the progress report.');
- }
-
-
- /**
- * Determine whether the user can view the course.
- *
- * @param User $user
- * @param Course $course
- * @return mixed
- */
- public function view(User $user, Course $course): Response
- {
- switch ($user->role) {
- case(6):
- $has_access = DB::table('tester_courses')
- ->where('course_id', $course->id)
- ->where('user_id', $user->id)
- ->first();
- break;
- case(5):
- case(2):
- $has_access = $this->ownsCourseByUser($course, $user);
- break;
- case(3):
- {
- $has_access = $course->enrollments->contains('user_id', $user->id);
- break;
- }
- case(4):
- {
- $has_access = $course->isGrader();
- break;
- }
- default:
- $has_access = false;
- }
- return $has_access
- ? Response::allow()
- : Response::deny('You are not allowed to access this course.');
- }
-
- public function viewOpen(User $user, Course $course): Response
- {
-
- return ($user->role === 2 && (Helper::isCommonsCourse($course) || $course->public)) || $course->anonymous_users
- ? Response::allow()
- : Response::deny('You are not allowed to access this course.');
- }
-
- /**
- * Determine whether the user can view the course.
- *
- * @param User $user
- * @param Course $course
- * @return mixed
- */
- public function createCourseAssignment(User $user, Course $course): Response
- {
- return $this->ownsCourseByUser($course, $user)
- ? Response::allow()
- : Response::deny('You are not allowed to create assignments for this course.');
- }
-
- /**
- * Determine whether the user can view the course.
- *
- * @param User $user
- * @param Course $course
- * @param Assignment $assignment
- * @return Response
- */
- public function importAssignment(User $user, Course $course, Assignment $assignment): Response
- {
-
- $has_access = true;
- $message = '';
- if (!$this->ownsCourseByUser($course, $user)) {
- $has_access = false;
- $message = 'You are not allowed to import assignments to this course.';
- }
- if ($has_access) {
- $has_access = $user->role === 2 && ($assignment->course->public
- || Helper::isCommonsCourse($assignment->course)
- || $this->ownsCourseByUser($assignment->course, $user));
- if (!$has_access) {
- $message = 'You can only import assignments from your own courses, the Commons, or public courses.';
-
- }
- }
-
- return $has_access
- ? Response::allow()
- : Response::deny($message);
- }
-
- public function showCourse(User $user, Course $course): Response
- {
- return $this->ownsCourseByUser($course, $user)
- ? Response::allow()
- : Response::deny('You are not allowed to show/hide this course.');
- }
-
-
- /**
- * Determine whether the user can create courses.
- *
- * @param User $user
- * @return mixed
- */
- public function create(User $user)
- {
- return (in_array($user->role, [2, 5]))
- ? Response::allow()
- : Response::deny('You are not allowed to create a course.');
- }
-
- /**
- * Determine whether the user can update the course.
- *
- * @param User $user
- * @param Course $course
- * @return mixed
- */
- public function update(User $user, Course $course)
- {
- return $this->ownsCourseByUser($course, $user)
- ? Response::allow()
- : Response::deny('You are not allowed to update this course.');
- }
-
- /**
- * @param User $user
- * @param Course $course
- * @return Response
- */
- public function delete(User $user, Course $course): Response
- {
- return $this->ownsCourseByUser($course, $user)
- ? Response::allow()
- : Response::deny('You are not allowed to delete this course.');
- }
-
-
- /**
- * @param User $user
- * @return Response
- */
- public function getAllCourses(User $user): Response
- {
- return $user->isAdminWithCookie()
- ? Response::allow()
- : Response::deny('You are not allowed to get all courses.');
- }
-
- /**
- * @param User $user
- * @return Response
- */
- public function getAssignmentNamesIdsByCourse(User $user): Response
- {
- //added (int) because wasn't working in the test
- return in_array($user->role, [2, 5])
- ? Response::allow()
- : Response::deny('You are not allowed to get the names and assignment IDs.');
- }
-
-
-}
diff --git a/public/assets/img/372103860_CHECK_MARK_400.gif b/public/assets/img/372103860_CHECK_MARK_400.gif
index 53e2c76d0..bba1ecf47 100644
Binary files a/public/assets/img/372103860_CHECK_MARK_400.gif and b/public/assets/img/372103860_CHECK_MARK_400.gif differ
diff --git a/public/assets/img/391906020_THUMBS_UP_400px.gif b/public/assets/img/391906020_THUMBS_UP_400px.gif
index 0721cf32f..aee9497a3 100644
Binary files a/public/assets/img/391906020_THUMBS_UP_400px.gif and b/public/assets/img/391906020_THUMBS_UP_400px.gif differ
diff --git a/public/assets/img/QR.png b/public/assets/img/QR.png
index 06e144850..b179dde67 100644
Binary files a/public/assets/img/QR.png and b/public/assets/img/QR.png differ
diff --git a/public/assets/img/additional_settings_canvas.png b/public/assets/img/additional_settings_canvas.png
index 56c6d324f..d749b171d 100644
Binary files a/public/assets/img/additional_settings_canvas.png and b/public/assets/img/additional_settings_canvas.png differ
diff --git a/public/assets/img/check_twice.gif b/public/assets/img/check_twice.gif
index 40e4e63c9..9e51daa7c 100644
Binary files a/public/assets/img/check_twice.gif and b/public/assets/img/check_twice.gif differ
diff --git a/public/assets/img/learning_trees/green_light.jpg b/public/assets/img/learning_trees/green_light.jpg
index bab308331..38895140a 100644
Binary files a/public/assets/img/learning_trees/green_light.jpg and b/public/assets/img/learning_trees/green_light.jpg differ
diff --git a/public/assets/img/learning_trees/red_light.jpg b/public/assets/img/learning_trees/red_light.jpg
index 0732ca122..12279e2b3 100644
Binary files a/public/assets/img/learning_trees/red_light.jpg and b/public/assets/img/learning_trees/red_light.jpg differ
diff --git a/public/assets/img/learning_trees/yellow_light.jpg b/public/assets/img/learning_trees/yellow_light.jpg
index f443fe4ac..ab752df24 100644
Binary files a/public/assets/img/learning_trees/yellow_light.jpg and b/public/assets/img/learning_trees/yellow_light.jpg differ
diff --git a/public/assets/img/output-onlinegiftools.gif b/public/assets/img/output-onlinegiftools.gif
index b58a0099e..adb951efd 100644
Binary files a/public/assets/img/output-onlinegiftools.gif and b/public/assets/img/output-onlinegiftools.gif differ
diff --git a/public/assets/img/splash.jpg b/public/assets/img/splash.jpg
index 9bd014762..261e55e3c 100644
Binary files a/public/assets/img/splash.jpg and b/public/assets/img/splash.jpg differ
diff --git a/public/assets/img/thumbs_up_twice.gif b/public/assets/img/thumbs_up_twice.gif
index d52493547..8f203fb53 100644
Binary files a/public/assets/img/thumbs_up_twice.gif and b/public/assets/img/thumbs_up_twice.gif differ
diff --git a/public/nanospell/nanospell.ckeditor/theme/wiggle.png b/public/nanospell/nanospell.ckeditor/theme/wiggle.png
old mode 100755
new mode 100644
index 8bf147faf..d371f3bc2
Binary files a/public/nanospell/nanospell.ckeditor/theme/wiggle.png and b/public/nanospell/nanospell.ckeditor/theme/wiggle.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/circle-zebra-vertical.png b/public/vendor/qrcodemonkey/qrcode/body/circle-zebra-vertical.png
index a9c5ac6fa..4b5611dcf 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/circle-zebra-vertical.png and b/public/vendor/qrcodemonkey/qrcode/body/circle-zebra-vertical.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/circle-zebra.png b/public/vendor/qrcodemonkey/qrcode/body/circle-zebra.png
index 98b9a1142..785954d3f 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/circle-zebra.png and b/public/vendor/qrcodemonkey/qrcode/body/circle-zebra.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/circle.png b/public/vendor/qrcodemonkey/qrcode/body/circle.png
index f4c6027f3..e7ef3f382 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/circle.png and b/public/vendor/qrcodemonkey/qrcode/body/circle.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/circular.png b/public/vendor/qrcodemonkey/qrcode/body/circular.png
index bf87af619..13394c53c 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/circular.png and b/public/vendor/qrcodemonkey/qrcode/body/circular.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/diamond.png b/public/vendor/qrcodemonkey/qrcode/body/diamond.png
index cf64995fc..524719dff 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/diamond.png and b/public/vendor/qrcodemonkey/qrcode/body/diamond.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/dot.png b/public/vendor/qrcodemonkey/qrcode/body/dot.png
index 76911de2a..e89ab1ebf 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/dot.png and b/public/vendor/qrcodemonkey/qrcode/body/dot.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/edge-cut-smooth.png b/public/vendor/qrcodemonkey/qrcode/body/edge-cut-smooth.png
index 52f661d78..a037dee96 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/edge-cut-smooth.png and b/public/vendor/qrcodemonkey/qrcode/body/edge-cut-smooth.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/edge-cut.png b/public/vendor/qrcodemonkey/qrcode/body/edge-cut.png
index 9cbb2a32e..17b1f463b 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/edge-cut.png and b/public/vendor/qrcodemonkey/qrcode/body/edge-cut.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/japnese.png b/public/vendor/qrcodemonkey/qrcode/body/japnese.png
index 9db3fc445..d0694640b 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/japnese.png and b/public/vendor/qrcodemonkey/qrcode/body/japnese.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/leaf.png b/public/vendor/qrcodemonkey/qrcode/body/leaf.png
index bee9b8f86..1ae272d8b 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/leaf.png and b/public/vendor/qrcodemonkey/qrcode/body/leaf.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/mosaic.png b/public/vendor/qrcodemonkey/qrcode/body/mosaic.png
index 7d21e561f..e7dae1ddd 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/mosaic.png and b/public/vendor/qrcodemonkey/qrcode/body/mosaic.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/pointed-edge-cut.png b/public/vendor/qrcodemonkey/qrcode/body/pointed-edge-cut.png
index e84edb1de..96416e3b6 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/pointed-edge-cut.png and b/public/vendor/qrcodemonkey/qrcode/body/pointed-edge-cut.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/pointed-in-smooth.png b/public/vendor/qrcodemonkey/qrcode/body/pointed-in-smooth.png
index 213323657..ecbd3dbaf 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/pointed-in-smooth.png and b/public/vendor/qrcodemonkey/qrcode/body/pointed-in-smooth.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/pointed-in.png b/public/vendor/qrcodemonkey/qrcode/body/pointed-in.png
index fc082c783..6288761ec 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/pointed-in.png and b/public/vendor/qrcodemonkey/qrcode/body/pointed-in.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/pointed-smooth.png b/public/vendor/qrcodemonkey/qrcode/body/pointed-smooth.png
index 9a5e7a25a..6f5ae685a 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/pointed-smooth.png and b/public/vendor/qrcodemonkey/qrcode/body/pointed-smooth.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/pointed.png b/public/vendor/qrcodemonkey/qrcode/body/pointed.png
index ef4522a20..4c6f5053d 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/pointed.png and b/public/vendor/qrcodemonkey/qrcode/body/pointed.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/round.png b/public/vendor/qrcodemonkey/qrcode/body/round.png
index 1e1f835b0..39abfc6aa 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/round.png and b/public/vendor/qrcodemonkey/qrcode/body/round.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/rounded-in-smooth.png b/public/vendor/qrcodemonkey/qrcode/body/rounded-in-smooth.png
index e3a56bc0e..c751e7bbe 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/rounded-in-smooth.png and b/public/vendor/qrcodemonkey/qrcode/body/rounded-in-smooth.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/rounded-in.png b/public/vendor/qrcodemonkey/qrcode/body/rounded-in.png
index a122c0e88..406acba20 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/rounded-in.png and b/public/vendor/qrcodemonkey/qrcode/body/rounded-in.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/rounded-pointed.png b/public/vendor/qrcodemonkey/qrcode/body/rounded-pointed.png
index 37d211f7d..8ec446f94 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/rounded-pointed.png and b/public/vendor/qrcodemonkey/qrcode/body/rounded-pointed.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/square.png b/public/vendor/qrcodemonkey/qrcode/body/square.png
index 462b78d17..772c6b7d4 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/square.png and b/public/vendor/qrcodemonkey/qrcode/body/square.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/body/star.png b/public/vendor/qrcodemonkey/qrcode/body/star.png
index b4b283b2f..0b57fb966 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/body/star.png and b/public/vendor/qrcodemonkey/qrcode/body/star.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame0.png b/public/vendor/qrcodemonkey/qrcode/eye/frame0.png
index ad627713e..e8c4eda45 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame0.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame0.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame1.png b/public/vendor/qrcodemonkey/qrcode/eye/frame1.png
index 21e6870e4..fe4a0ac13 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame1.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame1.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame10.png b/public/vendor/qrcodemonkey/qrcode/eye/frame10.png
index 8168a8b6c..b735c1661 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame10.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame10.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame11.png b/public/vendor/qrcodemonkey/qrcode/eye/frame11.png
index 158d248b1..adfdd3940 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame11.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame11.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame12.png b/public/vendor/qrcodemonkey/qrcode/eye/frame12.png
index 872d0607b..8572d5bbb 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame12.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame12.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame13.png b/public/vendor/qrcodemonkey/qrcode/eye/frame13.png
index 9b808ca70..10ff6aa05 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame13.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame13.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame16.png b/public/vendor/qrcodemonkey/qrcode/eye/frame16.png
index 881f50004..ecdf753cf 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame16.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame16.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame2.png b/public/vendor/qrcodemonkey/qrcode/eye/frame2.png
index 3455c2866..bb3fb9364 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame2.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame2.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame3.png b/public/vendor/qrcodemonkey/qrcode/eye/frame3.png
index 5bce6392b..d84ab9bde 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame3.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame3.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame4.png b/public/vendor/qrcodemonkey/qrcode/eye/frame4.png
index 72aa3c6ff..05cbc3a77 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame4.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame4.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame5.png b/public/vendor/qrcodemonkey/qrcode/eye/frame5.png
index 1e002c509..abaec0401 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame5.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame5.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame6.png b/public/vendor/qrcodemonkey/qrcode/eye/frame6.png
index 6bf97e0af..f5a016f5a 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame6.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame6.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame7.png b/public/vendor/qrcodemonkey/qrcode/eye/frame7.png
index af1f80820..8625230e9 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame7.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame7.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eye/frame8.png b/public/vendor/qrcodemonkey/qrcode/eye/frame8.png
index eda381bc8..d82af893d 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eye/frame8.png and b/public/vendor/qrcodemonkey/qrcode/eye/frame8.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball1.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball1.png
index 6c2b066e3..b382d5143 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball1.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball1.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball10.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball10.png
index f6984e533..6f0680f6c 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball10.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball10.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball13.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball13.png
index ceffc0ca1..bd9ce71cb 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball13.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball13.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball14.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball14.png
index 28aa817b3..fc50e3e44 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball14.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball14.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball17.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball17.png
index 48d96c56e..c9115cdd4 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball17.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball17.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball19.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball19.png
index 72a26a9e7..3f2b71c7f 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball19.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball19.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball2.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball2.png
index 120ea6d57..475654f9b 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball2.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball2.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball5.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball5.png
index fe312b7c5..42ebd6485 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball5.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball5.png differ
diff --git a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball7.png b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball7.png
index f632f8c97..77f3fec23 100644
Binary files a/public/vendor/qrcodemonkey/qrcode/eyeBall/ball7.png and b/public/vendor/qrcodemonkey/qrcode/eyeBall/ball7.png differ
diff --git a/resources/js/components/ResetCourse.vue b/resources/js/components/ResetCourse.vue
deleted file mode 100644
index b986d5852..000000000
--- a/resources/js/components/ResetCourse.vue
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
- Please confirm that you would like to reset the following course: {{ course.name }}
- Please confirm that you would like to unenroll {{ - studentToUnenroll.name - }} from - {{ studentToUnenroll.section }}. -
-- {{ studentToMove.name }} is currently enrolled in {{ studentToMove.section }}. -
-- Using the following configuration, you can integrate your Canvas installation with ADAPT via LTI 1.3, also - known as LTI Advantage. Optionally, you can following along with this video, which implements the steps below. -
- -- In your Canvas installation, first go to the Developer Keys page and add an LTI key. When the configuration - page - opens up choose "Manual - Entry" as the method to enter the configuration details. -
-
- Redirect URIs:
- {{ origin }}/api/lti/redirect-uri/{{ campusId }}
-
-
-
- Title: {{ appName }}
-
-
- Description Online homework platform
-
-
-
- Target Link URI:
- {{ origin }}/api/lti/redirect-uri/{{ campusId }}
-
-
-
- OpenID Connect Initiation Url:
- {{ origin }}/api/lti/oidc-initiation-url
-
-
-
- Public JWK:
-
Under LTI Advantage services toggle the following to On:
-- Open up Additional Settings and switch Privacy Level to Public: -
-
-
Placements: Assignment Selection
-
- Target Link URI:
- {{ origin }}/api/lti/configure/{{ campusId }}
-
-
-
Select Message Type: LtiDeepLinkingRequest
-Final steps:
-- Please fill out the form so that we can register your school's information. Once completed, you will - receive - a follow-up email explaining how you can add ADAPT as an external app and how your instructors can then - link - up - their ADAPT courses to Canvas. -
-- You can save questions from this open course to one of your Favorites folders and then import them to any - of your assignments. -
- -- If you're unsuccessful at completing the Root Assessment, you can use the arrows to - traverse - through the Learning Tree. -
-- You will receive a reset for the Root Assessment after you have - - successfully completed at least {{ - assignmentQuestionLearningTreeInfo.min_number_of_successful_assessments - }} assessment{{ - assignmentQuestionLearningTreeInfo.min_number_of_successful_assessments > 1 ? 's' : '' - }} - - - spent at least {{ - assignmentQuestionLearningTreeInfo.min_time - }} minute{{ assignmentQuestionLearningTreeInfo.min_time > 1 ? 's' : '' }} - - - on {{ assignmentQuestionLearningTreeInfo.number_of_successful_branches_for_a_reset }} of the branches. - - - in the Learning Tree. - -
-- You can have a total of {{ - assignmentQuestionLearningTreeInfo.number_of_resets - }} reset{{ assignmentQuestionLearningTreeInfo.number_of_resets > 1 ? 's' : '' }}. -
-- You'll be able to "give up" after you attempt this problem at least once. And, if you're not - sure how to start this problem, a good strategy is to always go back to your notes or textbook to - either find a related problem or review the underlying concept. -
-- - You can view a hint and no penalty will be applied. - - - You can view a hint, but if you do, a penalty of {{ hintPenaltyIfShownHint }}% will be applied to your next submission. - -
- - -- You can give up now and get access to the solution, but if you do, your current score of - {{ questions[currentPage - 1].submission_score }} will be recorded. -
-- In addition, once the solution becomes available, you will no longer be able to submit a new - response. -
- - --
- All responses successfully submitted. -
-Unfortunately, you were not successful in answering the Root Assessment correctly.
-- {{ getNumberOfResetsLeftMessage() }} -
-- {{ getNumberOfAttemptsLeftMessage() }} -
-- It looks like you're trying to access an assignment with the URL {{ $router.currentRoute.path }} - but we can't find that assignment. Please log out then log back in as your instructor may have updated the - link. - However, if you are still having issues and this is an embedded problem, please let your instructor know so - that they can fix the URL. -
-- You are trying to edit a question that is part of a Beta assignment. If you edit the question source, it will - affect all other Beta assignments. Please get in touch with the Alpha instructor to see if an edit is possible. -
-Please go to Tethered Courses in the Course Properties for their contact information.
-- By resetting to the default text, your current text submission will be removed. -
-Once the submission is removed, we will not be able to retrieve it!
- -- Please confirm that you would like to remove this solution. Note that you will still be able to upload - a different solution at any time. -
-- Note that students will still have access to the Libretexts solution. -
- -- Upload an entire PDF with one solution per page and let ADAPT cut up the PDF for you. Or, upload one - solution at a time. If you upload a full PDF, students will be able to both download a full solution key - and download solutions on a per question basis. -
-- Important: For best results, don't crop any of your pages. In addition, please make sure that they are all oriented in the same direction. -
-- Select a single page or a comma separated list of pages to submit as your solution to - this question or - Tell us which page your question submission starts on or - - - upload a new PDF. -
-- Important: - If your submission spans multiple pages, just enter the first page where the submission starts. -
-- This problem is locked. Since students have already submitted responses, you cannot update the - points per question nor change the open-ended submission type. -
-- In addition, since you are computing points by question weights, you will not be able to remove the - question - as it will affect already submitted questions. -
-{{ questions[currentPage - 1].common_question_text }}
-- Choose a branch to gain a better understanding of an underlying concept. - - Branch assessments have unlimited attempts without penalty. - -
-- You can add default text for your students to see in their own text editors when they - attempt this question. -
-- Use the built-in "ADAPT recorder" below to record and upload your audio submission directly to - ADAPT. - Otherwise, you may record your audio submission as an .mp3 file with another program (outside of - ADAPT), - save the .mp3 file to your computer, then - upload the .mp3 file from your computer into ADAPT. -
-- {{ getWindowLocation() }} -
- Please ask your instructor to update this link so that it matches a question in the assignment. -