ashirahattia/cs169-pgm

View on GitHub
app/views/matches/index.html.erb

Summary

Maintainability
Test Coverage
<%= render "layouts/sidebar.html.erb" %>
<div class="content-container">
    <div class="content">
        <h1>Group-Project Matching</h1>
        <p>
            Below are the group-project pairs.
        </p>
        <% if session[:is_ta] %>
            <table>
                <tr>
                    <th scope="row">Preference ranking:</th>
                    <% 1.upto(8).each do |x| %>
                        <td><%=x%></td>
                    <% end %>
                </tr>
                <tr>
                    <th scope="row">Number of groups:</th>
                    <% 1.upto(8).each do |x| %>
                        <td><%=num_with_preference(x)%></td>
                    <% end %>
                </tr>
            </table>
            
        <% end %>   
        <div class="table-container">
            <table id="match_table" class="match-table">
                <tr>
                    <th class="match-header">Group #</th>
                    <th class="match-header">Associated Student</th>
                    <th class="match-header">Project Name</th>
                    <% if session[:is_ta] %>
                        <th class="match-header">Preference</th>
                    <% end %>
                </tr>
                
                <% @matches.count.times do |index| %>
                <tr>
                    <td class="group-name"><%= @matches[index].group.id %></td>
                    <td class="group-name"><%= @matches[index].group.username %></td>
                    <td class="project-name"><%= @matches[index].project.project_name %></td>
                    <% if session[:is_ta] %>
                        <td class="rank <%=rank_color(@matches[index])%>"><%= choice_num @matches[index] %></td>
                    <% end %>
                </tr>
                <% end %>
            </table> 
        </div>
        
        <% if session[:is_ta] %>
            <br>
            <div class="table_container">
                <table id="unmatched_projects_table" class="match-table">
                    <th class="match-header">Unmatched Projects</th>
                    <% find_unmatched_projects().each do |project| %>
                    <tr>
                        <td class="project-name"><%=project.project_name %></td>
                    </tr>
                    <% end %>
                </table>
            </div>
            <br>
            <h1>Loss Function:</h1>
            <p>
                You can adjust the matching by selecting one of the following loss functions and adjusting the match coefficient x appropriately. 
            </p>
            <h3>For power loss function:</h3>
            <br>
               When x < 1, the algorithm <b>prefers giving some groups their top choices</b> at the expense of giving other groups their worse choices.<br>
               When x > 1, the algorithm <b>avoids giving groups their worse choices</b> at the expense of not giving some groups their top choices.<br>
               When x = 1, the algorithm wants to minimize the average preference.</p>
            <h3>For exponential loss function:</h3>
               It does not make sense to have x <= 1. With higher values of x, the algorithm avoids giving groups their worse choices at the expense of not giving some groups their top choices. </p>
            <p><b>x must be in the range [1e-14, 10].</b><p>
            <form id='loss_function_form' action="/matches/new" method="get">
                <p>Power (pref^x) <input type="radio" id='power' name="loss_function" value="power" <%=MatchesController.class_variable_get(:@@power)%>> &emsp; &emsp;
                   Exponential (x^pref) <input type="radio" id='exponential' name="loss_function" value="exponential" <%=MatchesController.class_variable_get(:@@exponential)%>></p>
                <p>x=<input type="text" id='x' name="x" value=<%=MatchesController.class_variable_get(:@@x)%>></p>
                <a id="trigger-rematch" class="button" href="#">Re-match</a>

                <div id="rematch-confirm-modal" class="modal-wrapper">
                <div class="modal-bg">
                </div>
                <div class="modal-container">
                    <p>
                        Are you sure you want to re-match? This will destroy your previous matching
                    </p>
                    <div class="action-container">
                        <a id="trigger-cancel" class="button red" href="#">Cancel</a>
                        <input id="Re-Match" type="submit" class="button" value="Re-Match"/>
                    </div>
                </div>
            </div>
            </form>
        <% end %>
    </div>  
</div>