CSC/ECE 517 Fall 2015/oss E1565 AAJ: Difference between revisions
mNo edit summary |
(Added changes for admin_controller) |
||
Line 30: | Line 30: | ||
* Add a drop down to the view for creating users. The new account creator can select the institution from that drop down. | * Add a drop down to the view for creating users. The new account creator can select the institution from that drop down. | ||
* Write test cases and make sure that the institutions can be selected and saved. | * Write test cases and make sure that the institutions can be selected and saved. | ||
==Changes Made== | |||
===Part A=== | |||
====admin_controller.rb==== | |||
=== Modified <code>Action_allowed</code> method === | |||
Modified <code>Action_allowed</code> method to return true only if... | |||
{| class="wikitable" | |||
|- | |||
! |Before Refactoring | |||
! |After Refactoring | |||
|- style="vertical-align:top;" | |||
|<pre> | |||
def add_administrator | |||
@user = User.new | |||
end | |||
def create_administrator | |||
save_administrator | |||
end | |||
</pre> | |||
|<pre> | |||
def add_administrator | |||
@user = User.new | |||
redirect_to 'users#new' | |||
end | |||
def create_administrator | |||
save_administrator | |||
redirect_to "users#new" | |||
end | |||
</pre> | |||
|} |
Revision as of 15:52, 31 October 2015
E1565: Refactoring Admin Controller and Course Controller
This page provides a description of the Expertiza based OSS project aimed at refactoring Admin Controller and Course Controller.
In order to run our code visit the link 152.46.16.123:3000 and use the following credentials - username: admin, password: admin.
Introduction to Expertiza
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.
Project Description
Part A
Files Involved: admin_controller and views in app/views/admin folder What it does: Defines the changes that can be done on other types of user by super-admin and provides the view accordingly. Those functionalities can be found from UI when super-admin logs in and clicks on "Administration -> Show". Then they can see a list of super-admin, admin and instructors based on the selection. At the bottom of the list there is a feature to add new administrators, but it is broken.
What is wrong with it: The adding new admin functionality is broken and has to be fixed in a clean way. It should have the same view as that of user creation page.
What needs to be done:
- Remove the text filed for adding new super-admin/admin/instructor and leave only the button on the UI
- When the button is clicked, redirect it to the new user creation view, and make the role (super-admin/admin/instructor) selected as default.
- Make sure that new user creation works for super-admin/admin/instructor. Write a test case to test it.
Part B
Files involved: users_controller.
What’s wrong with it: In expertiza there is an institution table. But it does not associate the users with institutions.
What needs to be done:
- Do a db migration, create a “institution_id” column in users table.
- Add a drop down to the view for creating users. The new account creator can select the institution from that drop down.
- Write test cases and make sure that the institutions can be selected and saved.
Changes Made
Part A
admin_controller.rb
Modified Action_allowed
method
Modified Action_allowed
method to return true only if...
Before Refactoring | After Refactoring |
---|---|
def add_administrator @user = User.new end def create_administrator save_administrator end |
def add_administrator @user = User.new redirect_to 'users#new' end def create_administrator save_administrator redirect_to "users#new" end |