Skip to content

Commit

Permalink
Implement lab-start, lab-invite and corresponding route
Browse files Browse the repository at this point in the history
  • Loading branch information
jesjos committed May 8, 2012
1 parent d93e080 commit 63ee155
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 113 deletions.
4 changes: 4 additions & 0 deletions app/models/lab_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def token
# Digest::SHA1.hexdigest(APP_CONFIG["salt"] || self.id.to_s)
end

def name
"Group #{self.number}"
end

#
# Adds a student to a lab group.
# Checks that the student is registered to the correct course.
Expand Down
20 changes: 18 additions & 2 deletions app/views/lab_groups/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
%h1 LabGroups#index
%p Find me in app/views/lab_groups/index.html.haml
.hero-unit
%h1 Lab Groups

%table.table-striped
%thead
%th
Group number
%th
Labs
%tbody
- @lab_groups.each do |group|
%td= group.number
%td
%ul
- group.labs.each do |lab|
%li= link_to lab.number, course_lab_group_lab_path(current_role_name, params[:course_id], group, lab)


2 changes: 1 addition & 1 deletion app/views/lab_groups/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
= form_for(@lab_group,
url: join_course_lab_groups_path("student", params[:course_id]),
html: {class: "form form-horizontal"}) do |group|
= group.text_field :id, :placeholder => 'Enter group code'
= group.text_field :hidden_token, :placeholder => 'Enter group code'
= group.submit 'Join', class: 'btn btn-primary'

18 changes: 13 additions & 5 deletions app/views/lab_groups/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
%h1
Group
= @lab_group.number
%p
A list of your labs for this course


.well
.form-inline
.input-prepend
%span.add-on
Invite code for this group
%input.input-large{type: "text", value: "git://water.com:/apa/bepa.git"}
%h1
Labs
%table.table.table-bordered.table-striped
%thead
%th Lab title
%tbody
- @lab_group.labs.each do |lab|
%tr
%td= link_to lab.title, course_lab_group_lab_path(current_role.class.name.downcase, @course, @lab_group, lab)
%td= link_to lab.title,
course_lab_group_lab_path(current_role.class.name.downcase,
@course,
@lab_group,
lab)
105 changes: 102 additions & 3 deletions app/views/labs/_lab_student.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,102 @@
%tr
%td= lab.name
%td= lab.description
- content_for :post_css do
/ Generic page styles
/ Bootstrap CSS fixes for IE6
/[if lt IE 7] <link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap-ie6.min.css">
/ CSS to style the file input field as button and adjust the Bootstrap progress bars
= stylesheet_link_tag "jqupload/jquery.fileupload-ui_css"

- content_for :post_js do
/ / The Templates plugin is included to render the upload/download listings
%script{:src => "http://blueimp.github.com/JavaScript-Templates/tmpl.min.js"}
/ The Load Image plugin is included for the preview images and image resizing functionality
%script{:src => "http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"}
/ The Canvas to Blob plugin is included for image resizing functionality
%script{:src => "http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"}
= javascript_include_tag "jqupload/jquery.iframe-transport.js", "jqupload/jquery.fileupload.js", "jqupload/jquery.fileupload-ip.js"
= javascript_include_tag "jqupload/jquery.fileupload-ui.js", "jqupload/locale.js"
%script{type: "text/x-tmpl"}
#commit-request-dialog.well
%h1 Sending commit request...
// ###################### HEADER ENDS ########################
.hero-unit{class: @lhg.state}
%h1
Lab title:
= @lab.title
%h1
Status:
%span{class: @lhg.state}= @lhg.state
%p
This is the current state of your lab
%br
Upload files to specific folders by navigating to them in the tree view.
%br
When you are satisfied with the submission, click the submit button to submit it.
%p
%a.btn.btn-primary.btn-large#scroll_to_uploads{href: "#"}
%i.icon-upload.icon-white
Upload files

.well
%h1
Submissions
%table.table.table-striped.table-bordered
%thead
%tr
%th
Name
%th
Submission commit hash
%th
Submission time
- @lab.submissions.each_with_index do |submission, index|
%tr
%td
= link_to "Submission #{index + 1}",
course_lab_group_lab_submission_path(current_role_name,
@course_id,
@lab_group,
@lab,
submission)
%td
= submission.commit_hash[0..6]
%td
= submission.created_at

