socialforge/app/views/layouts/_course_base_info.html.erb

114 lines
6.0 KiB
Plaintext

<%# is_teacher = User.current.logged? && User.current.allowed_to?(:as_teacher,@course) %>
<% teacher_num = Member.find_by_sql("SELECT count(*) as teacher_count FROM `member_roles` mr, `members` m where m.course_id=#{@course.id}
and m.id=mr.member_id and mr.role_id in ('3','7','9')").first.try(:teacher_count) %>
<% student_num = studentCount(@course) %>
<%# course_file_num = visable_attachemnts_incourse(@course).count %>
<p class="sy_cgrey mb10 mr20">
<%= link_to(@course.teacher.show_name, user_path(@course.teacher), :title => '主讲老师', :class => 'sy_cgrey') %>
&nbsp;&gt;&nbsp;
<% if @course.syllabus %>
<%=link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class => 'sy_cgrey', :title => '课程名称' %>
&nbsp;&gt;&nbsp;
<% end %>
<%=link_to @course.name, course_path(@course), :class => 'sy_cgrey' %>
</p>
<% if is_teacher %>
<div class="sy_class_setting" >
<ul>
<li class="sy_class_setting_icon">
<ul class="sy_class_setting_text">
<li><%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "sy_class_option" %></li>
<!--<li><%#= link_to "复制班级", copy_course_course_path(@course.id),:remote=>true, :class => "sy_class_option" %></li>-->
<% if @course.syllabus %>
<li><%= link_to "进入课程", syllabus_path(@course.syllabus), :class => "sy_class_option", :target => "_blank" %></li>
<% end %>
<% if @course.invite_code_halt == 0 %>
<li><a href="javascript:void(0);" class="sy_class_option" onclick="alert_halt_code();">暂停加入</a></li>
<% elsif @course.invite_code_halt == 1 %>
<li><a href="<%=set_invite_code_halt_course_path(@course) %>" data-remote="true" class="sy_class_option">放开加入</a></li>
<% end %>
<li><%= link_to "设置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "sy_class_option" %></li>
</ul>
</li>
</ul>
</div>
<% elsif User.current.logged? && User.current.member_of_course?(@course) %>
<div class="sy_class_setting" >
<ul>
<li class="sy_class_setting_icon">
<ul class="sy_class_setting_text">
<li>
<a href="javascript:void(0)" onclick="delete_confirm();" class="sy_class_option">退出班级</a>
</li>
</ul>
</li>
</ul>
</div>
<% end %>
<div class="cl"></div>
<div class="sy_class_logo fl">
<div class="pr" style="width: 96px; height:96px;">
<% if is_teacher%>
<%=link_to image_tag(url_to_avatar(@course),width:"96", height: "96", :id=>'nh_source_tx'), my_clear_user_avatar_temp_path(:course => @course.id), :remote => true%>
<div class="homepageEditProfile undis">
<%=link_to '', my_clear_user_avatar_temp_path(:course => @course.id), :class => 'homepageEditProfileIcon', :title => '点击编辑头像', :remote => true %>
</div>
<% else %>
<%= image_tag(url_to_avatar(@course), :width => "96", :height => "96", :alt => "班级logo") %>
<% end %>
</div>
</div>
<div class="sy_class_id fl">
<p>邀 请 码<br />
<span class="sy_corange">
<% if @course.invite_code_halt == 0 %>
<% if User.current.admin? || User.current.member_of_course?(@course) %>
<%=@course.generate_invite_code %>
<% else %>
<span class="f12">请询问老师</span>
<% end %>
<% else %>
已停用
<% end %>
</span>
</p>
</div>
<div class="sy_class_info fl ml15 mt14">
<div class="sy_class_titbox">
<h3 class="fl sy_class_title">
<%=@course.name %>
</h3>
<span class="<%= @course.is_public == 0 ? 'hw_icon_private' : 'hw_icon_open' %> fl mr20 mt3"></span>
<div class="cl"></div>
</div>
<p class="sy_cgrey mb5 f14 fl mt5">
<span class="mr25">教师:<%= course_teacher_link teacher_num %></span>
<span class="mr25">学生:<%= course_student_link student_num %></span>
<span class="mr25"><%= current_time_and_term @course %></span>
<span class="mr25"><%= get_occupation_from_user(@course.teacher).blank? ? '无' : get_occupation_from_user(@course.teacher) %></span>
</p>
<% is_TA = get_user_member_roles_course @course, User.current, 7 %>
<% is_TE = get_user_member_roles_course @course, User.current, 9 %>
<% is_ST = get_user_member_roles_course @course, User.current, 10 %>
<% if !is_teacher && is_TE %>
<%= link_to '教师身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => 10, :tar_role => (is_TA ? 7 : 9)), :class => "sy_btn_orange mr10 fl", :title => "由学生身份切换至教师身份" %>
<% elsif !is_teacher && is_TA %>
<%= link_to '助教身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => 10, :tar_role => (is_TA ? 7 : 9)), :class => "sy_btn_orange mr10 fl", :title => "由学生身份切换至教师身份" %>
<% elsif is_teacher && is_ST %>
<%= link_to '学生身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => (is_TA ? 7 : 9), :tar_role => 10), :class => "sy_btn_orange mr10 fl", :title => "由教师身份切换至学生身份" %>
<% end %>
<% unless (is_teacher || is_TA || is_TE || is_ST) %>
<div id="join_in_course_header" class="fl"><%= join_in_course_header(@course, User.current) %></div>
<% end %>
</div>
<div class="cl"></div>
<% if is_teacher %>
<div class="invite_code_tip_box fontGrey2" id="invite_code_tip_box">
<em></em>
<span></span>
<p class="mt10 mb5"><%= @course.invite_code_halt == 0 ? "请将邀请码告诉成员" : "邀请码已停用" %></p>
<p class="mb10"><%= @course.invite_code_halt == 0 ? "他们可以主动加入" : "暂时停止成员主动加入" %></p>
</div>
<% end %>