Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
allenwq committed May 20, 2015
2 parents 500834c + ea42dc6 commit 3db90e0
Show file tree
Hide file tree
Showing 25 changed files with 204 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ LineLength:

java_script:
enabled: true

scss:
enabled: true
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Coursemology [![Build Status](https://travis-ci.org/Coursemology/coursemology.org.svg?branch=development)](https://travis-ci.org/Coursemology/coursemology.org) [![Coverage Status](https://coveralls.io/repos/Coursemology/coursemology.org/badge.png)](https://coveralls.io/r/Coursemology/coursemology.org)
# Coursemology [![Build Status](https://travis-ci.org/Coursemology/coursemology.org.svg?branch=development)](https://travis-ci.org/Coursemology/coursemology.org) [![Coverage Status](https://coveralls.io/repos/Coursemology/coursemology.org/badge.png)](https://coveralls.io/r/Coursemology/coursemology.org) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Coursemology/coursemology.org?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Coursemology/coursemology.org?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

<a href="http://coursemology.org"><img src="https://raw.githubusercontent.com/Coursemology/coursemology.org/development/public/images/coursemology_logo_landscape_100.png"
alt="Coursemology logo" title="Coursemology" align="right" /></a>
Expand All @@ -19,7 +18,7 @@ There are two ways to setup a local development instance of Coursemology. You ca
2. [Vagrant](https://www.vagrantup.com/)
3. [Ansible](http://docs.ansible.com/intro_installation.html)

#### Setting up
#### Setting up

cd coursemology.org
vagrant up
Expand Down Expand Up @@ -66,7 +65,9 @@ We love contributors!
5. `git push origin awesome-feature`
6. Create a pull request on github.

Have an idea? Share it with us at the [Coursemology](https://groups.google.com/forum/#!forum/coursemology) mailing list.
## Contact Us

Have an idea? Pop by the [gitter](https://gitter.im/Coursemology/coursemology.org) chat room. If you prefer emails, join us at the [Coursemology-Dev](https://groups.google.com/forum/#!forum/coursemology-dev) mailing list. We will respond to you in less than 24 hours unless there's a zombie apocalypse.

## Found Boogs?

Expand Down
11 changes: 9 additions & 2 deletions app/assets/javascripts/assignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ $(document).ready(function() {
klass = 'btn-success';
break;
}
$div.html('<a href="' + actions_map[mid].url + '" class="btn ' + klass + '" >' + actions_map[mid].action + '</a>')
var link = $('<a>', {
'href': actions_map[mid].url,
'class': 'btn ' + klass,
'text': actions_map[mid].action
}).appendTo($div);
if ( actions_map[mid].action == 'Attempt' ){
link.attr('data-disable-with', 'Attempting...');
}
}
var $title = $("#title-"+mid);
if ($title.length > 0) {
Expand Down Expand Up @@ -61,4 +68,4 @@ $(document).ready(function() {
console.log(e);
}
}
});
});
1 change: 1 addition & 0 deletions app/controllers/course_preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def edit
@preferences = @course.home_sections
@no_preferences = @course.course_home_events_no_pref << @course.leaderboard_no_pef
@achievement_pref = @course.achievements_locked_display
@user_course_pref = @course.user_course_change_name_pref
when 'paging'
@tab = 'PagingPreference'
@preferences = @course.paging_prefs
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/forums/forums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def toggle_lock

private
def load_forum
@forum = ForumForum.find_using_slug(params[:id] || params[:forum_id])
@forum = @course.forums.find_using_slug(params[:id] || params[:forum_id])
if %w(new create).include?(params[:action])
@forum = ForumForum.new
@forum.assign_attributes(params[:forum])
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/forums/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,11 @@ def unsubscribe

private
def load_forum
@forum = ForumForum.find_using_slug(params[:forum_id])
raise ActiveRecord::RecordNotFound unless @forum
@forum = @course.forums.find_using_slug!(params[:forum_id])
end

def load_topic
@topic = ForumTopic.find_using_slug(params[:id] || params[:topic_id])
@topic = @forum.topics.find_using_slug(params[:id] || params[:topic_id])
if %w(new create).include?(params[:action])
@topic = ForumTopic.new
# No implicit assignment of attributes to the @post property. We need to create the post first before
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/tabs/tabs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def update
end
end

def sort
params[:order].each do |_, tab|
Tab.find(tab[:id]).update_column(:pos, tab[:position])
end
render nothing: true
end

# DELETE /tab/tabs/1
# DELETE /tab/tabs/1.json
def destroy
Expand Down
1 change: 1 addition & 0 deletions app/controllers/user_courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def update
end
if params[:name]
@user_course.user.name = params[:name].strip
@user_course.name = params[:name].strip
end
if params[:email]
@user_course.user.email = params[:email].strip
Expand Down
10 changes: 10 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,16 @@ def achievements_locked_display
self.course_preferences.join_items.item("Achievements").item_type('Icon').name('locked').first
end

def user_course_change_name_pref
self.course_preferences.join_items.item("UserCourse").item_type('ChangeName').name('ChangeName').first
end

def allow_name_change?
# return true when there is no preference
pref = user_course_change_name_pref
pref.nil? || pref.display?
end

def auto_create_sbm_pref
self.course_preferences.join_items.item('Mission').item_type('Submission').name('auto').first
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def auto_enroll_for_invited(confirm_token = nil)
end

def update_user_course
self.user_courses.each do |uc|
self.user_courses.includes(:course).each do |uc|
next unless uc.course.allow_name_change?

uc.name = self.name
uc.save
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user_course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UserCourse < ActiveRecord::Base
has_many :comment_subscriptions, dependent: :destroy
has_many :comment_topics, through: :comment_subscriptions

has_one :guild_user
has_one :guild_user, dependent: :destroy

#TODO
# has_many :submissions, foreign_key: "std_course_id", dependent: :destroy
Expand Down
20 changes: 16 additions & 4 deletions app/views/assessment/trainings/_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,21 @@
});

$(document).ready(function() {
$(".ui-sortable").sortable({
update: function(e, ui){
console.log(ui);
$('.ui-sortable').sortable({
update: function(e, ui) {
updated_order = [];

$('tr.tab.ng-scope').each(function (i) {
updated_order.push({id: $(this).data("id"), position: i + 1});
});

course_id = get_course_id(window.location.href);

$.ajax({
type: 'PUT',
url: '/courses/' + course_id + '/tabs/sort',
data: { order: updated_order }
});
}
});
});
Expand All @@ -188,7 +200,7 @@
</tr>
</thead>
<tbody id="dump" class="tabs" >
<tr ng-repeat="tab in tabs" class="tab" >
<tr ng-repeat="tab in tabs" class="tab" data-id="{{tab.id}}">
<td>{{$index + 1}}</td>
<td>{{tab.title}}</td>
<td>{{tab.description}}</td>
Expand Down
14 changes: 14 additions & 0 deletions app/views/course_preferences/_misc.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@
</div>
</div>

<% if @user_course_pref %>
<h3>Users</h3>
<p> Preference settings for users in course.</p>
<div class="info-block">
<div style="padding-left:5em" class="checkbox-text">
<input name="preferences[<%= @user_course_pref.id%>][prefer_value]"
value="<%= @user_course_pref.prefer_value %>" type="hidden">
<input name="preferences[<%= @user_course_pref.id%>][display]"
type="checkbox" <% if @user_course_pref.display? %> checked <% end %>>
<%= @user_course_pref.preferable_item.description %>
</div>
</div>
<% end %>

<div class="center">
<button class="btn btn-large btn-primary">Update</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/courses/manage_students.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
html: { method: :put, class: "form-horizontal" } do |f| %>
<tr>
<td>
<input type="text" name="name" value="<%= student.name %>" required>
<input type="text" name="name" value="<%= student_course.name %>" required>
</td>
<td>
<input type="email" name="email" value="<%= student.email %>" required>
Expand Down
2 changes: 1 addition & 1 deletion app/views/forums/forums/_forum.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<span class="last_post">
<% last_post = forum.last_post %>
<% if last_post %>
<%= link_to last_post.topic.title, course_forum_topic_path(@course, forum, last_post.topic) -%> by <%= last_post.author ? last_post.author.user : '(unknown)' %>
<%= link_to last_post.topic.title, course_forum_topic_path(@course, forum, last_post.topic) -%> by <%= last_post.author ? last_post.author.name : '(unknown)' %>
<time datetime="<%= last_post.created_at.to_s(:db) -%>"><%= time_ago_in_words(last_post.created_at) %> ago</time>
<% else %>
none
Expand Down
2 changes: 1 addition & 1 deletion app/views/forums/posts/_post.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="user">
<% if post.author %>
<h5 class="username">
<%= link_to post.author.user, course_user_course_path(@course, post.author) %>
<%= link_to post.author.name, course_user_course_path(@course, post.author) %>
</h5>
<div class="icon pull-right">
<a href="<%= get_social_media_url(post.author) %>">
Expand Down
4 changes: 2 additions & 2 deletions app/views/forums/posts/reply.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="user">
<% if @post.author %>
<h5 class="username">
<%= link_to @post.author.user, course_user_course_path(@course, @post.author) %>
<%= link_to @post.author.name, course_user_course_path(@course, @post.author) %>
</h5>
<div class="icon pull-right">
<img class="user-profile-pic" src="<%= @post.author.user.get_profile_photo_url %>"/>
Expand All @@ -21,7 +21,7 @@
<% if @post.parent %>
<div class="in-reply-to">
<%= link_to "In reply to #{@post.parent.author ? @post.parent.author.user : '(unknown)'}", "#post-#{@post.parent.id}" %>
<%= link_to "In reply to #{@post.parent.author ? @post.parent.author.name : '(unknown)'}", "#post-#{@post.parent.id}" %>
</div>
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions app/views/forums/topics/_topic.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<div class="subject">
<%= link_to topic.title, course_forum_topic_path(@course, @forum, topic) %>
</div>
<div class="started-by">Started by <%= topic.author ? topic.author.user : '(unknown)' %></div>
<div class="started-by">Started by <%= topic.author ? topic.author.name : '(unknown)' %></div>
</td>
<td class="votes-count text-center"><%= topic.votes_count %></td>
<td class="posts-count text-center"><%= topic.posts.count %></td>
<td class="views-count text-center"><%= topic.views.count %></td>
<td class="latest-post">
<% last_post = topic.posts.last %>
<% if last_post.author %>
<%= link_to last_post.author.user, course_user_course_path(@course, last_post.author) %><br />
<%= link_to last_post.author.name, course_user_course_path(@course, last_post.author) %><br />
<% else %>
(unknown)
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_course_side_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</a>
<div id="user-profile-name">
<a href="<%= main_app.course_user_course_path(@course, curr_user_course)%>">
<%= current_user.name %></a>
<%= curr_user_course.name %></a>
</div>
<div class="clearfix"></div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<hr/>
<div class="navbar-bottom">
<div class="container-fluid">
<p class="pull-left">&copy; 2013 - 2014 Coursemology.org. All Rights Reserved.</p>
<p class="pull-left">&copy; 2013 -
<%= Time.now.year %>
Coursemology.org. All Rights Reserved.</p>
<nav class="pull-right">
<ul class="nav">
<li><%= link_to "Term of Service", terms_of_service_path %></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_user_thumb_profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img class="user-profile-pic" src="<%= user.get_profile_photo_url %>" />
</a>
<a href="<%= user_course.get_path %>">
<strong><%= user.name %></strong>
<strong><%= user_course.name %></strong>
</a>

<div class="clearfix"></div>
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@
match "forum_participation" => "forum_participation#manage", as: :forum_participation
match "forum_participation/user/:poster_id" => "forum_participation#individual", as: :forum_participation_individual

resources :tabs, module: :tabs
resources :tabs, module: :tabs do
put :sort, on: :collection
end
end

match "courses/:id/students" => "courses#students", as: :course_students
Expand Down
9 changes: 9 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,15 @@

end

if PreferableItem.count == 66
PreferableItem.create! item: "UserCourse",
item_type: "ChangeName",
name: "ChangeName",
default_value: "",
description: "Allow students to change their names in course",
default_display: true
end

if NavbarLinkType.count == 0
NavbarLinkType.create! link_type: 'module'
NavbarLinkType.create! link_type: 'admin'
Expand Down
76 changes: 76 additions & 0 deletions spec/features/course_specific_name_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require 'rails_helper'

describe 'Course specific name', type: :feature do
let!(:lecturer) { FactoryGirl.create(:lecturer) }
let!(:student) { FactoryGirl.create(:student) }
let!(:course) { FactoryGirl.create(:course, :with_student, creator: lecturer, student: student) }
let!(:user_course) { student.get_user_course(course) }

context 'when name change is allowed' do
before { Course.any_instance.stub(:allow_name_change?).and_return(true) }

context 'when change name in user profile' do
let(:new_name) { 'New Name' }

before do
sign_in student
visit users_settings_path
fill_in 'user_name', with: new_name
click_button 'Update'
end

it 'changes name in course' do
expect(user_course.reload.name).to eq new_name
end
end

context 'when change name in course' do
let(:new_name) { 'New Name' }

before do
sign_in lecturer
visit course_manage_students_path(course)
fill_in 'name', with: new_name
find(:xpath, '//button[@type="submit"]').click
end

it 'changes name in course' do
expect(user_course.reload.name).to eq new_name
end
end
end

context 'when name change is not allowed' do
before { Course.any_instance.stub(:allow_name_change?).and_return(false) }

context 'when change name in user profile' do
let(:new_name) { 'New Name' }

before do
sign_in student
visit users_settings_path
fill_in 'user_name', with: new_name
click_button 'Update'
end

it 'does not change name in course' do
expect(user_course.reload.name).not_to eq new_name
end
end

context 'when change name in course' do
let(:new_name) { 'New Name' }

before do
sign_in lecturer
visit course_manage_students_path(course)
fill_in 'name', with: new_name
find(:xpath, '//button[@type="submit"]').click
end

it 'changes name in course' do
expect(user_course.reload.name).to eq new_name
end
end
end
end

0 comments on commit 3db90e0

Please sign in to comment.