.well
%h1 Current state of the lab
%br
.breadcrumbs
#tree-view
.breadcrumbs
.breadcrumb
%form.form-inline
%input#mkdir-input{type: "text"}
%a.btn.has-tooltip{href: "#mkdir",
title: "Click this button to create a folder at the current location in the tree"}
%i.icon-folder-open
Create a directory
.well
= render "upload"
- if @lhg.submission_allowed?
%a.btn.btn-large.btn-danger{href: new_commit_course_lab_group_lab_submissions_path(current_role_name, @course_id, @lab_group, @lab, @lhg.repository.last_commit.to_s)}
%i.icon-ok.icon-white
Submit!
- elsif @lhg.update_allowed?
%a.btn.btn-large.btn-danger{href: edit_course_lab_group_lab_submission_path(current_role_name,
@course_id,
@lab_group,
@lab,
@lhg.submissions.last)}
%i.icon-ok.icon-white
Update!
- else
%a.btn.btn-large.btn-danger.disabled.has-tooltip{href: new_course_lab_group_lab_submission_path(current_role_name,
@course_id,
@lab_group,
@lab),
title: "Submission is closed for the time being"}
%i.icon-ok.icon-white
Submit!
34 changes: 34 additions & 0 deletions app/views/labs/_start_lab.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.hero-unit
%h1
Start working on a lab
%br
%p Connect a lab group to the lab or create a new lab group.
.row
.span6
.well.equal-height
.center
- if @lab_groups
%br
%h3
Connect an existing lab group
%br
= form_tag "", class: "form form-horizontal" do
= select_tag "lab_group",
options_from_collection_for_select(@lab_groups,
"id",
"name",
prompt: "Select a group")
= submit_tag "Connect", class: "btn btn-primary"
- else
%h1 You have no lab groups.
.span6
.well.equal-height
.center
%br
%h3
= link_to 'Create a Lab Group',
course_lab_groups_path("student", params[:course_id]),
method: 'post',
class: "btn btn-big btn-primary"
%br
%h5 A new group will be created and connected to the lab
107 changes: 5 additions & 102 deletions app/views/labs/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,102 +1,5 @@
- content_for :post_css do
/ Generic page styles
/ Bootstrap CSS fixes for IE6
/[if lt IE 7] <link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap-ie6.min.css">
/ CSS to style the file input field as button and adjust the Bootstrap progress bars
= stylesheet_link_tag "jqupload/jquery.fileupload-ui_css"

- content_for :post_js do
/ / The Templates plugin is included to render the upload/download listings
%script{:src => "http://blueimp.github.com/JavaScript-Templates/tmpl.min.js"}
/ The Load Image plugin is included for the preview images and image resizing functionality
%script{:src => "http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"}
/ The Canvas to Blob plugin is included for image resizing functionality
%script{:src => "http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"}
= javascript_include_tag "jqupload/jquery.iframe-transport.js", "jqupload/jquery.fileupload.js", "jqupload/jquery.fileupload-ip.js"
= javascript_include_tag "jqupload/jquery.fileupload-ui.js", "jqupload/locale.js"
%script{type: "text/x-tmpl"}
#commit-request-dialog.well
%h1 Sending commit request...
// ###################### HEADER ENDS ########################
.hero-unit{class: @lhg.state}
%h1
Lab title:
= @lab.title
%h1
Status:
%span{class: @lhg.state}= @lhg.state
%p
This is the current state of your lab
%br
Upload files to specific folders by navigating to them in the tree view.
%br
When you are satisfied with the submission, click the submit button to submit it.
%p
%a.btn.btn-primary.btn-large#scroll_to_uploads{href: "#"}
%i.icon-upload.icon-white
Upload files

.well
%h1
Submissions
%table.table.table-striped.table-bordered
%thead
%tr
%th
Name
%th
Submission commit hash
%th
Submission time
- @lab.submissions.each_with_index do |submission, index|
%tr
%td
= link_to "Submission #{index + 1}",
course_lab_group_lab_submission_path(current_role_name,
@course_id,
@lab_group,
@lab,
submission)
%td
= submission.commit_hash[0..6]
%td
= submission.created_at

.well
%h1 Current state of the lab
%br
.breadcrumbs
#tree-view
.breadcrumbs
.breadcrumb
%form.form-inline
%input#mkdir-input{type: "text"}
%a.btn.has-tooltip{href: "#mkdir",
title: "Click this button to create a folder at the current location in the tree"}
%i.icon-folder-open
Create a directory
.well
= render "upload"
- if @lhg.submission_allowed?
%a.btn.btn-large.btn-danger{href: new_commit_course_lab_group_lab_submissions_path(current_role_name, @course_id, @lab_group, @lab, @lhg.repository.last_commit.to_s)}
%i.icon-ok.icon-white
Submit!
- elsif @lhg.update_allowed?
%a.btn.btn-large.btn-danger{href: edit_course_lab_group_lab_submission_path(current_role_name,
@course_id,
@lab_group,
@lab,
@lhg.submissions.last)}
%i.icon-ok.icon-white
Update!
- else
%a.btn.btn-large.btn-danger.disabled.has-tooltip{href: new_course_lab_group_lab_submission_path(current_role_name,
@course_id,
@lab_group,
@lab),
title: "Submission is closed for the time being"}
%i.icon-ok.icon-white
Submit!
- if @start
= render "start_lab"
- elsif current_role.is_a? Student or current_role.is_a? Assistant
= render "lab_#{current_role_name}"

1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resources :labs
resources :dashboards, only: [:index]
resources :courses do
resources :labs, only: [:show]
post "/courses/:course_id/upload" => "uploads#upload"
resources :lab_groups do
collection do
Expand Down

0 comments on commit 63ee155

Please sign in to comment.